About the code 'if 0>0'

#if 0 > 0
    vec4 plane;            
    #if 0 < 0
        bool clipped = true;               
        if ( clipped ) discard;
        #endif
    #endif

In the fragment shader,i find some code ‘0>0’,what is it use for used for?

Where did you find this code?

Looks like maybe it was compiled in some way and the first zero replaced a variable.

Something similar was discussed here: Where does `#define XXX` get added to GLSL code?

3 Likes

when i render sprite object,i get fragment shader code,’#if 0 > 0’ is in the code

You can find that part of the code in the clipping planes shader chunk. Basically, if you’re not using clipping planes, then the renderer transforms NUM_CLIPPING_PLANES to 0 and you get the result #if 0 > 0 so the GPU can skip that segment. It’s a nice shortcut to avoid making calculations that you don’t need. It’s also used with lights, shadows, and all kinds of material features that can be turned on/off.

If you were to use one clipping plane, then you’d get #if 1 > 0 and the code within would execute.

3 Likes

#if 0 > 0

personally, I think this is the head of a bird

thank you for your answer,i get i want from it