Advertisement

Water planar reflection with physical correct normals

Started by October 30, 2020 11:52 AM
4 comments, last by Kripto289 4 years, 1 month ago

Hello,

Sorry for my english,

I have 2 methods for rendering reflection of water. On the screenshot you can see cubemap and screen space reflection. If I use cubmap then I get the correct image. For flat reflections(ssr/planar), I always see the formula

tex2D (reflectionTex, screenPos.xy + normal.xz);

in other projects, like a water from ue4/cryengine/unity/custom waters etc.
But this formula is completely incorrect, since the normals do not use the real displacement along the Y axis. For correct reflection, I use a this formula
half3 reflectionRay = reflect (viewDir, normal);
float4 ssr = tex2D (reflectionTex, float2 (reflectionRay.x * 0.5 + 0.5, reflectionRay.y + 0.5));
I want to get the right reflection like on the left side of the picture.

I don't understand how to fix perspective distortion for flat reflection (e.g. planar reflection / screen space reflection). Is any advices?

// this usually means doing SSR with normal mapped normals
...
float3 normal = normalize(texture(normalMap, texcoord)).xyz;
...
tex2D (reflectionTex, screenPos.xy + normal.xz);

have u tried this?

float3 reflectionRay = reflect (normalize(viewDir), normalize(normal));
float4 ssr = tex2D (reflectionTex, normalize(reflectionRay));

Until then ?

Advertisement

ddlox said:

// this usually means doing SSR with normal mapped normals
...
float3 normal = normalize(texture(normalMap, texcoord)).xyz;
...
tex2D (reflectionTex, screenPos.xy + normal.xz);

have u tried this?

float3 reflectionRay = reflect (normalize(viewDir), normalize(normal));
float4 ssr = tex2D (reflectionTex, normalize(reflectionRay));

Until then ?

I tried first formula but it's incorrect method.

The second formula the same, I use normalized normals and viewDir

look here:

Have fun ?

ddlox said:

look here:

Have fun ?

I use screen space planar(projected) reflections.

This method http://remi-genin.fr/blog/screen-space-plane-indexed-reflection-in-ghost-recon-wildlands/

It does not work with normals and works only like a simple “planar” reflection.

This topic is closed to new replies.

Advertisement