HLSL Texture Sampler Question
I want a pixel shader that blends textures A and B based on a color I export from my modeling program.
For every vertex in my model I export Position, UV, Color1, Normal.
I can get single texture working just fine using the UV and setting the color to
Output.Color = tex2D(TextureSampler1, PSIn.cTextureCoords0)*clamp(PSIn.cLightingFactor + xAmbient,0,1);
Now, I want to take the sample from two textures and combine them based on a value I export with my mesh (in this case the X component of Color1).
However, doing the following:
vector tex1 = tex2D(TextureSampler1, PSIn.cTextureCoords0)*clamp(PSIn.cLightingFactor + xAmbient,0,1);
vector tex2 = tex2D(TextureSampler2, PSIn.cTextureCoords0)*clamp(PSIn.cLightingFactor + xAmbient,0,1);
I get the error stating " In ps_1_1, each sampler must have a unique TEXCOORD"
I've googled and don't see anything relevant or even close to this error. DO I need to duplicate my UVs for each sampler I need? Or am I going about this the wrong way?
Thanks,
Webby
Yes, you'll either have to pass down two copies of the same texture coordinate or switch to ps_2_0.
To expand on what Jalibr said... In ps.1.1 you can't use the same texcoord input twice. Add a second texcoord in your vertex output/pixel input. In your vertex shader, simply write your single input texcoord into both outputs.
Gah. The code I was playing with came from a demo online, I never thought to check the pixel shader version, obviously 1.0. The vertex shader was 2.0 and I just made the assumption.
So in PS 2.0 I can use the same UV pair for multiple samplers? Or do I still have to pass them down.
Even better, is there a document that specifies things like this?
Thanks,
Webby
So in PS 2.0 I can use the same UV pair for multiple samplers? Or do I still have to pass them down.
Even better, is there a document that specifies things like this?
Thanks,
Webby
The DirectX documentation does. Section DirectGraphics -> (opt. DirectX9) -> Reference -> HLSL
PS2.0 allows to sample arbitrary textures (samplers) using arbitrary texture coords up to 32 times per pixel shader. Even texture coords calculated in the pixel shader itsself can be used, but only to an indirection level of 6 AFAIK.
PS2.0 allows to sample arbitrary textures (samplers) using arbitrary texture coords up to 32 times per pixel shader. Even texture coords calculated in the pixel shader itsself can be used, but only to an indirection level of 6 AFAIK.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement