Inventor/oivDepthPeeling_frag.h File Reference

This file contains fonction that should be used to correctly manage transparency in custom shaders. More...

Go to the source code of this file.

Defines

#define OIV_DEPTHPEELING_H

Functions

bool OivDepthPeel (vec3 fragmentCoords)
void OivDepthPeelingOutputColor (vec4 color)
void OivDepthPeelingOutputColor (vec4 color, vec3 coords)

Detailed Description

This file contains fonction that should be used to correctly manage transparency in custom shaders.

To properly handle transparency, your fragment shader should contains the following function calls:

These methods are accessible by including the <Inventor/oivDepthPeeling_frag.h> header in your shader:

Ex:


 void main()
 {
   if ( OivDepthPeel(gl_FragCoord.xyz) )
   {
     Vec4 color = vec4(1, 0, 0, 0.5);
     OivDepthPeelingOutputColor(color);
   }
 }

Definition in file oivDepthPeeling_frag.h.


Define Documentation

#define OIV_DEPTHPEELING_H

Function Documentation

bool OivDepthPeel ( vec3  fragmentCoords  ) 

This method peels the current fragment.

If the fragment must be ignored the method does the discard. The fragments coords must be in screen space (gl_FragCoord.xyz should always be used)

Returns true if the fragment should be shaded.

void OivDepthPeelingOutputColor ( vec4  color,
vec3  coords 
)

By default the depth generated by the rasterizer (gl_FragCoord.z) is used but some algorithms may modify the depth in the fragment shader.

In theses case gl_FragCoord.z is not valid and thus the user-defined depth coordinate must be explicitly specified

void OivDepthPeelingOutputColor ( vec4  color  ) 

When depth peeling is enabled OivDepthPeelingOutputColor must be called instead of using the gl_FragData[0] since some depth peeling techniques use MRTs (multiple render targets) or premultiply the color by the alpha value (on-the-fly blending for example).


Open Inventor Toolkit reference manual, generated on 12 Feb 2024
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/