I'm not able to get it to work.
this is my IShaderConstantSetCallBack
Code: Select all
class MyShaderCallBack : public video::IShaderConstantSetCallBack
{
public:
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
for (int i = 0; i < 4; i++) m_samplers[i] = i;
video::IVideoDriver* driver = services->getVideoDriver();
services->setPixelShaderConstant("mLightColor", reinterpret_cast<f32*>(&m_color), 4);
services->setPixelShaderConstant("toon", m_samplers[0], 1);
services->setPixelShaderConstant("wall", m_samplers[1], 1);
}
video::SColorf m_color;
protected:
float m_samplers[4];
};
I used samplers attributes instead of allocating float[]'s eachs frame.
And my fragment program:
Code: Select all
//uniform sampler2D myTexture;
uniform sampler2D toon;
uniform sampler2D wall;
uniform sampler2D pepe;
uniform vec4 mLightColor;
void main(void)
{
gl_FragColor = texture2D(toon, vec2(gl_TexCoord[0])) + texture2D(wall, vec2(gl_TexCoord[1]));
}
I only see the same texture added over itself (while they are not the same). No matter what sampler2D name use in the texture2D caller, it always returns a sample of texture 0. Even if I call with "pepe" which is not defined in the SetConstants, I receive the texture 0.
The constant mLightColor arrives right to the fragment program.
Code: Select all
node->setMaterialTexture(0, driver->getTexture("wall.bmp"));
node->setMaterialTexture(1, driver->getTexture("toon.bmp"));
What could I be missing?