Transpose Mat4 in OpenGL ES 2.0 GLSL

I would like to transpose the matrix in my vertex OpenGL ES 2.0 shader, but apparently my iPad 3 does not support GLSL #version 120 , which is necessary for the built-in transpose(mat4) function.

I know that there are options for working, such as transferring the matrix to the CPU before transferring it to the graphics chip, but this will make my shader much easier if I can transpose it.

So, is there a transpose mat4 option in the shader on an iOS 6 device?

Another thing: the question

What version of GLSL is used on iPhone (s)?

says OpenGL ES 2.0 uses GLSL 1.20. So why does #version 120 not work on iPad 3?

+4
source share
2 answers

Have you tried just rearranging it yourself? Is this a performance issue? If not, I would try, because this is what the optimizer should handle, and it will take two minutes. Sort of:

 highp mat4 transpose(in highp mat4 inMatrix) { highp vec4 i0 = inMatrix[0]; highp vec4 i1 = inMatrix[1]; highp vec4 i2 = inMatrix[2]; highp vec4 i3 = inMatrix[3]; highp mat4 outMatrix = mat4( vec4(i0.x, i1.x, i2.x, i3.x), vec4(i0.y, i1.y, i2.y, i3.y), vec4(i0.z, i1.z, i2.z, i3.z), vec4(i0.w, i1.w, i2.w, i3.w) ); return outMatrix; } 
+10
source

How is the answer to Which version of GLSL used in iPhone (s)? correctly states, iOS supports OpenGL ES 2.0 with its satellite shader language: ESSL 1.0, ESSL 1.0 is based on, but not identical to, GLSL 1.20.

There is no built-in transpose function in ESSL 1.0, so you will need to implement your own.

+3
source

Source: https://habr.com/ru/post/1495116/


All Articles