PixelShader Samplers ?
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.
If you're using the Effects framework, you should use ID3DXEffect::SetTexture(), rather than going straight to the device.
Have you created the sampler state for your textures?
sampler2D image1 = sampler_state {texture = <yourtext>//add your filters};
Something like:
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.
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.
Each sampler must have a unique set of tex coords.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement