Extensible 3D (X3D)
Part 1: Architecture and base components
OpenGL Shading Language
This annex defines how a browser implementing the Shader component maps the concepts of the OpenGL Shading Language to the Shading Component. It applies to the ComposedShader node that sets the language field to "GLSL".
Table 1 provides links to the major topics in this annex.
The vertex shader replaces the fixed functionality of the vertex processor. The OpenGL specification states that the following functionality is disabled if a vertex shader is supplied:
The fragment shader replaces the fixed functionality of the fragment processor. The OpenGL specification states that the following functionality is disabled if a fragment shader is supplied:
The LoadSensor node (See 9.4.3 LoadSensor) has two output fields isActive and isLoaded. The isLoaded field behaviour is unchanged.
The isActive field is defined to issue a TRUE event when the all the following conditions have been satisifed:
The LoadSensor node does not have any interaction with the process of linking multiple shader objects into a complete shader program.
Each vertex attribute node directly maps the name field to the uniform variable of the same name. If the name is not available as a uniform variable in the provided shader source, the values of the node shall be ignored.
The browser implementation shall automatically assign appropriate internal index values for each attribute
Fields that are of type SFNode/MFNode are ignored unless the value is of type X3DTextureNode. Field instances of type X3DTextureNode are mapped according to the appropriate sampler data type. The texture types are mapped as as defined in Table 2
|X3D Texture type||GLSL Variable Type|
X3D does not define mappings to the OpenGL types sampler1D, sampler1DShadow and sampler2DShadow
Table 3 indicates how the X3D field types shall be mapped to OpenGL data types used in the OpenGL Shading Language.
|X3D Field type||GLSL Variable Type|
|SFNode||See 4.1 Node Fields|
|MFNode||See 4.1 Node Fields|
OpenGL defines maximum supported lengths of each array data type, which may conflict with the minimum support requirements for X3D. OpenGL will automatically convert double precision data types to single precision types.
When the url receives an event changing the value, the browser shall immediately attempt to download the new source. Upon successful download, the browser shall attempt to compile the new source and issue the appropriate LoadSensor events. It shall not automatically relink the shader program, nor disable the currently running shader. This follows the semantics of the OpenGL API requirements for separate register-compile-link steps.
Values defined at load time of the file, do not require an explicit request to relink. It shall be assumed to automatically link once all the objects have successfully downloaded. If some of the shader source files are not downloaded or compiled (eg due to errors) then no linking will occur for the shader program
If at any time after the initial load, the user changes the values of the object field, the user shall need to request an explicit relink of the containing shader program. The containing ComposedShader shall not automatically relink, nor should it automatically disable the current shader.
Per-vertex attributes may be defined as one of the fields of X3DComposedGeometryNode. These may be changed at runtime by adding or removing node instances. Adding new node instances to the field shall require that the user request an explicit relink in order to make them visible to the shader.
The user may, at any time, request that OpenGL re-link the composing shader objects by sending a TRUE value to the activate inputOnly field of the ComposedShader node. Users may need to force a re-link of the ComposedShader under various circumstances, such as changing the url field of one or more ShaderPart nodes, or adding or removing ShaderPart nodes. Relinking the shader shall replace the existing shader with the new executable.
Xj3D Homepage |
Xj3D @ Web3d |
Dev docs |
Dev Releases |
Last updated: $Date: 2004-09-16 19:52:10 $