Skip to main content
syntax fix
Source Link
user1430
user1430

You're calling SetTexture in your main program (effectively). This binds the texture to a sampler index, not a named sampler variable in shader code... you're not assigning Tex2D in the shader anything. So when you sample it, you get black (all-zero) and multiplying all-zero the way you do will of course still yield all-zero.

You could confirm this by simply outputting a flat color from the shader instead -- don't multiply by the sampled color -- and you should see something.

To fix this, you could use the Effect interface and call SetTexture on a compiled effect, or you could indicate that your sampler should be bound to register 0 (which is what you're setting the texture to):

texture2D FirstTexture : register(t0);  
sampler someSamplertexsmp : register(0s0) = sampler_state  
{  
    Texture   = <FirstTexture>;  
}; 

You're calling SetTexture in your main program (effectively). This binds the texture to a sampler index, not a named sampler variable in shader code... you're not assigning Tex2D in the shader anything. So when you sample it, you get black (all-zero) and multiplying all-zero the way you do will of course still yield all-zero.

You could confirm this by simply outputting a flat color from the shader instead -- don't multiply by the sampled color -- and you should see something.

To fix this, you could use the Effect interface and call SetTexture on a compiled effect, or you could indicate that your sampler should be bound to register 0 (which is what you're setting the texture to):

sampler someSampler : register(0);

You're calling SetTexture in your main program (effectively). This binds the texture to a sampler index, not a named sampler variable in shader code... you're not assigning Tex2D in the shader anything. So when you sample it, you get black (all-zero) and multiplying all-zero the way you do will of course still yield all-zero.

You could confirm this by simply outputting a flat color from the shader instead -- don't multiply by the sampled color -- and you should see something.

To fix this, you could use the Effect interface and call SetTexture on a compiled effect, or you could indicate that your sampler should be bound to register 0 (which is what you're setting the texture to):

texture2D FirstTexture : register(t0);  
sampler texsmp : register(s0) = sampler_state  
{  
    Texture   = <FirstTexture>;  
}; 
Source Link
user1430
user1430

You're calling SetTexture in your main program (effectively). This binds the texture to a sampler index, not a named sampler variable in shader code... you're not assigning Tex2D in the shader anything. So when you sample it, you get black (all-zero) and multiplying all-zero the way you do will of course still yield all-zero.

You could confirm this by simply outputting a flat color from the shader instead -- don't multiply by the sampled color -- and you should see something.

To fix this, you could use the Effect interface and call SetTexture on a compiled effect, or you could indicate that your sampler should be bound to register 0 (which is what you're setting the texture to):

sampler someSampler : register(0);