javax.media.j3d
Class Shader

java.lang.Object
  extended by javax.media.j3d.SceneGraphObject
      extended by javax.media.j3d.NodeComponent
          extended by javax.media.j3d.Shader
Direct Known Subclasses:
SourceCodeShader

public abstract class Shader
extends NodeComponent

The Shader object is the abstract base class for programmable shader code. Currently, only text-based source code shaders are supported, so the only subclass of Shader is SourceCodeShader. We leave open the possibility for binary (object code) shaders in the future.

Each instance of a Shader object allows an application to specify the source code used in programming the Graphics Pipeline Unit (GPU) of the graphics accelerator. A Shader object is constructed with modes that specify the shading language and the shader type.

The shading language specifies the language and runtime environment used to program the GPU. The currently defined shading languages are GLSL (also known as the OpenGL 2.0 shading language) and Cg. Note that not all shading languages are supported on all platforms. It is up to the application or utility to query whether a particular shading language is supported before using it. The value of the shadingLanguage mode is one of: SHADING_LANGUAGE_GLSL or SHADING_LANGUAGE_CG.

The shader type specifies whether the shader is a vertex shader or a fragment shader. A vertex shader replaces the fixed-function graphics pipeline for vertex operations (transformation and lighting). A fragment shader replaces the fixed-function graphics pipeline for fragment shading operations (texture mapping, texture application, coloring, shading, and so forth). The value of the shaderType mode is one of: SHADER_TYPE_VERTEX or SHADER_TYPE_FRAGMENT.

Both the shading language and shader type are immutable modes of the Shader object.

NOTE: Applications should not extend this class.

Since:
Java 3D 1.4
See Also:
ShaderProgram, Canvas3D.isShadingLanguageSupported(int)

Field Summary
static int SHADER_TYPE_FRAGMENT
          This constant indicates that the shader type is a fragment shader.
static int SHADER_TYPE_VERTEX
          This constant indicates that the shader type is a vertex shader.
static int SHADING_LANGUAGE_CG
          This constant indicates the Cg shading language.
static int SHADING_LANGUAGE_GLSL
          This constant indicates the GLSL shading language.
 
Method Summary
 int getShaderType()
          Returns the type of this shader.
 int getShadingLanguage()
          Returns the shading language of this shader.
 
Methods inherited from class javax.media.j3d.NodeComponent
cloneNodeComponent, cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SHADING_LANGUAGE_GLSL

public static final int SHADING_LANGUAGE_GLSL
This constant indicates the GLSL shading language. It is one of the possible values of the shadingLanguage parameter.

See Also:
Constant Field Values

SHADING_LANGUAGE_CG

public static final int SHADING_LANGUAGE_CG
This constant indicates the Cg shading language. It is one of the possible values of the shadingLanguage parameter.

See Also:
Constant Field Values

SHADER_TYPE_VERTEX

public static final int SHADER_TYPE_VERTEX
This constant indicates that the shader type is a vertex shader. It is one of the possible values of the shaderType parameter.

See Also:
Constant Field Values

SHADER_TYPE_FRAGMENT

public static final int SHADER_TYPE_FRAGMENT
This constant indicates that the shader type is a fragment shader. It is one of the possible values of the shaderType parameter.

See Also:
Constant Field Values
Method Detail

getShadingLanguage

public int getShadingLanguage()
Returns the shading language of this shader.

Returns:
the shading language of this shader, one of: SHADING_LANGUAGE_GLSL or SHADING_LANGUAGE_CG.

getShaderType

public int getShaderType()
Returns the type of this shader.

Returns:
the shader type, one of: SHADER_TYPE_VERTEX or SHADER_TYPE_FRAGMENT.