|
|
|
@ -35,8 +35,10 @@ void main_fp
|
|
|
|
|
|
|
|
|
|
, uniform sampler2D reflectionMap : register(s0)
|
|
|
|
|
, uniform sampler2D refractionMap : register(s1)
|
|
|
|
|
, uniform sampler2D normalMap : register(s2)
|
|
|
|
|
, uniform sampler2D depthMap : register(s2)
|
|
|
|
|
, uniform sampler2D normalMap : register(s3)
|
|
|
|
|
, uniform float time
|
|
|
|
|
, uniform float far
|
|
|
|
|
, uniform float4 fogParams
|
|
|
|
|
, uniform float4 fogColour
|
|
|
|
|
)
|
|
|
|
@ -45,6 +47,9 @@ void main_fp
|
|
|
|
|
float2 screenCoords = iScreenCoords.xy / iScreenCoords.z;
|
|
|
|
|
screenCoords.y = (1-saturate(renderTargetFlipping))+renderTargetFlipping*screenCoords.y;
|
|
|
|
|
|
|
|
|
|
float depth1 = tex2D(depthMap, screenCoords).r * far - iDepth;
|
|
|
|
|
depth1 = saturate(depth1 / 500.f);
|
|
|
|
|
|
|
|
|
|
float2 uv1 = iUv + time * float2(0.5, 0);
|
|
|
|
|
float2 uv2 = iUv + time * float2(0, 0.5);
|
|
|
|
|
float2 uv3 = iUv + time * float2(-0.5, 0);
|
|
|
|
@ -53,12 +58,14 @@ void main_fp
|
|
|
|
|
float4 normal = tex2D(normalMap, uv1) + tex2D(normalMap, uv2) + tex2D(normalMap, uv3) + tex2D(normalMap, uv4);
|
|
|
|
|
normal = normal / 4.f;
|
|
|
|
|
normal = 2*normal - 1;
|
|
|
|
|
screenCoords += normal.yx * 0.05;
|
|
|
|
|
|
|
|
|
|
float4 reflection = tex2D(reflectionMap, screenCoords);
|
|
|
|
|
float4 refraction = tex2D(refractionMap, screenCoords);
|
|
|
|
|
float2 screenCoords_reflect = screenCoords + normal.yx * 0.05;
|
|
|
|
|
float2 screenCoords_refract = screenCoords + normal.yx * 0.1 * depth1;
|
|
|
|
|
|
|
|
|
|
float4 reflection = tex2D(reflectionMap, screenCoords_reflect);
|
|
|
|
|
float4 refraction = tex2D(refractionMap, screenCoords_refract);
|
|
|
|
|
|
|
|
|
|
oColor.xyz = lerp(reflection.xyz, refraction.xyz, 1);
|
|
|
|
|
oColor.xyz = lerp(refraction.xyz, reflection.xyz, depth1);
|
|
|
|
|
|
|
|
|
|
float fogValue = saturate((iDepth - fogParams.y) * fogParams.w);
|
|
|
|
|
oColor.xyz = lerp(oColor.xyz, fogColour, fogValue);
|
|
|
|
|