i´ve googled a lot and have read all the threads about this. But nothing works for me, so here´s my problem:
I cannot access a second, third.. texture within the shader. Only the first texture is being used
What I´ve got:
Shader Class
Code: Select all
class ShaderMergeResults : public scene::ISceneNode
{
public:
video::SMaterial Material;
...
virtual void OnSetConstants(...)
{
....
int texture1 = 0;
services->setPixelShaderConstant("tex1",(const float*)&texture1,1);
int texture2 = 1;
services->setPixelShaderConstant("tex2",(const float*)&texture2,1);
int texture3 = 2;
services->setPixelShaderConstant("tex3",(const float*)&texture3,1);
}
void initiate(...)
{
...
Material.setTexture(0, rendertarget_depth);
Material.setTexture(1, rendertarget_blur);
Material.setTexture(2, rendertarget_normal);
Material.MaterialType=(E_MATERIAL_TYPE)gpu->addHighLevelShaderMaterialFromFiles
(
vsFileName, "main", video::EVST_VS_1_1,
psFileName, "main", video::EPST_PS_1_1,
callback, (video::EMT_SOLID)
);
}
virtual void render()
{
u16 indices[] = {0,1,2,3,4,5};
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList(&Vertices[0], 6, &indices[0], 2);
}
Code: Select all
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform sampler2D tex3;
varying vec2 vTexCoord;
void main (void)
{
gl_FragColor = texture2D(tex2, vTexCoord);
}
BR,
magoon