Sign in to follow this  
Endemoniada

PixelShader Samplers ?

Recommended Posts

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
If you're using the Effects framework, you should use ID3DXEffect::SetTexture(), rather than going straight to the device.

Share this post


Link to post
Share on other sites
Have you created the sampler state for your textures?


sampler2D image1 = sampler_state {
texture = <yourtext>
//add your filters
};

Share this post


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

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