Multi texturing

Started by
3 comments, last by jollyjeffers 17 years, 5 months ago
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
Advertisement
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>


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
And Im using an NVIDIA QUADRO FX 4500 card
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement