Mixing normal mapping and optic effects

Afternoon everyone.

I am trying to create an effect that uses reflection & refraction with a normal map, for effects like water, windows etc, unfortunately I have a very frustrating problem achieving this.

I have 2 different shaders, one is normal mapping and the other gives optic effects with a cubemap (reflection & refraction), both shaders work perfectly. The problem is I’m trying to put both shaders together for the final effect, and of course failing at it.

I know this is quite a big problem, but if anyone is able to spare a few minutes of their time I would be over the moon with joy!

I thought it would be best if I gave you my shaders and images of the result with the shaders, so I put them all in a 7zip archive for you to view.
BumpMap, Refraction shaders work, SGGlass is the problem shader.
Password: theglass

Shader link

Sorry for asking for so much, I’m just frazzled now.

Thank you.

Edit: Forgot to mention, the final result I keep getting, it looks like the reflection/refraction is not using the normal thats obtained from the normal map, it just continues to look like the original refraction shader.

If your shaders are working independently then I would look to make sure you haven’t left a texture/transform matrix/normal map active from one stage that should be disabled before then second stage.

I am not sure if I explained that well; but for a logic error in the code rather than in the shaders

I’ve combed through my code for days now and unfortunately I cannot see such an issue :frowning: So I’m guessing you see nothing wrong with the shaders either then?

Actually ill also try and rephrase the goal (poor writing skills). The effect is essentially… instead of using 1 normal from the quad for the reflection & refraction effect, I want to use a new normal at each fragment, extracted from the normal map.

This is a bit beyond me; maybe someone else can help

Alright, thanks for assisting :slight_smile:

This is DirectX but it might help


Problem Solved! finally!

I was missing this line of code in my vertex shader…

gl_TexCoord[0] = gl_MultiTexCoord0;

Can’t believe I didn’t notice this for so long! I guess I just had too many shaders open at a time I was working on, which made me miss the small details from overworking.

Thanks for the help.

Thanks you for sharing

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.