GLSL Example Effect (COLLADA 1.4.1): Difference between revisions

From COLLADA Public Wiki
Jump to navigation Jump to search
Gordon (talk | contribs)
A complete example of a GLSL effect
 
m Fixed formatting.
 
(31 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==An example of a Profile GLSL effect==


<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
This document describes a simple example of the COLLADA profile_GLSL. The full listing can be found in the APPENDIX of this document. It is a complete example in that it includes geometry, textures, a scene, and a profile_GLSL effect. When rendered, the example should look like the following image.
<asset>
<contributor>
<author></author>
<authoring_tool>RenderMonkey</authoring_tool>
<comments>Output from RenderMonkey COLLADA Exporter</comments>
<copyright></copyright>
<source_data></source_data>
</contributor>
<created>2007-12-11T14:24:00Z</created>
<modified>2007-12-11T14:24:00Z</modified>
<unit meter="0.01" name="centimeter"></unit>
<up_axis>Y_UP</up_axis>
</asset>
<library_visual_scenes>
<visual_scene id="VisualSceneNode" name="untitled">
<node id="Model_E0_MESH_0_REF_1" name="Model_E0_MESH_0_REF_1">
<instance_geometry url="#Model_E0_MESH_0_REF_1_lib">
<bind_material>
<technique_common>
<instance_material symbol="Textured_Bump_E0_MP_MAT" target="#Textured_Bump_E0_MP_MAT">
<bind_vertex_input semantic="rm_Binormal" input_semantic="BINORMAL" input_set="2"></bind_vertex_input>
<bind_vertex_input semantic="rm_Tangent" input_semantic="TANGENT" input_set="1"></bind_vertex_input>
</instance_material>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<library_materials>
<material id="Textured_Bump_E0_MP_MAT" name="Textured_Bump_E0_MP_MAT">
<instance_effect url="#Textured_Bump_E0_MP_FX">
<technique_hint platform="PC-OGL" profile="GLSL" ref="Textured_Bump_E0_MP_TECH"></technique_hint>
<setparam ref="fSpecularPower_E0_P0">
<float>25</float>
</setparam>
<setparam ref="fvAmbient_E0_P0">
<float4>0.368627 0.368421 0.368421 1</float4>
</setparam>
<setparam ref="fvDiffuse_E0_P0">
<float4>0.886275 0.885003 0.885003 1</float4>
</setparam>
<setparam ref="fvEyePosition_E0_P0">
<float3>0 0 100</float3>
</setparam>
<setparam ref="fvLightPosition_E0_P0">
<float3>-100 100 100</float3>
</setparam>
<setparam ref="fvSpecular_E0_P0">
<float4>0.490196 0.488722 0.488722 1</float4>
</setparam>
<setparam ref="baseMap_Sampler">
<sampler2D>
<source>baseMap_Surface</source>
<minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
<magfilter>LINEAR</magfilter>
</sampler2D>
</setparam>
<setparam ref="baseMap_Surface">
<surface type="2D">
<init_from>base_E0</init_from>
<format>A8R8G8B8</format>
</surface>
</setparam>
<setparam ref="bumpMap_Sampler">
<sampler2D>
<source>bumpMap_Surface</source>
<minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
<magfilter>LINEAR</magfilter>
</sampler2D>
</setparam>
<setparam ref="bumpMap_Surface">
<surface type="2D">
<init_from>bump_E0</init_from>
<format>A8R8G8B8</format>
</surface>
</setparam>
</instance_effect>
</material>
</library_materials>
<library_effects>
<effect id="Textured_Bump_E0_MP_FX">
<profile_GLSL>
<code sid="Vertex_Program_E0_P0_VP">uniform vec3 fvLightPosition;
uniform vec3 fvEyePosition;


varying vec2 Texcoord;
[[Image:Example.jpg]]
varying vec3 ViewDirection;
varying vec3 LightDirection;
attribute vec3 rm_Binormal;
attribute vec3 rm_Tangent;
void main( void )
{
gl_Position = ftransform();
Texcoord = gl_MultiTexCoord0.xy;
vec4 fvObjectPosition = gl_ModelViewMatrix * gl_Vertex;
vec3 fvViewDirection = fvEyePosition - fvObjectPosition.xyz;
vec3 fvLightDirection = fvLightPosition - fvObjectPosition.xyz;
vec3 fvNormal = gl_NormalMatrix * gl_Normal;
vec3 fvBinormal = gl_NormalMatrix * rm_Binormal;
vec3 fvTangent = gl_NormalMatrix * rm_Tangent;
ViewDirection.x = dot( fvTangent, fvViewDirection );
ViewDirection.y = dot( fvBinormal, fvViewDirection );
ViewDirection.z = dot( fvNormal, fvViewDirection );
LightDirection.x = dot( fvTangent, fvLightDirection.xyz );
LightDirection.y = dot( fvBinormal, fvLightDirection.xyz );
LightDirection.z = dot( fvNormal, fvLightDirection.xyz );
}</code>
<code sid="Fragment_Program_E0_P0_FP">uniform vec4 fvAmbient;
uniform vec4 fvSpecular;
uniform vec4 fvDiffuse;
uniform float fSpecularPower;


uniform sampler2D baseMap;
'''Figure 1: The example when rendered using the COLLADA OpenGL Effects Viewer.'''
uniform sampler2D bumpMap;


varying vec2 Texcoord;
[http://ati.amd.com/developer/rendermonkey/downloads.html''' OpenGL Effect Viewer]
varying vec3 ViewDirection;
varying vec3 LightDirection;


void main( void )
The following example uses the common COLLADA libraries, such as library_effects, library_materials, library_geometry, and library_images. Information on these libraries can be found elsewhere, this document focuses on the profile_GLSL only.
{
 
vec3 fvLightDirection = normalize( LightDirection );
==Structure of the GLSL Profile==
vec3 fvNormal = normalize( ( texture2D( bumpMap, Texcoord ).xyz * 2.0 ) - 1.0 );
 
  float fNDotL = dot( fvNormal, fvLightDirection );
The start of the profile_GLSL is indicated within the <effect> element using the <profile_GLSL> element.
 
vec3 fvReflection = normalize( ( ( 2.0 * fvNormal ) * fNDotL ) - fvLightDirection );
  <library_effects>
vec3 fvViewDirection = normalize( ViewDirection );
    <effect id="Textured_Bump_E0_MP_FX">
float fRDotV = max( 0.0, dot( fvReflection, fvViewDirection ) );
      '''<profile_GLSL>'''
   
 
vec4 fvBaseColor = texture2D( baseMap, Texcoord );
The GLSL profile consists of the following main blocks:
 
vec4 fvTotalAmbient = fvAmbient * fvBaseColor;  
* Code for the vertex and fragment shaders is contained within the <code> element
vec4 fvTotalDiffuse = fvDiffuse * fNDotL * fvBaseColor;  
* Values for the shader parameters are defined using <newparams>
vec4 fvTotalSpecular = fvSpecular * ( pow( fRDotV, fSpecularPower ) );
* A Technique that defines an effect specific to a target platform (defined in <technique>)
* A List of passes (one or more) defined in the <pass> element
gl_FragColor = ( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular );
* Shader descriptions (<shader>)
 
}</code>
===The <code> element===
<newparam sid="fSpecularPower_E0_P0">
 
<float>25</float>
The following is a typical GLSL <code> element containing GLSL shader code (marked in green). There are usually two <code> elements, one for the vertex shader and one for the fragment shader. The GLSL shading language is not described here.
</newparam>
 
<newparam sid="fvAmbient_E0_P0">
  '''<code''' sid="Vertex_Program_E0_P0_VP">
<float4>0.368627 0.368421 0.368421 1</float4>
  uniform vec4 fvSpecular;
</newparam>
  uniform vec4 fvDiffuse;
<newparam sid="fvDiffuse_E0_P0">
  uniform float fSpecularPower;
<float4>0.886275 0.885003 0.885003 1</float4>
  uniform sampler2D baseMap;
</newparam>
  uniform sampler2D bumpMap;
<newparam sid="fvEyePosition_E0_P0">
  varying vec2 Texcoord;
<float3>0 0 100</float3>
  varying vec3 ViewDirection;
</newparam>
  varying vec3 LightDirection;
<newparam sid="fvLightPosition_E0_P0">
  void main( void )
<float3>-100 100 100</float3>
  <nowiki>{</nowiki>
</newparam>
  vec3 fvLightDirection = normalize( LightDirection );
<newparam sid="fvSpecular_E0_P0">
  vec3 fvNormal = normalize( ( texture2D( bumpMap, Texcoord ).xyz <nowiki>*</nowiki> 2.0 ) - 1.0 );
<float4>0.490196 0.488722 0.488722 1</float4>
  float fNDotL = dot( fvNormal, fvLightDirection );
</newparam>
  vec3 fvReflection = normalize( ( ( 2.0 <nowiki>*</nowiki> fvNormal ) <nowiki>*</nowiki> fNDotL ) - fvLightDirection );
<newparam sid="baseMap_Sampler">
  vec3 fvViewDirection = normalize( ViewDirection );
<sampler2D>
  float fRDotV = max( 0.0, dot( fvReflection, fvViewDirection ) );
<source>baseMap_Surface</source>
  vec4 fvBaseColor = texture2D( baseMap, Texcoord );
<minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
  vec4 fvTotalAmbient = fvAmbient <nowiki>*</nowiki> fvBaseColor;
<magfilter>LINEAR</magfilter>
  vec4 fvTotalDiffuse = fvDiffuse <nowiki>*</nowiki> fNDotL <nowiki>*</nowiki> fvBaseColor;
</sampler2D>
  vec4 fvTotalSpecular = fvSpecular <nowiki>*</nowiki> ( pow( fRDotV, fSpecularPower ) );
</newparam>
  gl_FragColor = ( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular );
<newparam sid="baseMap_Surface">
  }
<surface type="2D">
'''<nowiki></code></nowiki>'''
<init_from>base_E0</init_from>
 
<format>A8R8G8B8</format>
===The <newparam> element===
</surface>
 
</newparam>
Newparams are used to define data that needs to be bound to the uniforms in the shader code. In the following examples we can see that newparams for specular power, sampler data and surface data are set. Please note that these values can be overridden at the <material> level by using <setparam><nowiki></nowiki>s.
<newparam sid="bumpMap_Sampler">
 
<sampler2D>
        '''<newparam''' sid="fSpecularPower_E0_P0">
<source>bumpMap_Surface</source>
          <float>25</float>
<minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
        </newparam>
<magfilter>LINEAR</magfilter>
 
</sampler2D>
        '''<newparam '''sid="baseMap_Sampler">
</newparam>
          <sampler2D>
<newparam sid="bumpMap_Surface">
            <nowiki><source>baseMap_Surface</source></nowiki>
<surface type="2D">
            <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
<init_from>bump_E0</init_from>
            <magfilter>LINEAR</magfilter>
<format>A8R8G8B8</format>
          </sampler2D>
</surface>
        </newparam>
</newparam>
 
<technique sid="Textured_Bump_E0_MP_TECH">
        '''<newparam''' sid="baseMap_Surface">
<pass sid="Pass_0">
          <surface type="2D">
<shader stage="VERTEXPROGRAM">
            <init_from>base_E0</init_from>
<compiler_target>110</compiler_target>
            <format>A8R8G8B8</format>
<name source="Vertex_Program_E0_P0_VP">main</name>
          </surface>
<bind symbol="fvEyePosition">
        </newparam>
<param ref="fvEyePosition_E0_P0"></param>
 
</bind>
===The <technique> element===
<bind symbol="fvLightPosition">
 
<param ref="fvLightPosition_E0_P0"></param>
Techniques are a another layer of hierarchy inside profiles, each of which describes the same effect for a gradation of GPU hardware, API, or slight variations of the same effect e.g. different types of skin (cow, alligator, ostrich etc).
</bind>
 
</shader>
'''        <technique '''sid="Textured_Bump_E0_MP_TECH">
<shader stage="FRAGMENTPROGRAM">
 
<compiler_target>110</compiler_target>
===The <pass> and <shader> elements===
<name source="Fragment_Program_E0_P0_FP">main</name>
 
<bind symbol="fSpecularPower">
At the core of an effect description are the <pass> elements. Each pass element specifies the target compiler, references to the vertex or fragment shader programs (with code entry points), and a set of input bindings for the shader parameters.
<param ref="fSpecularPower_E0_P0"></param>
 
</bind>
In the following example we show a pass element with the two shader stages (vertex and fragment). Each shader stage binds the params''' '''to the uniforms within tha shader code.''' '''Notice that the params do not actually define any data - just the reference to a previously defined newparam''.''
<bind symbol="fvAmbient">
 
<param ref="fvAmbient_E0_P0"></param>
          '''<pass''' sid="Pass_0">
</bind>
            '''<shader''' stage="VERTEXPROGRAM">
<bind symbol="fvDiffuse">
              <compiler_target>110</compiler_target>
<param ref="fvDiffuse_E0_P0"></param>
              <name source="Vertex_Program_E0_P0_VP">main</name>
</bind>
              <bind symbol="fvEyePosition">
<bind symbol="fvSpecular">
                <param ref="fvEyePosition_E0_P0"></param>
<param ref="fvSpecular_E0_P0"></param>
              </bind>
</bind>
              <bind symbol="fvLightPosition">
<bind symbol="baseMap">
                <param ref="fvLightPosition_E0_P0"></param>
<param ref="baseMap_Sampler"></param>
              </bind>
</bind>
            '''</shader>'''
<bind symbol="bumpMap">
            '''<shader''' stage="FRAGMENTPROGRAM">
<param ref="bumpMap_Sampler"></param>
              <compiler_target>110</compiler_target>
</bind>
              <name source="Fragment_Program_E0_P0_FP">main</name>
</shader>
              <bind symbol="fSpecularPower">
</pass>
                <param ref="fSpecularPower_E0_P0"></param>
</technique>
              </bind>
</profile_GLSL>
              <bind symbol="fvAmbient">
</effect>
                <param ref="fvAmbient_E0_P0"></param>
</library_effects>
              </bind>
<library_images>
              <bind symbol="fvDiffuse">
<image id="base_E0" name="base_E0">
                <param ref="fvDiffuse_E0_P0"></param>
<init_from>./Textured_Bump/Fieldstone.tga</init_from>
              </bind>
</image>
              <bind symbol="fvSpecular">
<image id="bump_E0" name="bump_E0">
                <param ref="fvSpecular_E0_P0"></param>
<init_from>./Textured_Bump/FieldstoneBumpDOT3.tga</init_from>
              </bind>
</image>
              <bind symbol="baseMap">
</library_images>
                <param ref="baseMap_Sampler"></param>
<library_geometries>
              </bind>
<geometry id="Model_E0_MESH_0_REF_1_lib" name="Model_E0_MESH_0_REF_1">
              <bind symbol="bumpMap">
<mesh>
                <param ref="bumpMap_Sampler"></param>
<source id="Model_E0_MESH_0_REF_1_lib_positions" name="position">
              </bind>
<float_array id="Model_E0_MESH_0_REF_1_lib_positions_array" count="9">-50 -50 0 50 -50 0 0 50 0</float_array>
            '''</shader>'''
<technique_common>
          '''</pass'''>
<accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_positions_array" stride="3">
        '''</technique>'''
<param name="X" type="float"></param>
      '''</profile_GLSL>'''
<param name="Y" type="float"></param>
    </effect>
<param name="Z" type="float"></param>
 
</accessor>
== '''APPENDIX I: A complete profile_GLSL example'''==
</technique_common>
 
</source>
 
<source id="Model_E0_MESH_0_REF_1_lib_normals" name="normal">
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<float_array id="Model_E0_MESH_0_REF_1_lib_normals_array" count="9">0 0 -1 0 0 -1 0 0 -1</float_array>
  <asset>
<technique_common>
    <contributor>
<accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_normals_array" stride="3">
      <author></author>
<param name="X" type="float"></param>
      <authoring_tool>RenderMonkey</authoring_tool>
<param name="Y" type="float"></param>
      <comments>Output from RenderMonkey COLLADA Exporter</comments>
<param name="Z" type="float"></param>
      <copyright></copyright>
</accessor>
      <source_data></source_data>
</technique_common>
    </contributor>
</source>
    <created>2007-12-11T14:24:00Z</created>
<source id="Model_E0_MESH_0_REF_1_lib_texcoords" name="texcoords">
    <modified>2007-12-11T14:24:00Z</modified>
<float_array id="Model_E0_MESH_0_REF_1_lib_texcoords_array" count="6">0 0 1 0 0.5 1</float_array>
    <unit meter="0.01" name="centimeter"></unit>
<technique_common>
    <up_axis>Y_UP</up_axis>
<accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_texcoords_array" stride="2">
  </asset>
<param name="X" type="float"></param>
  <library_visual_scenes>
<param name="Y" type="float"></param>
    <visual_scene id="VisualSceneNode" name="untitled">
</accessor>
      <node id="Model_E0_MESH_0_REF_1" name="Model_E0_MESH_0_REF_1">
</technique_common>
        <instance_geometry url="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib">
</source>
          <bind_material>
<source id="Model_E0_MESH_0_REF_1_lib_tangents" name="tangent">
            <technique_common>
<float_array id="Model_E0_MESH_0_REF_1_lib_tangents_array" count="9">1 0 0 1 0 0 1 0 0</float_array>
              <instance_material symbol="Textured_Bump_E0_MP_MAT" target="<nowiki>#</nowiki>Textured_Bump_E0_MP_MAT">
<technique_common>
                <bind_vertex_input semantic="rm_Binormal" input_semantic="BINORMAL" input_set="2"></bind_vertex_input>
<accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_tangents_array" stride="3">
                <bind_vertex_input semantic="rm_Tangent" input_semantic="TANGENT" input_set="1"></bind_vertex_input>
<param name="X" type="float"></param>
              </instance_material>
<param name="Y" type="float"></param>
            </technique_common>
<param name="Z" type="float"></param>
          </bind_material>
</accessor>
        </instance_geometry>
</technique_common>
      </node>
</source>
    </visual_scene>
<source id="Model_E0_MESH_0_REF_1_lib_binormals" name="binormal">
  </library_visual_scenes>
<float_array id="Model_E0_MESH_0_REF_1_lib_binormals_array" count="9">0 1 0 0 0 0 0 1 0</float_array>
  <library_materials>
<technique_common>
    <material id="Textured_Bump_E0_MP_MAT" name="Textured_Bump_E0_MP_MAT">
<accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_binormals_array" stride="3">
      <instance_effect url="<nowiki>#</nowiki>Textured_Bump_E0_MP_FX">
<param name="X" type="float"></param>
        <technique_hint platform="PC-OGL" profile="GLSL" ref="Textured_Bump_E0_MP_TECH"></technique_hint>
<param name="Y" type="float"></param>
        <setparam ref="fSpecularPower_E0_P0">
<param name="Z" type="float"></param>
          <float>25</float>
</accessor>
        </setparam>
</technique_common>
        <setparam ref="fvAmbient_E0_P0">
</source>
          <float4>0.368627 0.368421 0.368421 1</float4>
<vertices id="Model_E0_MESH_0_REF_1_lib_vertices">
        </setparam>
<input semantic="POSITION" source="#Model_E0_MESH_0_REF_1_lib_positions"></input>
        <setparam ref="fvDiffuse_E0_P0">
<input semantic="NORMAL" source="#Model_E0_MESH_0_REF_1_lib_normals"></input>
          <float4>0.886275 0.885003 0.885003 1</float4>
<input semantic="TEXCOORD" source="#Model_E0_MESH_0_REF_1_lib_texcoords"></input>
        </setparam>
</vertices>
        <setparam ref="fvEyePosition_E0_P0">
<triangles count="1" material="Textured_Bump_E0_MP_MAT">
          <float3>0 0 100</float3>
<input offset="0" semantic="VERTEX" source="#Model_E0_MESH_0_REF_1_lib_vertices"></input>
        </setparam>
<input offset="0" semantic="TANGENT" source="#Model_E0_MESH_0_REF_1_lib_tangents"></input>
        <setparam ref="fvLightPosition_E0_P0">
<input offset="0" semantic="BINORMAL" source="#Model_E0_MESH_0_REF_1_lib_binormals"></input>
          <float3>-100 100 100</float3>
<p>0 1 2</p>
        </setparam>
</triangles>
        <setparam ref="fvSpecular_E0_P0">
</mesh>
          <float4>0.490196 0.488722 0.488722 1</float4>
</geometry>
        </setparam>
</library_geometries>
        <setparam ref="baseMap_Sampler">
<scene>
          <sampler2D>
<instance_visual_scene url="#VisualSceneNode"></instance_visual_scene>
            <nowiki><source>baseMap_Surface</source></nowiki>
</scene>
            <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
</COLLADA>
            <magfilter>LINEAR</magfilter>
          </sampler2D>
        </setparam>
        <setparam ref="baseMap_Surface">
          <surface type="2D">
            <init_from>base_E0</init_from>
            <format>A8R8G8B8</format>
          </surface>
        </setparam>
        <setparam ref="bumpMap_Sampler">
          <sampler2D>
            <nowiki><source>bumpMap_Surface</source></nowiki>
            <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
            <magfilter>LINEAR</magfilter>
          </sampler2D>
        </setparam>
        <setparam ref="bumpMap_Surface">
          <surface type="2D">
            <init_from>bump_E0</init_from>
            <format>A8R8G8B8</format>
          </surface>
        </setparam>
      </instance_effect>
    </material>
  </library_materials>
  <library_effects>
    <effect id="Textured_Bump_E0_MP_FX">
      <profile_GLSL>
        <code sid="Vertex_Program_E0_P0_VP">
          uniform vec3 fvLightPosition;
          uniform vec3 fvEyePosition;
          varying vec2 Texcoord;
          varying vec3 ViewDirection;
          varying vec3 LightDirection;
          attribute vec3 rm_Binormal;
          attribute vec3 rm_Tangent;
          void main( void )
          {
          gl_Position = ftransform();
          Texcoord = gl_MultiTexCoord0.xy;
          vec4 fvObjectPosition = gl_ModelViewMatrix <nowiki>*</nowiki> gl_Vertex;
          vec3 fvViewDirection = fvEyePosition - fvObjectPosition.xyz;
          vec3 fvLightDirection = fvLightPosition - fvObjectPosition.xyz;
          vec3 fvNormal = gl_NormalMatrix <nowiki>*</nowiki> gl_Normal;
          vec3 fvBinormal = gl_NormalMatrix <nowiki>*</nowiki> rm_Binormal;
          vec3 fvTangent = gl_NormalMatrix <nowiki>*</nowiki> rm_Tangent;
          ViewDirection.x = dot( fvTangent, fvViewDirection );
          ViewDirection.y = dot( fvBinormal, fvViewDirection );
          ViewDirection.z = dot( fvNormal, fvViewDirection );
          LightDirection.x = dot( fvTangent, fvLightDirection.xyz );
          LightDirection.y = dot( fvBinormal, fvLightDirection.xyz );
          LightDirection.z = dot( fvNormal, fvLightDirection.xyz );
          }
        <nowiki></code></nowiki>
        <nowiki><code sid="Fragment_Program_E0_P0_FP"></nowiki>
          uniform vec4 fvAmbient;
          uniform vec4 fvSpecular;
          uniform vec4 fvDiffuse;
          uniform float fSpecularPower;
          uniform sampler2D baseMap;
          uniform sampler2D bumpMap;
          varying vec2 Texcoord;
          varying vec3 ViewDirection;
          varying vec3 LightDirection;
          void main( void )
          {
            vec3 fvLightDirection = normalize( LightDirection );
            vec3 fvNormal = normalize( ( texture2D( bumpMap, Texcoord ).xyz <nowiki>*</nowiki> 2.0 ) - 1.0 );
            float fNDotL = dot( fvNormal, fvLightDirection );
            vec3 fvReflection = normalize( ( ( 2.0 <nowiki>*</nowiki> fvNormal ) <nowiki>*</nowiki> fNDotL ) - fvLightDirection );
            vec3 fvViewDirection = normalize( ViewDirection );
            float fRDotV = max( 0.0, dot( fvReflection, fvViewDirection ) );
            vec4 fvBaseColor = texture2D( baseMap, Texcoord );
            vec4 fvTotalAmbient = fvAmbient <nowiki>*</nowiki> fvBaseColor;
            vec4 fvTotalDiffuse = fvDiffuse <nowiki>*</nowiki> fNDotL <nowiki>*</nowiki> fvBaseColor;
            vec4 fvTotalSpecular = fvSpecular <nowiki>*</nowiki> ( pow( fRDotV, fSpecularPower ) );
            gl_FragColor = ( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular );
          }
        <nowiki></code></nowiki>
        <newparam sid="fSpecularPower_E0_P0">
          <float>25</float>
        </newparam>
        <newparam sid="fvAmbient_E0_P0">
          <float4>0.368627 0.368421 0.368421 1</float4>
        </newparam>
        <newparam sid="fvDiffuse_E0_P0">
          <float4>0.886275 0.885003 0.885003 1</float4>
        </newparam>
        <newparam sid="fvEyePosition_E0_P0">
          <float3>0 0 100</float3>
        </newparam>
        <newparam sid="fvLightPosition_E0_P0">
          <float3>-100 100 100</float3>
        </newparam>
        <newparam sid="fvSpecular_E0_P0">
          <float4>0.490196 0.488722 0.488722 1</float4>
        </newparam>
        <newparam sid="baseMap_Sampler">
          <sampler2D>
            <nowiki><source>baseMap_Surface</source></nowiki>
            <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
            <magfilter>LINEAR</magfilter>
          </sampler2D>
        </newparam>
        <newparam sid="baseMap_Surface">
          <surface type="2D">
            <init_from>base_E0</init_from>
            <format>A8R8G8B8</format>
          </surface>
        </newparam>
        <newparam sid="bumpMap_Sampler">
          <sampler2D>
            <nowiki><source>bumpMap_Surface</source></nowiki>
            <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
            <magfilter>LINEAR</magfilter>
          </sampler2D>
        </newparam>
        <newparam sid="bumpMap_Surface">
          <surface type="2D">
            <init_from>bump_E0</init_from>
            <format>A8R8G8B8</format>
          </surface>
        </newparam>
        <technique sid="Textured_Bump_E0_MP_TECH">
          <pass sid="Pass_0">
            <shader stage="VERTEXPROGRAM">
              <compiler_target>110</compiler_target>
              <name source="Vertex_Program_E0_P0_VP">main</name>
              <bind symbol="fvEyePosition">
                <param ref="fvEyePosition_E0_P0"></param>
              </bind>
              <bind symbol="fvLightPosition">
                <param ref="fvLightPosition_E0_P0"></param>
              </bind>
            </shader>
            <shader stage="FRAGMENTPROGRAM">
              <compiler_target>110</compiler_target>
              <name source="Fragment_Program_E0_P0_FP">main</name>
              <bind symbol="fSpecularPower">
                <param ref="fSpecularPower_E0_P0"></param>
              </bind>
              <bind symbol="fvAmbient">
                <param ref="fvAmbient_E0_P0"></param>
              </bind>
              <bind symbol="fvDiffuse">
                <param ref="fvDiffuse_E0_P0"></param>
              </bind>
              <bind symbol="fvSpecular">
                <param ref="fvSpecular_E0_P0"></param>
              </bind>
              <bind symbol="baseMap">
                <param ref="baseMap_Sampler"></param>
              </bind>
              <bind symbol="bumpMap">
                <param ref="bumpMap_Sampler"></param>
              </bind>
            </shader>
          </pass>
        </technique>
      </profile_GLSL>
    </effect>
  </library_effects>
  <library_images>
    <image id="base_E0" name="base_E0">
      <init_from>./Textured_Bump/Fieldstone.tga</init_from>
    </image>
    <image id="bump_E0" name="bump_E0">
      <init_from>./Textured_Bump/FieldstoneBumpDOT3.tga</init_from>
    </image>
  </library_images>
  <library_geometries>
    <geometry id="Model_E0_MESH_0_REF_1_lib" name="Model_E0_MESH_0_REF_1">
      <mesh>
        <nowiki><source id="Model_E0_MESH_0_REF_1_lib_positions" name="position"></nowiki>
          <float_array id="Model_E0_MESH_0_REF_1_lib_positions_array" count="9">-50 -50 0 50 -50 0 0 50 0</float_array>
          <technique_common>
            <accessor count="3" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_positions_array" stride="3">
              <param name="X" type="float"></param>
              <param name="Y" type="float"></param>
              <param name="Z" type="float"></param>
            </accessor>
          </technique_common>
        </source>
        <nowiki><source id="Model_E0_MESH_0_REF_1_lib_normals" name="normal"></nowiki>
          <float_array id="Model_E0_MESH_0_REF_1_lib_normals_array" count="9">0 0 -1 0 0 -1 0 0 -1</float_array>
          <technique_common>
            <accessor count="3" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_normals_array" stride="3">
              <param name="X" type="float"></param>
              <param name="Y" type="float"></param>
              <param name="Z" type="float"></param>
            </accessor>
          </technique_common>
        </source>
        <nowiki><source id="Model_E0_MESH_0_REF_1_lib_texcoords" name="texcoords"></nowiki>
          <float_array id="Model_E0_MESH_0_REF_1_lib_texcoords_array" count="6">0 0 1 0 0.5 1</float_array>
          <technique_common>
            <accessor count="3" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_texcoords_array" stride="2">
              <param name="X" type="float"></param>
              <param name="Y" type="float"></param>
            </accessor>
          </technique_common>
        </source>
        <nowiki><source id="Model_E0_MESH_0_REF_1_lib_tangents" name="tangent"></nowiki>
          <float_array id="Model_E0_MESH_0_REF_1_lib_tangents_array" count="9">1 0 0 1 0 0 1 0 0</float_array>
          <technique_common>
            <accessor count="3" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_tangents_array" stride="3">
              <param name="X" type="float"></param>
              <param name="Y" type="float"></param>
              <param name="Z" type="float"></param>
            </accessor>
          </technique_common>
        </source>
        <nowiki><source id="Model_E0_MESH_0_REF_1_lib_binormals" name="binormal"></nowiki>
          <float_array id="Model_E0_MESH_0_REF_1_lib_binormals_array" count="9">0 1 0 0 0 0 0 1 0</float_array>
          <technique_common>
            <accessor count="3" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_binormals_array" stride="3">
              <param name="X" type="float"></param>
              <param name="Y" type="float"></param>
              <param name="Z" type="float"></param>
            </accessor>
          </technique_common>
        </source>
        <vertices id="Model_E0_MESH_0_REF_1_lib_vertices">
          <input semantic="POSITION" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_positions"></input>
          <input semantic="NORMAL" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_normals"></input>
          <input semantic="TEXCOORD" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_texcoords"></input>
        </vertices>
        <triangles count="1" material="Textured_Bump_E0_MP_MAT">
          <input offset="0" semantic="VERTEX" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_vertices"></input>
          <input offset="0" semantic="TANGENT" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_tangents"></input>
          <input offset="0" semantic="BINORMAL" source="<nowiki>#</nowiki>Model_E0_MESH_0_REF_1_lib_binormals"></input>
          <nowiki><p>0 1 2</p></nowiki>
        </triangles>
      </mesh>
    </geometry>
  </library_geometries>
  <scene>
    <instance_visual_scene url="<nowiki>#</nowiki>VisualSceneNode"></instance_visual_scene>
  </scene>
</COLLADA>
 
[[Category:COLLADA tutorials]]

Latest revision as of 08:58, 26 May 2012

An example of a Profile GLSL effect

This document describes a simple example of the COLLADA profile_GLSL. The full listing can be found in the APPENDIX of this document. It is a complete example in that it includes geometry, textures, a scene, and a profile_GLSL effect. When rendered, the example should look like the following image.

Figure 1: The example when rendered using the COLLADA OpenGL Effects Viewer.

OpenGL Effect Viewer

The following example uses the common COLLADA libraries, such as library_effects, library_materials, library_geometry, and library_images. Information on these libraries can be found elsewhere, this document focuses on the profile_GLSL only.

Structure of the GLSL Profile

The start of the profile_GLSL is indicated within the <effect> element using the <profile_GLSL> element.

<library_effects>
   <effect id="Textured_Bump_E0_MP_FX">
     <profile_GLSL>

The GLSL profile consists of the following main blocks:

  • Code for the vertex and fragment shaders is contained within the element
  • Values for the shader parameters are defined using <newparams>
  • A Technique that defines an effect specific to a target platform (defined in <technique>)
  • A List of passes (one or more) defined in the <pass> element
  • Shader descriptions (<shader>)

The element

The following is a typical GLSL element containing GLSL shader code (marked in green). There are usually two elements, one for the vertex shader and one for the fragment shader. The GLSL shading language is not described here.

<code sid="Vertex_Program_E0_P0_VP">
  uniform vec4 fvSpecular;
  uniform vec4 fvDiffuse;
  uniform float fSpecularPower;
  uniform sampler2D baseMap;
  uniform sampler2D bumpMap;
  varying vec2 Texcoord;
  varying vec3 ViewDirection;
  varying vec3 LightDirection;
  void main( void )
  {
  vec3 fvLightDirection = normalize( LightDirection );
  vec3 fvNormal = normalize( ( texture2D( bumpMap, Texcoord ).xyz * 2.0 ) - 1.0 );
  float fNDotL = dot( fvNormal, fvLightDirection ); 
  vec3 fvReflection = normalize( ( ( 2.0 * fvNormal ) * fNDotL ) - fvLightDirection ); 
  vec3 fvViewDirection = normalize( ViewDirection );
  float fRDotV = max( 0.0, dot( fvReflection, fvViewDirection ) );
  vec4 fvBaseColor = texture2D( baseMap, Texcoord );
  vec4 fvTotalAmbient = fvAmbient * fvBaseColor; 
  vec4 fvTotalDiffuse = fvDiffuse * fNDotL * fvBaseColor; 
  vec4 fvTotalSpecular = fvSpecular * ( pow( fRDotV, fSpecularPower ) );
  gl_FragColor = ( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular );
  }
</code>

The <newparam> element

Newparams are used to define data that needs to be bound to the uniforms in the shader code. In the following examples we can see that newparams for specular power, sampler data and surface data are set. Please note that these values can be overridden at the <material> level by using <setparam>‘s.

       <newparam sid="fSpecularPower_E0_P0">
         <float>25</float>
       </newparam>
       <newparam sid="baseMap_Sampler">
         <sampler2D>
           <source>baseMap_Surface</source>
           <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
           <magfilter>LINEAR</magfilter>
         </sampler2D>
       </newparam>
       <newparam sid="baseMap_Surface">
         <surface type="2D">
           <init_from>base_E0</init_from>
           <format>A8R8G8B8</format>
         </surface>
       </newparam>

The <technique> element

Techniques are a another layer of hierarchy inside profiles, each of which describes the same effect for a gradation of GPU hardware, API, or slight variations of the same effect e.g. different types of skin (cow, alligator, ostrich etc).

<technique sid="Textured_Bump_E0_MP_TECH">

The <pass> and <shader> elements

At the core of an effect description are the <pass> elements. Each pass element specifies the target compiler, references to the vertex or fragment shader programs (with code entry points), and a set of input bindings for the shader parameters.

In the following example we show a pass element with the two shader stages (vertex and fragment). Each shader stage binds the params to the uniforms within tha shader code. Notice that the params do not actually define any data - just the reference to a previously defined newparam.

         <pass sid="Pass_0">
           <shader stage="VERTEXPROGRAM">
             <compiler_target>110</compiler_target>
             <name source="Vertex_Program_E0_P0_VP">main</name>
             <bind symbol="fvEyePosition">
               <param ref="fvEyePosition_E0_P0"></param>
             </bind>
             <bind symbol="fvLightPosition">
               <param ref="fvLightPosition_E0_P0"></param>
             </bind>
           </shader>
           <shader stage="FRAGMENTPROGRAM">
             <compiler_target>110</compiler_target>
             <name source="Fragment_Program_E0_P0_FP">main</name>
             <bind symbol="fSpecularPower">
               <param ref="fSpecularPower_E0_P0"></param>
             </bind>
             <bind symbol="fvAmbient">
               <param ref="fvAmbient_E0_P0"></param>
             </bind>
             <bind symbol="fvDiffuse">
               <param ref="fvDiffuse_E0_P0"></param>
             </bind>
             <bind symbol="fvSpecular">
               <param ref="fvSpecular_E0_P0"></param>
             </bind>
             <bind symbol="baseMap">
               <param ref="baseMap_Sampler"></param>
             </bind>
             <bind symbol="bumpMap">
               <param ref="bumpMap_Sampler"></param>
             </bind>
           </shader>
         </pass>
       </technique>
     </profile_GLSL>
   </effect>

APPENDIX I: A complete profile_GLSL example

<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
 <asset>
   <contributor>
     <author></author>
     <authoring_tool>RenderMonkey</authoring_tool>
     <comments>Output from RenderMonkey COLLADA Exporter</comments>
     <copyright></copyright>
     <source_data></source_data>
   </contributor>
   <created>2007-12-11T14:24:00Z</created>
   <modified>2007-12-11T14:24:00Z</modified>
   <unit meter="0.01" name="centimeter"></unit>
   <up_axis>Y_UP</up_axis>
 </asset>
 <library_visual_scenes>
   <visual_scene id="VisualSceneNode" name="untitled">
     <node id="Model_E0_MESH_0_REF_1" name="Model_E0_MESH_0_REF_1">
       <instance_geometry url="#Model_E0_MESH_0_REF_1_lib">
         <bind_material>
           <technique_common>
             <instance_material symbol="Textured_Bump_E0_MP_MAT" target="#Textured_Bump_E0_MP_MAT">
               <bind_vertex_input semantic="rm_Binormal" input_semantic="BINORMAL" input_set="2"></bind_vertex_input>
               <bind_vertex_input semantic="rm_Tangent" input_semantic="TANGENT" input_set="1"></bind_vertex_input>
             </instance_material>
           </technique_common>
         </bind_material>
       </instance_geometry>
     </node>
   </visual_scene>
 </library_visual_scenes>
 <library_materials>
   <material id="Textured_Bump_E0_MP_MAT" name="Textured_Bump_E0_MP_MAT">
     <instance_effect url="#Textured_Bump_E0_MP_FX">
       <technique_hint platform="PC-OGL" profile="GLSL" ref="Textured_Bump_E0_MP_TECH"></technique_hint>
       <setparam ref="fSpecularPower_E0_P0">
         <float>25</float>
       </setparam>
       <setparam ref="fvAmbient_E0_P0">
         <float4>0.368627 0.368421 0.368421 1</float4>
       </setparam>
       <setparam ref="fvDiffuse_E0_P0">
         <float4>0.886275 0.885003 0.885003 1</float4>
       </setparam>
       <setparam ref="fvEyePosition_E0_P0">
         <float3>0 0 100</float3>
       </setparam>
       <setparam ref="fvLightPosition_E0_P0">
         <float3>-100 100 100</float3>
       </setparam>
       <setparam ref="fvSpecular_E0_P0">
         <float4>0.490196 0.488722 0.488722 1</float4>
       </setparam>
       <setparam ref="baseMap_Sampler">
         <sampler2D>
           <source>baseMap_Surface</source>
           <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
           <magfilter>LINEAR</magfilter>
         </sampler2D>
       </setparam>
       <setparam ref="baseMap_Surface">
         <surface type="2D">
           <init_from>base_E0</init_from>
           <format>A8R8G8B8</format>
         </surface>
       </setparam>
       <setparam ref="bumpMap_Sampler">
         <sampler2D>
           <source>bumpMap_Surface</source>
           <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
           <magfilter>LINEAR</magfilter>
         </sampler2D>
       </setparam>
       <setparam ref="bumpMap_Surface">
         <surface type="2D">
           <init_from>bump_E0</init_from>
           <format>A8R8G8B8</format>
         </surface>
       </setparam>
     </instance_effect>
   </material>
 </library_materials>
 <library_effects>
   <effect id="Textured_Bump_E0_MP_FX">
     <profile_GLSL>
       
         uniform vec3 fvLightPosition;
         uniform vec3 fvEyePosition;
         varying vec2 Texcoord;
         varying vec3 ViewDirection;
         varying vec3 LightDirection;
         attribute vec3 rm_Binormal;
         attribute vec3 rm_Tangent;
         void main( void )
         {
          gl_Position = ftransform();
          Texcoord = gl_MultiTexCoord0.xy;
          vec4 fvObjectPosition = gl_ModelViewMatrix * gl_Vertex;
          vec3 fvViewDirection = fvEyePosition - fvObjectPosition.xyz;
          vec3 fvLightDirection = fvLightPosition - fvObjectPosition.xyz;
          vec3 fvNormal = gl_NormalMatrix * gl_Normal;
          vec3 fvBinormal = gl_NormalMatrix * rm_Binormal;
          vec3 fvTangent = gl_NormalMatrix * rm_Tangent;
          ViewDirection.x = dot( fvTangent, fvViewDirection );
          ViewDirection.y = dot( fvBinormal, fvViewDirection );
          ViewDirection.z = dot( fvNormal, fvViewDirection );
          LightDirection.x = dot( fvTangent, fvLightDirection.xyz );
          LightDirection.y = dot( fvBinormal, fvLightDirection.xyz );
          LightDirection.z = dot( fvNormal, fvLightDirection.xyz );
          }
       </code>
       <code sid="Fragment_Program_E0_P0_FP">
         uniform vec4 fvAmbient;
         uniform vec4 fvSpecular;
         uniform vec4 fvDiffuse;
         uniform float fSpecularPower;
         uniform sampler2D baseMap;
         uniform sampler2D bumpMap;
         varying vec2 Texcoord;
         varying vec3 ViewDirection;
         varying vec3 LightDirection;
         void main( void )
         {
           vec3 fvLightDirection = normalize( LightDirection );
           vec3 fvNormal = normalize( ( texture2D( bumpMap, Texcoord ).xyz * 2.0 ) - 1.0 );
           float fNDotL = dot( fvNormal, fvLightDirection ); 
           vec3 fvReflection = normalize( ( ( 2.0 * fvNormal ) * fNDotL ) - fvLightDirection ); 
           vec3 fvViewDirection = normalize( ViewDirection );
           float fRDotV = max( 0.0, dot( fvReflection, fvViewDirection ) );
           vec4 fvBaseColor = texture2D( baseMap, Texcoord );
           vec4 fvTotalAmbient = fvAmbient * fvBaseColor; 
           vec4 fvTotalDiffuse = fvDiffuse * fNDotL * fvBaseColor; 
           vec4 fvTotalSpecular = fvSpecular * ( pow( fRDotV, fSpecularPower ) );
           gl_FragColor = ( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular );
         }
       </code>
       <newparam sid="fSpecularPower_E0_P0">
         <float>25</float>
       </newparam>
       <newparam sid="fvAmbient_E0_P0">
         <float4>0.368627 0.368421 0.368421 1</float4>
       </newparam>
       <newparam sid="fvDiffuse_E0_P0">
         <float4>0.886275 0.885003 0.885003 1</float4>
       </newparam>
       <newparam sid="fvEyePosition_E0_P0">
         <float3>0 0 100</float3>
       </newparam>
       <newparam sid="fvLightPosition_E0_P0">
         <float3>-100 100 100</float3>
       </newparam>
       <newparam sid="fvSpecular_E0_P0">
         <float4>0.490196 0.488722 0.488722 1</float4>
       </newparam>
       <newparam sid="baseMap_Sampler">
         <sampler2D>
           <source>baseMap_Surface</source>
           <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
           <magfilter>LINEAR</magfilter>
         </sampler2D>
       </newparam>
       <newparam sid="baseMap_Surface">
         <surface type="2D">
           <init_from>base_E0</init_from>
           <format>A8R8G8B8</format>
         </surface>
       </newparam>
       <newparam sid="bumpMap_Sampler">
         <sampler2D>
           <source>bumpMap_Surface</source>
           <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
           <magfilter>LINEAR</magfilter>
         </sampler2D>
       </newparam>
       <newparam sid="bumpMap_Surface">
         <surface type="2D">
           <init_from>bump_E0</init_from>
           <format>A8R8G8B8</format>
         </surface>
       </newparam>
       <technique sid="Textured_Bump_E0_MP_TECH">
         <pass sid="Pass_0">
           <shader stage="VERTEXPROGRAM">
             <compiler_target>110</compiler_target>
             <name source="Vertex_Program_E0_P0_VP">main</name>
             <bind symbol="fvEyePosition">
               <param ref="fvEyePosition_E0_P0"></param>
             </bind>
             <bind symbol="fvLightPosition">
               <param ref="fvLightPosition_E0_P0"></param>
             </bind>
           </shader>
           <shader stage="FRAGMENTPROGRAM">
             <compiler_target>110</compiler_target>
             <name source="Fragment_Program_E0_P0_FP">main</name>
             <bind symbol="fSpecularPower">
               <param ref="fSpecularPower_E0_P0"></param>
             </bind>
             <bind symbol="fvAmbient">
               <param ref="fvAmbient_E0_P0"></param>
             </bind>
             <bind symbol="fvDiffuse">
               <param ref="fvDiffuse_E0_P0"></param>
             </bind>
             <bind symbol="fvSpecular">
               <param ref="fvSpecular_E0_P0"></param>
             </bind>
             <bind symbol="baseMap">
               <param ref="baseMap_Sampler"></param>
             </bind>
             <bind symbol="bumpMap">
               <param ref="bumpMap_Sampler"></param>
             </bind>
           </shader>
         </pass>
       </technique>
     </profile_GLSL>
   </effect>
 </library_effects>
 <library_images>
   <image id="base_E0" name="base_E0">
     <init_from>./Textured_Bump/Fieldstone.tga</init_from>
   </image>
   <image id="bump_E0" name="bump_E0">
     <init_from>./Textured_Bump/FieldstoneBumpDOT3.tga</init_from>
   </image>
 </library_images>
 <library_geometries>
   <geometry id="Model_E0_MESH_0_REF_1_lib" name="Model_E0_MESH_0_REF_1">
     <mesh>
       <source id="Model_E0_MESH_0_REF_1_lib_positions" name="position">
         <float_array id="Model_E0_MESH_0_REF_1_lib_positions_array" count="9">-50 -50 0 50 -50 0 0 50 0</float_array>
         <technique_common>
           <accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_positions_array" stride="3">
             <param name="X" type="float"></param>
             <param name="Y" type="float"></param>
             <param name="Z" type="float"></param>
           </accessor>
         </technique_common>
       </source>
       <source id="Model_E0_MESH_0_REF_1_lib_normals" name="normal">
         <float_array id="Model_E0_MESH_0_REF_1_lib_normals_array" count="9">0 0 -1 0 0 -1 0 0 -1</float_array>
         <technique_common>
           <accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_normals_array" stride="3">
             <param name="X" type="float"></param>
             <param name="Y" type="float"></param>
             <param name="Z" type="float"></param>
           </accessor>
         </technique_common>
       </source>
       <source id="Model_E0_MESH_0_REF_1_lib_texcoords" name="texcoords">
         <float_array id="Model_E0_MESH_0_REF_1_lib_texcoords_array" count="6">0 0 1 0 0.5 1</float_array>
         <technique_common>
           <accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_texcoords_array" stride="2">
             <param name="X" type="float"></param>
             <param name="Y" type="float"></param>
           </accessor>
         </technique_common>
       </source>
       <source id="Model_E0_MESH_0_REF_1_lib_tangents" name="tangent">
         <float_array id="Model_E0_MESH_0_REF_1_lib_tangents_array" count="9">1 0 0 1 0 0 1 0 0</float_array>
         <technique_common>
           <accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_tangents_array" stride="3">
             <param name="X" type="float"></param>
             <param name="Y" type="float"></param>
             <param name="Z" type="float"></param>
           </accessor>
         </technique_common>
       </source>
       <source id="Model_E0_MESH_0_REF_1_lib_binormals" name="binormal">
         <float_array id="Model_E0_MESH_0_REF_1_lib_binormals_array" count="9">0 1 0 0 0 0 0 1 0</float_array>
         <technique_common>
           <accessor count="3" source="#Model_E0_MESH_0_REF_1_lib_binormals_array" stride="3">
             <param name="X" type="float"></param>
             <param name="Y" type="float"></param>
             <param name="Z" type="float"></param>
           </accessor>
         </technique_common>
       </source>
       <vertices id="Model_E0_MESH_0_REF_1_lib_vertices">
         <input semantic="POSITION" source="#Model_E0_MESH_0_REF_1_lib_positions"></input>
         <input semantic="NORMAL" source="#Model_E0_MESH_0_REF_1_lib_normals"></input>
         <input semantic="TEXCOORD" source="#Model_E0_MESH_0_REF_1_lib_texcoords"></input>
       </vertices>
       <triangles count="1" material="Textured_Bump_E0_MP_MAT">
         <input offset="0" semantic="VERTEX" source="#Model_E0_MESH_0_REF_1_lib_vertices"></input>
         <input offset="0" semantic="TANGENT" source="#Model_E0_MESH_0_REF_1_lib_tangents"></input>
         <input offset="0" semantic="BINORMAL" source="#Model_E0_MESH_0_REF_1_lib_binormals"></input>
          <p>0 1 2</p>
       </triangles>
     </mesh>
   </geometry>
 </library_geometries>
 <scene>
   <instance_visual_scene url="#VisualSceneNode"></instance_visual_scene>
 </scene>
</COLLADA>