Sign in to follow this  

PixelShader Samplers ?

Recommended Posts

Endemoniada    430
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.

Share this post

Link to post
Share on other sites
Lui    115
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);

Share this post

Link to post
Share on other sites
Buckeye    10747
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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this