0
votes

I try to build up a complex water shader ( i got the water shader from an example in the internet ). Now i want to add some features, blend a pattern grid into the water which is blured. Atm the water and the blur works, but when i try to build up the blur effekt with some randomization ... i use to many instruction for the shader ... :(

I searched for topics like "hlsl multiple passes", "hlsl render to texture", "hlsl multiple passes without texture", cause i dont have an existing "ground" texture.

I build up the water from a normal map and a enviroment map, now ... is it possible to get this "whole map / texture / shader data" from the first pass into the second ? Cause when i only execute the both passes, the color from the first pass get completely overwritten :(

I hope you guys can understand my problem and have all the information you need.

Would be nice if you would help me.

Thanks...

1
What shader model do you use?miloszmaki

1 Answers

1
votes

You can try compiling for shader model 3.0. It allows to use more instructions.

If you want to perform multiple passes you don't have to use rendering to target. You should enable alpha blending to prevent previous colors from being overwritten.

However, this will not work if you need to sample the output of the previous pass. In this case you need 2 textures (A and B, both created as render targets). Follow these steps:

  1. Set render target to texture A.
  2. Render the first pass.
  3. Set render target to texture B (or to the final render target, if you don't need to sample texture B in the following render process).
  4. Set up hlsl sampler with texture A (using ID3DXEffect::SetTexture, for example).
  5. Render the second pass (using texture A for sampling).

If you have more than 2 passes, swap A and B and do steps 3.-5. for each pass.