Jump to content
  • Advertisement
Sign in to follow this  
dhanji

HLSL Multitexturing

This topic is 5473 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok I am compiling my pixel shader for 1.4 and am trying to apply multiple textures:
//Pixel Shader
    PS_OUTPUT Output;
    Output.RGBColor = tex2D(MeshTextureSampler, In.TextureUV);
    Output.RGBColor *= tex2D(MeshTexture2Sampler, In.TextureUV);

    return Output;

Now this makes my screen go black, but if I use just one texture sampler I get the texture displaying correctly (so I know the textures are going into the shader fine). Also I am compiling for PS_1_4 which I know supports upto 4 sampling instructions (and I'm only trying to do 2). Any ideas? Also this displays texture 2 correctly:
    Output.RGBColor = tex2D(MeshTextureSampler, In.TextureUV);
    Output.RGBColor = tex2D(MeshTexture2Sampler, In.TextureUV);
so I know 2 samples are working. Just not modulating, why oh why? I even tried this:
    Output.RGBColor = tex2D(MeshTextureSampler, In.TextureUV);
    Output.RGBColor *= tex2D(MeshTexture2Sampler, In.TextureUV);
    Output.RGBColor.a = 1.0;
in case the alpha was being messed with. no dice, still a black screen.

Share this post


Link to post
Share on other sites
Advertisement
Try

Output.RGBColor = tex2D(MeshTextureSampler, In.TextureUV) * tex2D(MeshTexture2Sampler, In.TextureUV);


I'm not 100% sure how it works in HLSL but I don't think you can read from the output values (like *= does)

Share this post


Link to post
Share on other sites
ok I figured it out, you have to use different texture coordinates (or rebuild the existing one) like so:


In.TextureUV.xy += 0.000000001f; // < 1 texel


then you have to buffer it to a register, and then swizzle it into the color components (direct multiply doesnt work):


Output.RGBColor = tex2D(MeshTextureSampler, In.TextureUV);
In.TextureUV.xy += 0.000000001f; // < 1 texel
float4 clr2 = tex2D(MeshTexture2Sampler, In.TextureUV);
Output.RGBColor.rgb *= clr2.rgb;


this works fine.

Share this post


Link to post
Share on other sites
yea that's a good idea. I think the problem is that it's unable to read from the same register twice?
The same thing happens when I try to access the clr2 "variable" a second time.

Share this post


Link to post
Share on other sites
that is very odd behaviour (maybe even undefined) have you contacted MS tech support about this?

also, what video card and drivers are you using?

Share this post


Link to post
Share on other sites
ps_1_4 allows the usage of the same texture coordinate for several texture lookups, so that should work. ps_1_3 needs separate texture coordinates though.

Share this post


Link to post
Share on other sites
no I havent contacted ms. heh.
I have an ATI Radeon 9000 mobility running CATALYST 6.14.10.6348. I havent updated in awhile, maybe thats the problem?

I definitely narrowed it down to the unable to read from same register twice, issue.
Right now Im having to sample the 2nd texture twice over in the same pass.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!