   Pixel Shader questions
  Hello,I am new to shader programming so I have a couple of questions.I want to write 2 pixel shaders the first one works with 3 texturesand the other one works with the output texture of the previousshader and a different texture. I am not using the effect frameworkMy question are:1 > When creating the two pixel shaders there is parameter whichneeds to be passed( the constanttable pointer). Now should there    be different constant table for each pixel shader.2 > In the application I need to specify the SetTexture function    to associate a texture to a particular stage. How do    I associate the texture to the texture names inside thepixel shader.3 > the function used inside the shader to index texture is    tex2D but it takes the argument of type sampler.    How do I associate a texture to a sampler.Thank you,Sri   
  You can only run one pixelshader per pass.   ;Quote:Original post by sriI want to write 2 pixel shaders the first one works with 3 texturesand the other one works with the output texture of the previousshader and a different texture.You will need to create an intermediary texture as a render target (D3DUSAGE_RENDERTARGET) and output the first stage (3 textures) to this target (note: you have to manually switch using IDirect3DDevice9::SetRenderTarget()). You can then use this texture (as well as the other you mention) as inputs into the second shader that renders to the screen (or wherever!)...Quote:Original post by sri1 > When creating the two pixel shaders there is parameter whichneeds to be passed( the constanttable pointer). Now should there    be different constant table for each pixel shader.The constant table is just a thin mapping between the aliases used in HLSL and the raw constant-register addresses. You will need a constant table for each pixel shader, and you will also need to configure the values for those constants before each invocation.Quote:Original post by sri2 > In the application I need to specify the SetTexture function    to associate a texture to a particular stage. How do    I associate the texture to the texture names inside thepixel shader.I'm pretty sure you'll need to wrap up a texture inside a sampler. Although you might want to check the documentation as I'm not entirely sure [oh]Quote:Original post by sri3 > the function used inside the shader to index texture is    tex2D but it takes the argument of type sampler.    How do I associate a texture to a sampler.At the top of your HLSL shader:sampler my_texture : register( s0 );Where s0 can be 0-15, corresponding to the index used in SetTexture().hthJack   ;  Thanks jack,I wrote one pixel shader with all the information you gave and every thingworked fine. I got the desired output from my fisrt pixel shaderbut when I wrote the second pixel shader for some reason theoutput of my first pixel shader has changed. I don't know why.What could I be doing wrong.Thanks again for the help. Sri   