Why can't I find out the state of OpenGL lights in GLSL?

Is there a way to find out if the lights are turned on in GLSL, which doesn't include passing attributes or creating tons of different shaders?

How about using NVidia C for graphics (Cg)? Can I do this with Cg?

Now I am convinced that you cannot do this. But now I ask: why not?

+3
source share
4 answers

According to my understanding of the Enable or Disable section of GLSL Common Mistakes, this is a philosophical reason: shaders are written to redefine a fixed pipeline, so they should not rely on fixed pipeline conditions. You must use a different shader for every opportunity you need.

I also suggest that this may be a design choice based on the fact that the branches of the road on the GPU, and someone should have thought that you should not do such things as

if (gl_LightSource[0].enabled)
{ ... }

Firstly.

+6
source

unforgiven3 rights - GLSL does not provide access to fixed pipe permission states. You must submit it in a form.

+3
source

GLSL - - HLSL ( DirectX), , , , .

: - (

+1

(0,0,0,0) , .

0
source

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


All Articles