GLSL TOP — 2d Texture Array

Hello. Recently I started learning GLSL and I just can’t figure out how to create 2d Texture Array.
For example, I need to rotate one texture 4 times 90 degrees and put everything in one array.

I know how to do it through the Transform TOP, but it would be much more efficient to do everything with code at once.
GLSL_2d_array.tox (1.37 KB)

1 Like

I think this works.

[code]out vec4 fragColor;

mat2 rotate2d(float _angle){
return mat2(cos(_angle),-sin(_angle),
sin(_angle),cos(_angle));
}

void main()
{
float angle = (uTDCurrentDepth/4.) * (2.*PI);

vec4 color1 = texture(sTD2DInputs[0], (rotate2d(angle) *(vUV.st - vec2(0.5))) + vec2(0.5));
fragColor = TDOutputSwizzle(color1);

}
[/code]
GLSL_2d_array.tox (1.37 KB)

1 Like

David, thank you so much! Exactly what I need :slight_smile:

Wonderful, I was fiddling around to get texture instancing to work with my “Pre-Kepler Graphics Card” and didn’t mange to do so.
With this technique it worked !

Thanks for asking and thanks for answering :slight_smile: