Sign in to follow this  
shyampm

Multi texturing

Recommended Posts

shyampm    122
Hi guys, Im working with four textures...but when I am trying to sample the texture values within the shader program only the values for the 1st texture are being sampled...is there any flag or command to enable the other textures to be sampled too??? i would appreciate any help Thanks

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Help us to help you - some more details on how you're attempting multi-texturing for example [smile]

SM1 shaders had some limitations with regards to addressing/sampling textures but ISTR they generated compiler errors if you got it wrong.

Have you checked the disassembly of your shader? It's possible that the HLSL compiler is optimizing out your sampling if it determines it has no effect on the final result.

What shader model are you using? can you post the relevant code?

How is the application code set up? Are you definitely sure the correct textures are bound to the correct stages?

What hardware are you using?


Jack

Share this post


Link to post
Share on other sites
shyampm    122

Well, i do not have a complete knowledge of how this works..but Ill try and explain my difficulty....here is the piece of shader code Im working with....

PS_OUTPUT product( float4 pos : VPOS,
float2 a : TEXCOORD0,
float2 b : TEXCOORD1,
float2 c : TEXCOORD2,
float2 d : TEXCOORD3)
{
PS_OUTPUT Output;

float4 value_a = tex2D(samplerA, a);
float4 value_b = tex2D(samplerA, b);
float4 value_c = tex2D(samplerA, c);
float4 value_d = tex2D(samplerA, d);

Output.value = (value_a * value_c) + (value_b) ;
return Output;
}

The problem Im facing is that only value_a is being sampled correctly..that is the function tex2D is fetching the correct value at the texture coordinate specified by me in my main program.....based on this i tried specifying texture coordinates for all the other textures too and expected the values at these coordinates to be fetched...but the value that is being fetched for value_a is the same as that for value_c and value_b.while I expected them to be different....Is there a way I can get this working... I dunno if im thinking in the right way....please guide me

Share this post


Link to post
Share on other sites
jollyjeffers    1570
You're sampling the same texture each time:

float4 value_a = tex2D(samplerA, a);
float4 value_b = tex2D(samplerA, b);
float4 value_c = tex2D(samplerA, c);
float4 value_d = tex2D(samplerA, d);


The sampler will define the texture used, so you'd need to create four samplers (or however many) specifying each of the four textures.

Also, your value_d sample should be optimized away by the compiler as the value is never used.

hth
Jack

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