|
|
|
@ -79,7 +79,7 @@ float3 perturb(shTexture2D tex, float2 coords, float bend, float2 windDir, float
|
|
|
|
|
|
|
|
|
|
float3 getCaustics (shTexture2D causticMap, float3 worldPos, float3 waterEyePos, float3 worldNormal, float3 lightDirectionWS0, float waterLevel, float waterTimer, float3 windDir_windSpeed)
|
|
|
|
|
{
|
|
|
|
|
float waterDepth = shSaturate((waterEyePos.y - worldPos.z) / 50.0);
|
|
|
|
|
float waterDepth = shSaturate((waterEyePos.z - worldPos.z) / 50.0);
|
|
|
|
|
|
|
|
|
|
float3 causticPos = intercept(worldPos.xyz, lightDirectionWS0.xyz, float3(0,0,1), waterLevel);
|
|
|
|
|
|
|
|
|
@ -91,20 +91,21 @@ float3 getCaustics (shTexture2D causticMap, float3 worldPos, float3 waterEyePos,
|
|
|
|
|
// NOTE: the original shader calculated a tangent space basis here,
|
|
|
|
|
// but using only the world normal is cheaper and i couldn't see a visual difference
|
|
|
|
|
// also, if this effect gets moved to screen-space some day, it's unlikely to have tangent information
|
|
|
|
|
float3 causticNorm = worldNormal.xyz * perturb(causticMap, causticPos.xz, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).xyz * 2 - 1;
|
|
|
|
|
float3 causticNorm = worldNormal.xyz * perturb(causticMap, causticPos.xy, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).xyz * 2 - 1;
|
|
|
|
|
causticNorm = float3(causticNorm.x, causticNorm.y, -causticNorm.z);
|
|
|
|
|
|
|
|
|
|
//float fresnel = pow(clamp(dot(LV,causticnorm),0.0,1.0),2.0);
|
|
|
|
|
|
|
|
|
|
float NdotL = max(dot(worldNormal.xyz, lightDirectionWS0.xyz),0.0);
|
|
|
|
|
|
|
|
|
|
float causticR = 1.0-perturb(causticMap, causticPos.xz, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
|
|
|
|
float causticR = 1.0-perturb(causticMap, causticPos.xy, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
|
|
|
|
|
|
|
|
|
/// \todo sunFade
|
|
|
|
|
|
|
|
|
|
// float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*sunFade*causticdepth;
|
|
|
|
|
float3 caustics = clamp(pow(float3(causticR,causticR,causticR)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)),0.0,1.0)*NdotL*causticdepth;
|
|
|
|
|
float causticG = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
|
|
|
|
float causticB = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION*2.0, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
|
|
|
|
float causticG = 1.0-perturb(causticMap,causticPos.xy+(1.0-causticdepth)*ABBERATION, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
|
|
|
|
float causticB = 1.0-perturb(causticMap,causticPos.xy+(1.0-causticdepth)*ABBERATION*2.0, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
|
|
|
|
//caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*sunFade*causticdepth;
|
|
|
|
|
caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)))*NdotL*causticdepth;
|
|
|
|
|
|
|
|
|
|