Using more than one texture in hLSL
My shader has a sampler for a texture. When I want to bind a texture I use
g_pd3dDevice->SetTexture( 0, g_texture);
Now I want to have more than one texture, so I wanna do something like
g_pd3dDevice->SetTexture( 0, g_texture1);
g_pd3dDevice->SetTexture( 1, g_texture2);
g_pd3dDevice->SetTexture( 2, g_texture3);
But how should my sampler-declarations in HLSL look? (to bind the different samplers to the different "numbers"?)
This should help. Look at the end of each line. For instance, s1 is texture from stage 1 in SetTexture method.
uniform sampler2D texture : register(s0),uniform sampler2D anotherTexture : register(s1)
Quote:Original post by zurekx
My shader has a sampler for a texture. When I want to bind a texture I use
g_pd3dDevice->SetTexture( 0, g_texture);
Now I want to have more than one texture, so I wanna do something like
g_pd3dDevice->SetTexture( 0, g_texture1);
g_pd3dDevice->SetTexture( 1, g_texture2);
g_pd3dDevice->SetTexture( 2, g_texture3);
But how should my sampler-declarations in HLSL look? (to bind the different samplers to the different "numbers"?)
Slight side question, but if you're using HLSL, why are you not using the effect framework? With the effect framework you can just have this in your shader:
texture textureBlahsampler2D samplerBlah = sampler_state { texture = <textureBlah>;};
For each texture, and then when you set up the effect you can just do:
effect->SetValue("textureBlah", g_texture1, D3DX_DEFAULT);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement