Sending GL Uniforms: Multiple floats versus vector packaging

Let's say I have four floating point values ​​that I want to send to the shader, of which the following is the best way to send them.

Sending them as separate floats:

uniform float uniformValue1;
uniform float uniformValue2;
uniform float uniformValue3;
uniform float uniformValue4;

void main()
{
    //do shader stuff here
}

Packing them in one vector:

uniform vec4 uniformValues;

void main()
{
    //do shader stuff here
}

I came across this document: https://www.khronos.org/webgl/public-mailing-list/archives/1003/pdf7z773meQcF.pdf

What talks about this subject is interesting to me: is OpenGL / OpenGLES / WebGL automatically wrapping uniforms, or is it something I should take care of myself?

+4
source share
2 answers

. API , , , , . ; , .

OpenGL 3.2+, : GPU, .

, Uniform blocks, , , . , , .

, ( OpenGL 4.3+), .

+2

does OpenGL/OpenGLES/WebGL automatically pack uniforms or is it something I should take care of myself?

  • , GL - , -.
0

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


All Articles