L
L
lexdevel2015-08-18 14:50:05
OpenGL
lexdevel, 2015-08-18 14:50:05

How to use multiple textures in a GLSL shader?

Hello!
I am writing a 2D arcade game in OpenGL ES / GLSL. There is the following video , the code is here . This video shows how to render sprites very fast. I don't like building a pixel shader with a lot of conditions a little, I would like to make it more optimal - take the texture by index. Actually, this is the question. Is it possible to do something like:

varying vec2 textureCoord;
varying int textureIndex;
uniform sampler2D textureArray[32];

void main() {
    gl_FragColor = texture2D(textureArray[textureIndex], textureCoord);
}

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2015-08-18
@BasmanovDaniil

It is possible, but with limitations , it may not work on mobile phones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question