|
|
|
|
|
|
|
|
|
|
float2 AdjustedDepth(half2 uvs, half4 additionalData) |
|
|
|
{ |
|
|
|
float rawD = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_ScreenTextures_linear_clamp, uvs); |
|
|
|
float rawD = SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_ScreenTextures_linear_clamp, uvs).r; |
|
|
|
float d = LinearEyeDepth(rawD, _ZBufferParams); |
|
|
|
return float2(d * additionalData.x - additionalData.y, (rawD * -_ProjectionParams.x) + (1-UNITY_REVERSED_Z)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
half3 Refraction(half2 distortion, half depth, real depthMulti) |
|
|
|
{ |
|
|
|
half3 output = SAMPLE_TEXTURE2D_LOD(_CameraOpaqueTexture, sampler_CameraOpaqueTexture_linear_clamp, distortion, depth * 0.25).rgb; |
|
|
|
half3 output = SAMPLE_TEXTURE2D_X_LOD(_CameraOpaqueTexture, sampler_CameraOpaqueTexture_linear_clamp, distortion, depth * 0.25).rgb; |
|
|
|
output *= Absorption((depth) * depthMulti); |
|
|
|
return output; |
|
|
|
} |
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
// Dynamic displacement |
|
|
|
half4 waterFX = SAMPLE_TEXTURE2D_LOD(_WaterFXMap, sampler_ScreenTextures_linear_clamp, screenUV.xy, 0); |
|
|
|
half4 waterFX = SAMPLE_TEXTURE2D_X_LOD(_WaterFXMap, sampler_ScreenTextures_linear_clamp, screenUV.xy, 0); |
|
|
|
input.posWS.y += waterFX.w * 2 - 1; |
|
|
|
|
|
|
|
// After waves |
|
|
|
|
|
|
UNITY_SETUP_INSTANCE_ID(IN); |
|
|
|
half3 screenUV = IN.shadowCoord.xyz / IN.shadowCoord.w;//screen UVs |
|
|
|
|
|
|
|
half4 waterFX = SAMPLE_TEXTURE2D(_WaterFXMap, sampler_ScreenTextures_linear_clamp, IN.preWaveSP.xy); |
|
|
|
half4 waterFX = SAMPLE_TEXTURE2D_X(_WaterFXMap, sampler_ScreenTextures_linear_clamp, IN.preWaveSP.xy); |
|
|
|
|
|
|
|
// Depth |
|
|
|
float3 depth = WaterDepth(IN.posWS, IN.additionalData, screenUV.xy);// TODO - hardcoded shore depth UVs |
|
|
|