Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

shaders(3) [debian man page]

Shader Classes(3)						       Coin							 Shader Classes(3)

NAME
Shader Classes - Classes class SoVertexAttribute A generic node for providing GL vertex attributes of various types. class SoVertexAttributeBinding The SoVertexAttributeBinding class is a node for setting up how vertex attributes are mapped to shapes. class SoShaderObject class SoShaderProgram The SoShaderProgram class is used to specify a set of vertex/geometry/fragment objects. Detailed Description Coin-2.5 added support for Shaders. Shaders replace the fixed function vertex and fragment processing in OpenGL by letting the user define the processing that takes place at key points in the OpenGL pipeline. Vertex shaders handle the operations that occur on each vertex, while fragment shaders handle the operations that occur on each pixel. The SoShaderProgram node in Coin provides a convenient way of specifying the code for vertex and fragment shaders. Coin-3.0 expanded upon the shader support by adding support for OpenGL Vertex Attributes. When using shaders, programmers are no longer limited to the set of attributes that OpenGL defines (glColor, glNormal, glTexCoord etc.) You can now define your own per-vertex data and pass them to the shaders using the SoVertexAttribute node. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 Shader Classes(3)

Check Out this Related Man Page

SoShaderProgram(3)						       Coin							SoShaderProgram(3)

