To test it, I created a simple shader that maps one of the 6 textures on the mesh and switches between them every second. It works fine for tex0-3 but tex4-5 show black.
I am really sure that the textures are all correct (and non black) because when I show them on separate meshes without the shader on texture 0, they all show.
SceneNode:
Code: Select all
vlak = SCN()->addMeshSceneNode(tngmesh);
vlak->setName("vlak");
vlak->setPosition(vector3df(0.0f, 0.0f, 0.0f));
for (int i = 0; i < 6; ++i)
vlak->setMaterialTexture(i, tex[i]);
vlak->setMaterialFlag(EMF_LIGHTING, false);
vlak->setMaterialType((E_MATERIAL_TYPE)myShaderMtrlType);
Code: Select all
...
float idx = (float)(GetTickCount() % 6000) / 1000.0f;
services->setPixelShaderConstant("idx", &idx, 1);
Code: Select all
sampler2D tex0 : register(s0);
sampler2D tex1 : register(s1);
sampler2D tex2 : register(s2);
sampler2D tex3 : register(s3);
sampler2D tex4 : register(s4);
sampler2D tex5 : register(s5);
float idx;
float4 pixelMain(float2 Tex: TEXCOORD0) : COLOR
{
float4 Color;
float4 Color0 = tex2D(tex0, Tex);
float4 Color1 = tex2D(tex1, Tex);
float4 Color2 = tex2D(tex2, Tex);
float4 Color3 = tex2D(tex3, Tex);
float4 Color4 = tex2D(tex4, Tex);
float4 Color5 = tex2D(tex5, Tex);
if (idx < 1)
Color = Color0;
else if (idx < 2)
Color = Color1;
else if (idx < 3)
Color = Color2;
else if (idx < 4)
Color = Color3;
else if (idx < 5)
Color = Color4;
else
Color = Color5;
return Color;
}
D.