Noxalus
Noxalus

Reputation: 75

HLSL water refraction shader

I'm currently working on a water rendering project with XNA (DirectX9) and I spend a lot of time on a problem that I don't understand.

In my project, I render a terrain and an horizontal plane that represent the water. I'm currently trying to create the refractive texture that I will apply to this plane. To do that, I used a render target in which I render the part of the terrain that is under the water plane (clipping => into my HLSL file, during pixel shader operation). I transform this render target into a texture that I apply directly on the water plane.

The result that I would like to have is exactly the same than if I didn't draw the water plane, I just want to see the terrain that is under the water (no light beam deviation for the moment). But for now, I have a very strange result. I record some video to show you, it's better than any explanations: http://www.youtube.com/watch?v=XGesGvEnAEg

Here is the code of the HLSL file of refraction: https://gist.github.com/Noxalus/8213296

Do you know from where the problem come from?

Thanks in advance for your help!

Upvotes: 1

Views: 3095

Answers (1)

Ronan Thibaudau
Ronan Thibaudau

Reputation: 3603

Could be wrong but, looks to me like it's only rendered once & then reused? (looks transformed when you move around with the blue water plane, not refreshed)?

Are you sure you're updating the texture you pass to the refraction shader every frame?

Upvotes: 1

Related Questions