Jump to content
  • Advertisement
Sign in to follow this  
Mr Kickass

Multiple textures in HLSL without using ID3DXEffect

This topic is 4850 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

If you are not utilizing ID3DXEffect, is there something special you have to do to use multiple textures? I set my 3 textures using ID3DDevice9::SetTexture(), using samplers 0,1 and 2. All the samplers yield the same texture - tex0 -, but the wierd thing is if I try using 2 or 3 different samplers in the same function, one will yield the 2nd texture - tex1 - sometimes. Am I missing some sort of texture related semantic? From what I've read there is only TEXCOORD that is somewhat related to textures. /*__________________________________________________________________________ texture tex0; texture tex1; texture tex2; sampler2D ScreenSampler = sampler_state { Texture = (tex0); }; sampler2D LowRezSampler = sampler_state { Texture = (tex1); }; sampler2D _2x2Sampler = sampler_state { Texture = (tex2); }; float4 ps(in float2 texcoord0 : TEXCOORD0, in float2 texcoord1 : TEXCOORD1, in float2 texcoord2 : TEXCOORD2) : COLOR0 { float4 color = 0; float2 upright = {.5f,.5f}; float2 lowright = {.5f,-.5f}; float2 upleft = {-.5f,.5f}; float2 lowleft = {-.5f,-.5f}; color += tex2D(_2x2Sampler, upright) * 0.25f; color += tex2D(_2x2Sampler, lowright) * 0.25f; color += tex2D(_2x2Sampler, upleft) * 0.25f; color += tex2D(_2x2Sampler, lowleft) * 0.25f; return color; } /*_____________________________________________________________________________

Share this post


Link to post
Share on other sites
Advertisement
From your code it seems that you are only sampling from the same texture (_2x2Sampler): try using the other samplers that you defined.

Share this post


Link to post
Share on other sites
naming a texture "tex0" "tex1" and so on does not allow you to set it with SetTexture(0, ...). You need to declare your samplers like that :
sampler2D ScreenSampler : s0;
s0 means the sampler will be associated with the first texture sampler, and you can then set your texture with SetTexture(0, ...). you can specify s1 for the second sampler, and so on. You don't need to declare textures if you're not using fx files.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!