Menu

#316 fix - passing array of textures to shader

Shader branch
open
nobody
None
5
2016-10-14
2016-10-14
No

I encountered a problem when passing an array of textures to a shader:

After setting two materials

    node->setMaterialTexture(0, driver->getTexture("./media/wall.bmp"));
    node->setMaterialTexture(1, driver->getTexture("./media/bark_loo.jpg"));

and passing them to the shader

    s32 TextureLayerID[] = {0, 1}; 
    services->setPixelShaderConstant("myTextures[0]", TextureLayerID, 2);

under both indexes is the same texture

uniform sampler2D myTextures[2];
varying vec2 texCoord;

void main (void)
{
    //gl_FragColor = texture2D(myTextures[0], texCoord);
    gl_FragColor = texture2D(myTextures[1], texCoord);
}

Attached patch makes it work. (I am not sure if this is the correct way to achieve this, though.)

1 Attachments

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.