H3D API
2.4.1
|
The ComposedShader node defines a shader where the individual source files are not individually programmable. More...
#include <H3D/ComposedShader.h>
Classes | |
class | MFShaderPart |
MFShaderPart is specialized to transfer a pointer from itself to the ShaderPart instances contained in the field. More... | |
class | SetupDynamicRoutes |
Class used to set up routes from nodes in SFNode and MFNode fields to correctly break cache. More... | |
class | UpdateCache |
event collection field to update when global caching is update More... | |
class | UpdateUniforms |
A field used to update any uniforms from their corresponding fields. More... | |
Public Types | |
typedef DependentSFNode< ShaderConstants, FieldRef< H3DDisplayListObject, H3DDisplayListObject::DisplayList, &H3DDisplayListObject::displayList >, true > | SFShaderConstantsBase |
The SFShaderConstants field is dependent on the displayList field of the containing ShaderConstants node. | |
typedef DependentMFNode< ShaderPart, FieldRef< ShaderPart, ShaderPart::SFShaderString, &ShaderPart::shaderString >, true > | MFShaderPartBase |
The MFShaderPartBase is dependent on the url field of the containing ShaderPart node. | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
Public Member Functions | |
ComposedShader (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0, Inst< SFBool > _isSelected=0, Inst< SFBool > _isValid=0, Inst< SFBool > _activate=0, Inst< SFString > _language=0, Inst< MFShaderPart > _parts=0, Inst< SFBool > _suppressUniformWarnings=0, Inst< SFString > _geometryInputType=0, Inst< SFString > _geometryOutputType=0, Inst< SFInt32 > _geometryVerticesOut=0, Inst< SFString > _transparencyDetectMode=0, Inst< MFString > _transformFeedbackVaryings=0, Inst< SFBool > _printShaderWarnings=0, Inst< SFShaderConstants > _shaderConstants=0) | |
Constructor. | |
virtual | ~ComposedShader () |
Destructor. | |
virtual bool | addField (const string &_name, const Field::AccessType &access, Field *field) |
The addField method is specialized to add a route from the field added to the displayList field. | |
virtual bool | removeField (const string &_name) |
The removeField method is specialized to remove the route from the field to the displayList field. | |
virtual void | traverseSG (TraverseInfo &ti) |
Traverse the node. More... | |
virtual void | render () |
Sets up the shader program and sets uniform variable values. | |
virtual void | preRender () |
Enables the shader program. | |
virtual void | postRender () |
Disables the shader program. | |
virtual GLbitfield | getAffectedGLAttribs () |
Returns a bitmask of the OpenGL attrib bits that will be affected by this node. More... | |
virtual bool | isTransparent (X3DMaterialNode *material) |
Returns a hint if the X3DShaderNode produces an alpha channel that is < 1, i.e. More... | |
GLhandleARB | getProgramHandle () |
Returns the OpenGL shader program handle used by the ComposedShader. | |
![]() | |
X3DShaderNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0, Inst< SFBool > _isSelected=0, Inst< SFBool > _isValid=0, Inst< SFBool > _activate=0, Inst< SFString > _language=0) | |
Constructor. | |
virtual bool | isSupported () |
Returns true if the shader node type is supported by the browser. More... | |
void | setSelected (bool selected) |
Set the isSelected field. | |
virtual string | defaultXMLContainerField () |
Returns the default xml containerField attribute value. More... | |
![]() | |
X3DAppearanceChildNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0) | |
Constructor. | |
![]() | |
X3DNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
X3DMetadataObject * | getMetadataByName (const string &_name) |
Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More... | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL) |
Returns a new instance of this node type with the same state as this one. More... | |
virtual | ~Node () |
Destructor. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More... | |
void | setProtoInstanceParent (X3DPrototypeInstance *p) |
Set the X3DPrototypeInstance this node is the the root node if applicaple. | |
virtual bool | lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result) |
Detect intersection between a line segment and the Node. More... | |
virtual void | closestPoint (const Vec3f &p, NodeIntersectResult &result) |
Find closest point on Node to p. More... | |
virtual bool | movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result) |
Detect collision between a moving sphere and the Node. More... | |
virtual Field * | getField (const string &_name) const |
return a pointer to the field specified by name within this instance | |
int | addDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
int | removeDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
![]() | |
H3DDisplayListObject (Inst< DisplayList > _displayList=0) | |
Constructor. | |
![]() | |
X3DProgrammableShaderObject (H3DNodeDatabase *_database) | |
Constructor. | |
virtual void | clearFields () |
Remove all dynamic fields that have been previously added. | |
virtual | ~X3DProgrammableShaderObject () |
Destructor. | |
![]() | |
field_iterator | firstField () |
Get an iterator to the first of the dynamic fields. | |
field_iterator | endField () |
Get an iterator pointing to the end of the dynamic fields. | |
H3DDynamicFieldsObject () | |
Constructor. | |
Public Attributes | |
H3DUniquePtr< SFShaderConstants > | shaderConstants |
The shaderConstants field can contain a ShaderConstants node defining constants that can be used by all ShaderPart instances in the ComposedShader node. More... | |
H3DUniquePtr< MFShaderPart > | parts |
The shader parts to use in the ComposedShader. More... | |
H3DUniquePtr< SFBool > | suppressUniformWarnings |
Suppress the warnings printed to the console about setting uniform fields that do not exist in the shader. More... | |
H3DUniquePtr< SFString > | geometryInputType |
The input geometry type of the geometry being rendered with a geometry shader. More... | |
H3DUniquePtr< SFString > | geometryOutputType |
The output geometry type of the geometry being rendered with a geometry shader. More... | |
H3DUniquePtr< SFInt32 > | geometryVerticesOut |
The number of vertices the geometry shader generates. More... | |
H3DUniquePtr< SFString > | transparencyDetectMode |
Determines how the render system will determine if the shader used generates any fragment that has an alpha channel that is < 1, i.e. More... | |
H3DUniquePtr< MFString > | transformFeedbackVaryings |
List of varying names to capture during transform feedback. More... | |
H3DUniquePtr< SFBool > | printShaderWarnings |
Always print shader warnings to console. More... | |
![]() | |
H3DUniquePtr< SFBool > | isSelected |
The isSelected output field is used to indicate that this shader instance is the one selected for use by the browser. More... | |
H3DUniquePtr< SFBool > | isValid |
The isValid field is used to indicate whether the current shader objects can be run as a shader program. More... | |
H3DUniquePtr< SFBool > | activate |
The activate field forces the shader to activate the contained objects. More... | |
H3DUniquePtr< EventCollectingField< Field > > | activateMonitor |
field used to monitor if activate field is modified | |
H3DUniquePtr< SFString > | language |
The language field is used to indicate to the browser which shading language is used for the source file(s). More... | |
![]() | |
H3DUniquePtr< SFNode > | metadata |
Meta data about the node. More... | |
![]() | |
H3DUniquePtr< DisplayList > | displayList |
The DisplayList instance handling the OpenGL caching of this object. | |
Static Public Attributes | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static bool | use_bindless_textures = false |
True if we should use bindless textures. | |
Protected Member Functions | |
void | setGeometryShaderParameters (GLenum _program_handle) |
Sets geometry shader paramters based on fields. | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
Protected Attributes | |
GLhandleARB | program_handle |
The handle to the program object used for the shader in OpenGL. | |
vector< GLhandleARB > | current_shaders |
A vector of the handles to all shader objects that are currently linked into the program object. | |
H3DUniquePtr< SetupDynamicRoutes > | setupDynamicRoutes |
C++ fields only. Contains instance of SetupDynamicRoutes. | |
list< H3DSingleTextureNode * > | shader_textures |
list of textures to be used by the composedshader | |
H3DUniquePtr< UpdateUniforms > | updateUniforms |
A field used to update any uniforms from their corresponding fields. | |
Static Protected Attributes | |
static bool | tessellation_support_checked = false |
True if a warning has already been output about missing tessellation shader support. | |
![]() | |
static bool | use_bindless_textures_set = false |
True if use_bindless_textures has already be set once. | |
Additional Inherited Members | |
![]() | |
static X3DShaderNode * | getActiveShader () |
Gets the currently active shader, i.e. More... | |
![]() | |
static unsigned int | nrNodesAlive () |
Returns the nr of nodes currently alive, i.e. nodes created but not destructed. | |
static int | nrNodesCreated () |
Returns the number of nodes created in total since the start of the program. | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
The ComposedShader node defines a shader where the individual source files are not individually programmable.
All access to the shading capabilities is defined through a single interface that applies to all parts.
In H3D API this is the shader node to use if you want to use the GLSL shading language. If you want to use CG, use either the ProgramShader or PackagedShader nodes.
The isValid field adds an additional semantic indicating whether the current shader parts can be linked together to form a complete valid shader program.
The activate field forces the shader to activate the contained objects.
Examples:
|
virtual |
Returns a bitmask of the OpenGL attrib bits that will be affected by this node.
The value can be used in glPushAttrib in order to save the current state.
Reimplemented from H3D::X3DAppearanceChildNode.
References H3D::X3DAppearanceChildNode::getAffectedGLAttribs().
|
virtual |
Returns a hint if the X3DShaderNode produces an alpha channel that is < 1, i.e.
it is semi-transparent, or not. This is used to determine render order of transparent vs opaque objects.
Reimplemented from H3D::X3DShaderNode.
References H3D::X3DMaterialNode::isTransparent(), and transparencyDetectMode.
|
virtual |
Traverse the node.
Determines if GL_PATCHES should be rendered by geometry, if a tessellation shader is present
Reimplemented from H3D::Node.
Reimplemented in H3D::ShaderCombiner, H3D::PhongShader, H3D::MultiRenderTargetShader, H3D::ConvolutionFilterShader, and H3D::ComposedGeneratedShader.
References H3D::H3DDynamicFieldsObject::endField(), H3D::H3DDynamicFieldsObject::firstField(), and H3D::Node::traverseSG().
Referenced by H3D::ConvolutionFilterShader::traverseSG(), and H3D::PhongShader::traverseSG().
H3DUniquePtr< SFString > H3D::ComposedShader::geometryInputType |
The input geometry type of the geometry being rendered with a geometry shader.
Only used when type a ShaderPart is of type "GEOMETRY".
Access type: inputOutput
Default value: "TRIANGLES"
Valid values: "POINTS", "LINES", "TRIANGLES", "LINES_ADJACENCY", "TRIANGLES_ADJACENCY",
Referenced by ComposedShader(), and setGeometryShaderParameters().
H3DUniquePtr< SFString > H3D::ComposedShader::geometryOutputType |
The output geometry type of the geometry being rendered with a geometry shader.
Only used when type a ShaderPart is of type "GEOMETRY".
Access type: inputOutput
Default value: "TRIANGLE_STRIP"
Valid values: "POINTS", "LINE_STRIP", "TRIANGLE_STRIP"
Referenced by ComposedShader(), and setGeometryShaderParameters().
H3DUniquePtr< SFInt32 > H3D::ComposedShader::geometryVerticesOut |
The number of vertices the geometry shader generates.
Only used when type a ShaderPart is of type "GEOMETRY".
Access type: inputOutput
Default value: 64
Referenced by ComposedShader(), and setGeometryShaderParameters().
H3DUniquePtr< MFShaderPart > H3D::ComposedShader::parts |
The shader parts to use in the ComposedShader.
Access type: outputOnly
Referenced by ComposedShader(), H3D::H3DGeneratedShaderNode::H3DGeneratedShaderNode(), and render().
H3DUniquePtr< SFBool > H3D::ComposedShader::printShaderWarnings |
Always print shader warnings to console.
If true, this overrides the equivalent setting in any global DebugOptions node setting
Access type: inputOutput
Default value: false
Referenced by ComposedShader().
H3DUniquePtr< SFShaderConstants > H3D::ComposedShader::shaderConstants |
The shaderConstants field can contain a ShaderConstants node defining constants that can be used by all ShaderPart instances in the ComposedShader node.
Constants can be used instead of uniform variables in a shader and will be more efficient but with the drawback that whenever the value of any of them change, it triggers a recompile of the shader part that the constant value is located in.
Referenced by ComposedShader(), and H3D::ShaderPart::setParentComposedShader().
H3DUniquePtr< SFBool > H3D::ComposedShader::suppressUniformWarnings |
Suppress the warnings printed to the console about setting uniform fields that do not exist in the shader.
These warnings are printed when you have added a field to your shader which is not defined in the glsl shader code, if the uniform variable is defined in the shader code but not used anywhere, or when the variable is used in the code but optimized away by the glsl compiler. Usually we would only like to print a warning in the first case and not in the others, but there is no way to distinguish between them. We therefore leave it to the setting of this field if they should be printed or not.
Access type: inputOutput
Default value: false
Referenced by ComposedShader(), and H3D::H3DGeneratedShaderNode::H3DGeneratedShaderNode().
H3DUniquePtr< MFString > H3D::ComposedShader::transformFeedbackVaryings |
List of varying names to capture during transform feedback.
Allows the use of the OpenGL feature 'transform feedback'. Which makes it possible to render to a buffer on the gpu using a vertex ( and optionally geometry ) shader(s) for later user. The listed names must match an output variable of the shader. See http://www.opengl.org/sdk/docs/man3/xhtml/glTransformFeedbackVaryings.xml for more info.
Access type: inputOutput
Default value: []
Referenced by ComposedShader().
H3DUniquePtr< SFString > H3D::ComposedShader::transparencyDetectMode |
Determines how the render system will determine if the shader used generates any fragment that has an alpha channel that is < 1, i.e.
it is semi-transparent, or not. This is used to determine render order of transparent vs opaque objects.
Valid values are:
"AS_MATERIAL" | If the Material node in the same Appearance node produces a transparent object we consider the ComposedShader to be transparent. |
"TRANSPARENT" | The shader is considered transparent. |
"OPAQUE" | The shader is considered opaque. |
Access type: inputOutput
Valid values: "AS_MATERIAL", "TRANSPARENT", "OPAQUE"
Default value: "AS_MATERIAL"
Referenced by ComposedShader(), and isTransparent().