Access to the uniform of the same name in vertex and fragment shaders is not performed

I'm still very inexperienced with shaders, but I am good at climbing the learning curve.

What I stumbled upon this morning is an attempt to use the uniform type in both fragmented and vertex shaders.

A uniform can be defined in both shaders, but access to it is possible only in one or the other shader, but not in both. If I try to access the shader in both cases, the program will not compile.

The last idea I used is that they are compiled as separate characters, but I don’t know how to access them except glGetUniformLocation. A call that returns the same uniform location twice with the same line ... doesn't help much.

Shaders are pretty simple, and everything works just fine, with the exception of single-line or non-tests, which do not affect rendering.

Is there a special approach for using the uniform uniform with the same value between two shaders?

+4
source share
1 answer

SOLVE! Determining accuracy is usually not a requirement in my experience. I did not use it ... and because my uniform was an integer.

I read the confirmation that uniforms can be of the same name between vertices and fragments of shaders here:

http://www.gamedev.net/topic/535321-glsl-the-same-named-uniform-in-vertex-and-fragment-shaders/

, .

, highp, .

:

1 ()

Vertex shader:
uniform int frameNum;

Fragment shader:
uniform int frameNum;

2 ()

Vertex shader:
uniform highp int frameNum;

Fragment shader:
uniform int frameNum;

3 ()

Vertex shader:
uniform highp int frameNum;

Fragment shader:
uniform highp int frameNum;

4 ()

Vertex shader:
uniform int frameNum;

Fragment shader:
uniform highp int frameNum;
+9

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


All Articles