Using more than one texture in hLSL

Started by
2 comments, last by Cycles 16 years, 1 month ago
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"?)
Advertisement
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)
jid: sebastian.szymanski@jid.pl
The HLSL equivalent should be

sampler TextureSampler : register(s0); // s0 ... sN
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);
Oliver Charles (aka aCiD2) [ Cycles Blog ]

This topic is closed to new replies.

Advertisement