Jump to content
  • Advertisement
Sign in to follow this  
mishal153

How to bind samplers to texture stages ?

This topic is 3792 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If i declare a sampler in my HLSL pixel shader then how do bind a particular texture stage to that sampler ? Like we initialize uniform variables is there any way to initialize samplers from app code ? thanks Mishal

Share this post


Link to post
Share on other sites
Advertisement
I tried a small experiment. Here's my Pixel shader :

// Pixel shader input structure
struct PS_INPUT
{
float2 Texture : TEXCOORD0;
};

// Pixel shader output structure
struct PS_OUTPUT
{
float4 Color : COLOR0;
};


// Global variables
sampler2D Tex0;
sampler2D Tex1;

PS_OUTPUT ps_main( in PS_INPUT In )
{
PS_OUTPUT Out; //create an output pixel

Out.Color = tex2D(Tex1, In.Texture);
// Out.Color = tex2D(Tex0, In.Texture)

return Out; //return output pixel
}
//------------end of shader----------------

In my app i have 2 different textures. I set one on stage 0 and another in stage 1. But in my shader both Tex0 and Tex1 point to the texture on stage 1 for some reason. How do i use the stage 0 texture ?

Share this post


Link to post
Share on other sites
ok this is extremely stupid. Firstly, i was making a mistake in creating textures...i was using the same pointer to texture(LPDIRECT3DTEXTURE9). Forget it...after rectifying it i see that if there are 2 textures set and the pixel shader is doing:

PS_OUTPUT Out; //create an output pixel
float4 c0 = tex2D(Tex0, In.Texture);
float4 c1 = tex2D(Tex1, In.Texture);

Out.Color = c0*c1;

then both textures are sampled and all goes well. BUT if i do:

Out.Color = c0;

or

Out.Color = c1;

i get same color !!

driver acting over smart ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!