Package com.openinventor.inventor.nodes
Class SoFragmentShader
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.misc.SoBase
-
- com.openinventor.inventor.fields.SoFieldContainer
-
- com.openinventor.inventor.nodes.SoNode
-
- com.openinventor.inventor.nodes.SoShaderObject
-
- com.openinventor.inventor.nodes.SoFragmentShader
-
- All Implemented Interfaces:
SafeDisposable
public class SoFragmentShader extends SoShaderObject
Node that defines a fragment shader. This node defines a fragment shader.See
SoShaderProgram
for general information about using shaders and shader parameters.See parent class
SoShaderObject
for details about using the inherited fields.Notes:
- Shaders in the scene graph.
Shader object nodes cannot be inserted directly in a scene graph.
They must be added to the shaderObject field of anSoShaderProgram
node. - Predefined GLSL variables.
Open Inventor uses a compatibility profile context for rendering. So legacy GLSL predefined variables, for example gl_FragColor, can be used in fragment shaders. However, if you use the GLSL "#version" directive in a shader, you should append the keyword "compatibility", for example: "#version 150 compatibility". - Transparency.
To maintain compatibility with Open Inventor's high quality transparency algorithms like SORTED_PIXEL, fragment shaders should not output a color by setting gl_FragColor (or equivalent parameter) directly. Use the GLSL method OivDepthPeelingOutputColor() instead.
Fragment shaders can access the depthPeeling API using Open Inventor's built-in "include" mechanism as shown below. (Note: In the "oiv_include" statement there must not be any white space in the string "//!oiv_include". The space character shown below is required by a limitation of our documentation tools.)// Fragment shader GLSL code // !oiv_include <Inventor/oivDepthPeeling_frag.h> void main() { if (OivDepthPeel( gl_FragCoord.xyz )) { // Compute and set fragment color vec4 color = . . . OivDepthPeelingOutputColor( color ); } } - Transparency.
If a fragment shader makes geometry transparent (sets alpha values < 1), the application should set theSoShaderProgram.generateTransparency
field to true. This ensures that Open Inventor knows to apply the correct handling for the current transparency mode. - Shadows.
To integrate with Open Inventor's shadow casting algorithm, fragment shaders should call the GLSL methods OivComputeShadow() and OivGenerateShadowMap(). Please seeSoShadowGroup
for example code.
File format/default:
FragmentShader {
sourceProgram "" sourceType FILENAME isActive true parameter NULL
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoShaderObject
SoShaderObject.ShaderTypes, SoShaderObject.SourceTypes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.nodes.SoShaderObject
isActive, parameter, sourceProgram, sourceType
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoFragmentShader()
Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
getMaxTextureImageUnit()
Returns the maximum number of texture image units.static boolean
isSupported(SoShaderObject.SourceTypes sourceType)
Calls isSupported(sourceType, (com.openinventor.inventor.misc.SoState)null).static boolean
isSupported(SoShaderObject.SourceTypes sourceType, SoState state)
Indicates if fragment shaders in the specified language are supported by your graphics board.-
Methods inherited from class com.openinventor.inventor.nodes.SoShaderObject
getShaderType
-
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
-
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
-
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-
-
-
Method Detail
-
isSupported
public static boolean isSupported(SoShaderObject.SourceTypes sourceType)
Calls isSupported(sourceType, (com.openinventor.inventor.misc.SoState)null).
-
isSupported
public static boolean isSupported(SoShaderObject.SourceTypes sourceType, SoState state)
Indicates if fragment shaders in the specified language are supported by your graphics board. When using a debug build of Open Inventor, some "no context available" warning messages may be generated. You can ignore them or seeSoGLExtension
for an example of usingSoGLContext
to avoid them.
-
getMaxTextureImageUnit
public static int getMaxTextureImageUnit()
Returns the maximum number of texture image units.
-
-