PixelShader Samplers ?

Started by
4 comments, last by Buckeye 16 years, 1 month ago
Hi guys, I want my pixel shader to have access to two (or more) textures: // app g_d3d_device->SetTexture(0,texture_0); g_d3d_device->SetTexture(1,texture_1); // shader sampler2D image0; // I can't find a sematic for here sampler2D image1; // this should output texture_0 output.color=tex2D(image0,input.uv); // and this should output texture_1 output.color=tex2D(image1,input.uv); ...but they both output the same thing, whatever is in stage0 I see tons of HLSL examples but they rarely show you how to get stuff into the shader. Thanks.
Advertisement
If you're using the Effects framework, you should use ID3DXEffect::SetTexture(), rather than going straight to the device.
NextWar: The Quest for Earth available now for Windows Phone 7.
What if I'm not using the Effects Framework ?
Have you created the sampler state for your textures?

sampler2D image1 = sampler_state {texture = <yourtext>//add your filters};
Something like:
sampler image : register(s0);

should do what you want.

But I would also rather suggest using the sampler state parameters.
If you also need to set filtering or addressing parameters, they can be set by global integer variables.

int g_TexFilter;int g_TexAnisotropy;texture g_Texture;sampler g_sTex = sampler_state{    Texture = <g_Texture>;    AddressU = Wrap;    AddressV = Wrap;    MipFilter = LINEAR;    MagFilter = LINEAR;    MinFilter = (g_TexFilter);    MaxAnisotropy = (g_TexAnisotropy);}

You may also need to use different uv's for each of the two textures.

Each sampler must have a unique set of tex coords.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement