CalmWater_Caustics.cginc 881 B

12345678910111213141516171819202122232425
  1. #ifndef CALMWATER_CAUSTICS_INCLUDED
  2. #define CALMWATER_CAUSTICS_INCLUDED
  3. // ===========================================================================
  4. // Caustics
  5. // ===========================================================================
  6. void ComputeCaustics(inout GlobalData data)
  7. {
  8. #ifdef UNITY_PASS_FORWARDBASE
  9. #ifndef CULL_FRONT
  10. #if _CAUSTICS_ON
  11. float2 causticsUV = ProjectedWorldPos(data.worldPosition.xyz, data.depth, data.DepthUV.z).xz / _CausticsTex_ST.xy + _CausticsTex_ST.zw;
  12. causticsUV += data.worldNormal.xy * 0.0015 * _Distortion;
  13. causticsUV += frac(_Time.x * _CausticsSpeed);
  14. float causticsDepth = DistanceFade(data.depth, data.DepthUV.z, _CausticsStart, _CausticsEnd);
  15. data.finalColor += tex2D(_CausticsTex, causticsUV) * causticsDepth * data.finalColor * _CausticsIntensity * _LightColor0.rgb;
  16. #endif
  17. #endif
  18. #endif
  19. }
  20. #endif