coin_shaders - Online Linux Manual PageSection : 3
Updated : Mon Jan 25 2021
Source : Version 4.0.0
Note : Coin

NAMEcoin_shaders − Shaders in Coin Coin 2​.5 added support for shaders​. The main nodes used are SoShaderProgram, SoVertexShader, SoFragmentShader, and SoGeometryShader​. 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​. • 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​. • coin_light_model - Set to 1 for PHONG, 0 for BASE_COLOR lighting​. • coin_two_sided_lighting - Set to 1 for two-sided, 0 for normal 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_fragment​.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); }
0
Johanes Gumabo
Data Size   :   11,023 byte
man-coin_shaders.3coin4Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 181,207
Visitor ID   :     :  
Visitor IP   :   18.226.34.148   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.