Hello There, Guest! Login Register

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modifying water shader to reflect environment
So I'm trying to modify water_pass2_ps20 to produce reflections and refractions, although with my limited knowledge of HLSL (which mostly stems from C++ anyways) I was unsuccessful.

float3 envMapCol = texCUBE(envMap, rView);
float3 envMapCol = reflect(dp, rView);

does NOT work, and I'm not sure else to go about making the shader reflect. Any ideas?
[Image: RebelFactionStanding.png]
Go get a hold of Sytner, he had fully reflective water with waves working.

I still haven't invested the time to learn HLSL, too busy atm.
(2013-01-30, 01:50 AM)Timbab Wrote: Go get a hold of Sytner, he had fully reflective water with waves working.

Sytner, from what I hear, has a reputation for disappearing.

(2013-01-30, 01:50 AM)Timbab Wrote: I still haven't invested the time to learn HLSL, too busy atm.

I tried looking up online tutorials of the topic, and I think they all sucked. I should go over them again though just to be sure.
[Image: RebelFactionStanding.png]
Screw it I been doing this response way too many times, I suck at explaining stuff.

I been taught DX10/11 + PS/VS 4.0, can't apply my knowledge entirely to this unfortunately I do things completely differen't in shaders. Shader layouts in general in SWG are annoying to work with (well to read)

Anyway to jump straight in, for me in 4.0 pass in the incident and the normal of the 2 water and then sample it onto the map and get the reflected color.

Edit: The reflect function passes back "reflectW" and not the actual color, its different in 2.0 vs 4.0 but managed to find source which is a bit below to how to apply it properly.

Now looking around at what my University gave me to help with DirectX found some old DX9 (when they use to teach it) and its got some older stuff that is definitely relevant, my experience is pretty much useless on unique function calls, here is basicly what your trying to do:

This is from a water example (This is just a small snippet there is a lot more before hand):

float3 envMapTex = reflect(-toEyeW, normalW) + (normalT*2.0f);
float3 reflectedColor = texCUBE(EnvMap, envMapTex);

So basicly you want to keep the texCUBE code but you want to get the reflection before it and pass it into it, this will return the color to then to can use when calculating the ambient and diffuse material.

So now its just about replacing -toEyeW, normalW and normalT and tweaking the maths behind it.

I only can say for sure that NormalT is infact "norm"

float3 norm0 = 2*(tex2D(normalMap0, norm0tc)-0.5);
float3 norm1 = 2*(tex2D(normalMap1, norm1tc)-0.5);
float3 norm = normalize(norm0 + norm1);

For the rest you will have to work it out, hope this in some way helps. If I made no sense at one point then thats because I suck at explaining and rewritten this a bit because I kept talking with 4.0 rather then 2.0
[Image: 2156b479.gif]

Forum Jump:

Browsing: 1 Guest(s)