|
|
|
@ -64,7 +64,6 @@ 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;
|
|
|
|
|
//normal = normalize(normal);
|
|
|
|
|
|
|
|
|
|
float2 screenCoords_reflect = screenCoords + normal.yx * 0.05;
|
|
|
|
|
float2 screenCoords_refract = screenCoords + normal.yx * 0.1 * depth1;
|
|
|
|
@ -72,11 +71,14 @@ void main_fp
|
|
|
|
|
float4 reflection = tex2D(reflectionMap, screenCoords_reflect);
|
|
|
|
|
float4 refraction = tex2D(refractionMap, screenCoords_refract);
|
|
|
|
|
|
|
|
|
|
// tangent to object space
|
|
|
|
|
normal.xyz = normal.xzy;
|
|
|
|
|
|
|
|
|
|
// fresnel
|
|
|
|
|
//float facing = 1.0 - max(abs(dot(iEyeVector.xyz, normal.xyz)), 0);
|
|
|
|
|
//float reflectionFactor = saturate(0.3 + 0.7 * pow(facing, 2));
|
|
|
|
|
float facing = 1.0 - max(abs(dot(normalize(iEyeVector.xyz), normal.xyz)), 0);
|
|
|
|
|
float reflectionFactor = saturate(0.3 + 0.7 * pow(facing, 2));
|
|
|
|
|
|
|
|
|
|
oColor.xyz = lerp(refraction.xyz, reflection.xyz, depth1);
|
|
|
|
|
oColor.xyz = lerp(refraction.xyz, reflection.xyz, depth1 * reflectionFactor);
|
|
|
|
|
|
|
|
|
|
float fogValue = saturate((iDepth - fogParams.y) * fogParams.w);
|
|
|
|
|
oColor.xyz = lerp(oColor.xyz, fogColour, fogValue);
|
|
|
|
|