technique

Holds a description of the textures, samplers, shaders, parameters, and passes necessary for rendering this effect using one method.

Element Information

Model

Attributes

QName Type Fixed Default Use Inheritable Annotation
id xs:ID optional
The id attribute is a text string containing the unique identifier of this element. 
This value must be unique within the instance document. Optional attribute.
sid sid_type required
The sid attribute is a text string value containing the sub-identifier of this element. 
This value must be unique within the scope of the parent element. Optional attribute.

Source

<xs:element name="technique">
  <xs:annotation>
    <xs:documentation>Holds a description of the textures, samplers, shaders, parameters, and passes necessary for rendering this effect using one method.</xs:documentation>
  </xs:annotation>
  <xs:complexType>
    <xs:sequence>
      <xs:element name="asset" type="asset_type" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The technique element may contain an asset element.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:choice>
        <xs:element name="constant">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="emission" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="reflective" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="reflectivity" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="transparent" type="fx_common_transparent_type" minOccurs="0"/>
              <xs:element name="transparency" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="index_of_refraction" type="fx_common_float_or_param_type" minOccurs="0"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="lambert">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="emission" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="ambient" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="diffuse" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="reflective" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="reflectivity" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="transparent" type="fx_common_transparent_type" minOccurs="0"/>
              <xs:element name="transparency" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="index_of_refraction" type="fx_common_float_or_param_type" minOccurs="0"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="phong">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="emission" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="ambient" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="diffuse" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="specular" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="shininess" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="reflective" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="reflectivity" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="transparent" type="fx_common_transparent_type" minOccurs="0"/>
              <xs:element name="transparency" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="index_of_refraction" type="fx_common_float_or_param_type" minOccurs="0"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="blinn">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="emission" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="ambient" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="diffuse" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="specular" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="shininess" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="reflective" type="fx_common_color_or_texture_type" minOccurs="0"/>
              <xs:element name="reflectivity" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="transparent" type="fx_common_transparent_type" minOccurs="0"/>
              <xs:element name="transparency" type="fx_common_float_or_param_type" minOccurs="0"/>
              <xs:element name="index_of_refraction" type="fx_common_float_or_param_type" minOccurs="0"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
      <xs:element name="extra" type="extra_type" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>The extra element may appear any number of times.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="id" type="xs:ID">
      <xs:annotation>
        <xs:documentation>The id attribute is a text string containing the unique identifier of this element. This value must be unique within the instance document. Optional attribute.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sid" type="sid_type" use="required">
      <xs:annotation>
        <xs:documentation>The sid attribute is a text string value containing the sub-identifier of this element. This value must be unique within the scope of the parent element. Optional attribute.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
</xs:element>

Sample

< profile_GLSL xmlns = "http://www.collada.org/2008/03/COLLADASchema" >

[...]

< 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 * 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>

< instance_image url = "base" />

< minfilter>

LINEAR

</ minfilter>

< magfilter>

LINEAR

</ magfilter>

< mipfilter>

LINEAR

</ mipfilter>

</ sampler2D>

</ newparam>

< newparam sid = "bumpMap_Sampler" >

< sampler2D>

< instance_image url = "bump" />

< minfilter>

LINEAR

</ minfilter>

< magfilter>

LINEAR

</ magfilter>

< mipfilter>

LINEAR

</ mipfilter>

</ sampler2D>

</ newparam>

< technique sid = "Textured_Bump_E0_MP_TECH" >

< pass sid = "Pass_0" >

< program>

< shader stage = "VERTEX" >

< sources>

< import ref = "Vertex_Program_E0_P0_VP" />

</ sources>

</ shader>

< shader stage = "FRAGMENT" >

< sources>

< import ref = "Fragment_Program_E0_P0_FP" />

</ sources>

</ shader>

< bind_uniform symbol = "fSpecularPower" >

< param ref = "fSpecularPower_E0_P0" />

</ bind_uniform>