|
|
Line 405: |
Line 405: |
| </program> | | </program> |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
| ===Generate===
| |
|
| |
| Often shader effects need tangent vectors to work properly. These
| |
| tangent vectors, usually called tangent and binormal, are computed
| |
| on the CPU and given to the shader as vertex attributes. These
| |
| vectors are computed on demand on the geometry using the effect if
| |
| the 'generate' clause is present in the effect file. Exemple :
| |
|
| |
| <syntaxhighlight lang="xml">
| |
| <generate>
| |
| <tangent type="int">6</tangent>
| |
| <binormal type="int">7</binormal>
| |
| <normal type="int">8</normal>
| |
| </generate>
| |
| </syntaxhighlight>
| |
|
| |
| Valid subnodes of 'generate' are 'tangent', 'binormal' or 'normal'.
| |
| The integer value of these subnode is the index of the attribute
| |
| that will hold the value of the vec3 vector.
| |
|
| |
| The generate clause is located under PropertyList in the xml file.
| |
|
| |
| In order to be available for the vertex shader, these data should
| |
| be bound to an attribute in the program clause, like this :
| |
|
| |
| <syntaxhighlight lang="xml">
| |
| <program>
| |
| <vertex-shader>my_vertex_shader</vertex-shader>
| |
| <attribute>
| |
| <name>my_tangent_attribute</name>
| |
| <index>6</index>
| |
| </attribute>
| |
| <attribute>
| |
| <name>my_binormal_attribute</name>
| |
| <index>7</index>
| |
| </attribute>
| |
| </program>
| |
| </syntaxhighlight>
| |
|
| |
| attribute names are whatever the shader use. The index is the one
| |
| declared in the 'generate' clause. So because generate/tangent has
| |
| value 6 and my_tangent_attribute has index 6, my_tangent_attribute
| |
| holds the tangent value for the vertex.
| |
|
| |
|
| =Uniforms passed to shaders outside the xml effect framework= | | =Uniforms passed to shaders outside the xml effect framework= |