Answer the question
In order to leave comments, you need to log in
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);
}
Answer the question
In order to leave comments, you need to log in
It is possible, but with limitations , it may not work on mobile phones.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question