NAME
SoShaderProgram - The SoShaderProgram class is used to specify a set of vertex/geometry/fragment objects. SYNOPSIS
#include <Inventor/nodes/SoShaderProgram.h> Inherits SoNode. Public Member Functions virtual SoType getTypeId (void) const SoShaderProgram (void) void setEnableCallback (SoShaderProgramEnableCB *cb, void *closure) virtual void GLRender (SoGLRenderAction *action) virtual void search (SoSearchAction *action) Static Public Member Functions static SoType getClassTypeId (void) static void initClass () Public Attributes SoMFNode shaderObject Protected Member Functions virtual const SoFieldData * getFieldData (void) const virtual ~SoShaderProgram () Static Protected Member Functions static const SoFieldData ** getFieldDataPtr (void) Additional Inherited Members Detailed Description The SoShaderProgram class is used to specify a set of vertex/geometry/fragment objects. This node can store one of each of SoVertexShader, SoGeometryShader and SoFragmentShader in its shaderObject field. Coin will load all shader objects specified there, and attach all objects into a program before binding it as the current shader program. A typical scene graph with shaders will look something like this: Separator { ShaderProgram { shaderObject [ VertexShader { sourceProgram 'myvertexshader.glsl' parameter [ ShaderParameter1f { name 'myvertexparam' value 1.0 } ] } FragmentShader { sourceProgram 'myfragmentshader.glsl' parameter [ ShaderParameter1f { name 'myfragmentparam' value 2.0 } ] } ] } Cube { } } This will render the Cube with the vertex and fragment shaders specified in myvertexshader.glsl and myfragmentshader.glsl. Coin also supports ARB shaders and Cg shaders (if the Cg library is installed). However, we recommend using GLSL since we will focus mostly on support this shader language. Coin defines some named parameters that can be added by the application programmer, and which will be automatically updated by Coin while traversing the scene graph. o coin_texunit[n]_model - Set to 0 when texturing is disabled, and to SoTextureImageElement::Model if there's a current texture on the state for unit n. o coin_light_model - Set to 1 for PHONG, 0 for BASE_COLOR lighting. Example scene graph that renders per-fragment OpenGL Phong lighting for one light source. The shaders assume the first light source is a directional light. This is the case if you open the file in a standard examiner viewer. The iv-file: Separator { ShaderProgram { shaderObject [ VertexShader { sourceProgram 'perpixel_vertex.glsl' } FragmentShader { sourceProgram 'perpixel_fragment.glsl' } ] } Complexity { value 1.0 } Material { diffuseColor 1 0 0 specularColor 1 1 1 shininess 0.9 } Sphere { } Translation { translation 3 0 0 } Material { diffuseColor 0 1 0 specularColor 1 1 1 shininess 0.9 } Cone { } Translation { translation 3 0 0 } Material { diffuseColor 0.8 0.4 0.1 specularColor 1 1 1 shininess 0.9 } Cylinder { } } The vertex shader (perpixel_vertex.glsl): varying vec3 ecPosition3; varying vec3 fragmentNormal; void main(void) { vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; ecPosition3 = ecPosition.xyz / ecPosition.w; fragmentNormal = normalize(gl_NormalMatrix * gl_Normal); gl_Position = ftransform(); gl_FrontColor = gl_Color; } The fragment shader (perpixel_vertex.glsl): varying vec3 ecPosition3; varying vec3 fragmentNormal; void DirectionalLight(in int i, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular) { float nDotVP; // normal . light direction float nDotHV; // normal . light half vector float pf; // power factor nDotVP = max(0.0, dot(normal, normalize(vec3(gl_LightSource[i].position)))); nDotHV = max(0.0, dot(normal, vec3(gl_LightSource[i].halfVector))); if (nDotVP == 0.0) pf = 0.0; else pf = pow(nDotHV, gl_FrontMaterial.shininess); ambient += gl_LightSource[i].ambient; diffuse += gl_LightSource[i].diffuse * nDotVP; specular += gl_LightSource[i].specular * pf; } void main(void) { vec3 eye = -normalize(ecPosition3); vec4 ambient = vec4(0.0); vec4 diffuse = vec4(0.0); vec4 specular = vec4(0.0); vec3 color; DirectionalLight(0, normalize(fragmentNormal), ambient, diffuse, specular); color = gl_FrontLightModelProduct.sceneColor.rgb + ambient.rgb * gl_FrontMaterial.ambient.rgb + diffuse.rgb * gl_Color.rgb + specular.rgb * gl_FrontMaterial.specular.rgb; gl_FragColor = vec4(color, gl_Color.a); } FILE FORMAT/DEFAULTS: ShaderProgram { shaderObject [] } See also: SoShaderObject SoShaderProgram Since: Coin 2.5 Constructor &; Destructor Documentation SoShaderProgram::SoShaderProgram (void) Constructor. SoShaderProgram::~SoShaderProgram () [protected], [virtual] Destructor. Member Function Documentation SoType SoShaderProgram::getClassTypeId (void) [static] This static method returns the SoType object associated with objects of this class. Reimplemented from SoNode. SoType SoShaderProgram::getTypeId (void) const [virtual] Returns the type identification of an object derived from a class inheriting SoBase. This is used for run-time type checking and 'downward' casting. Usage example: void foo(SoNode * node) { if (node->getTypeId() == SoFile::getClassTypeId()) { SoFile * filenode = (SoFile *)node; // safe downward cast, knows the type } } For application programmers wanting to extend the library with new nodes, engines, nodekits, draggers or others: this method needs to be overridden in all subclasses. This is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using the pre-defined macros available through for instance Inventor/nodes/SoSubNode.h (SO_NODE_INIT_CLASS and SO_NODE_CONSTRUCTOR for node classes), Inventor/engines/SoSubEngine.h (for engine classes) and so on. For more information on writing Coin extensions, see the class documentation of the toplevel superclasses for the various class groups. Implements SoBase. const SoFieldData ** SoShaderProgram::getFieldDataPtr (void) [static], [protected] This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Reimplemented from SoNode. const SoFieldData * SoShaderProgram::getFieldData (void) const [protected], [virtual] Returns a pointer to the class-wide field data storage object for this instance. If no fields are present, returns NULL. Reimplemented from SoFieldContainer. void SoShaderProgram::setEnableCallback (SoShaderProgramEnableCB *cb, void *closure) Adds a callback which is called every time this program is enabled/disabled. void SoShaderProgram::GLRender (SoGLRenderAction *action) [virtual] Action method for the SoGLRenderAction. This is called during rendering traversals. Nodes influencing the rendering state in any way or who wants to throw geometry primitives at OpenGL overrides this method. Reimplemented from SoNode. void SoShaderProgram::search (SoSearchAction *action) [virtual] Action method for SoSearchAction. Compares the search criteria from the action to see if this node is a match. Searching is done by matching up all criteria set up in the SoSearchAction -- if any of the requested criteria is a miss, the search is not deemed successful for the node. See also: SoSearchAction Reimplemented from SoNode. void SoShaderProgram::initClass (void) [static] Sets up initialization for data common to all instances of this class, like submitting necessary information to the Coin type system. Reimplemented from SoNode. Member Data Documentation SoMFNode SoShaderProgram::shaderObject The shader objects. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SoShaderProgram(3)
Man Page