1 <?xml version="1.0" encoding="utf-8">
3 An effect consists of parameters and techniques. The "parameters"
4 section of an effect is a tree of values that describe, abstractly,
5 the graphical appearence of objects that use the effect. Techniques
6 refer to these parameters and use them to set OpenGL state or to
7 set parameters for shader programs. Parameters can be declared to
8 have a dynamic variance, which means that if their value is changed
9 the corresponding value in the technique will be changed too.
11 A technique can contain a predicate that describes the OpenGL
12 functionality required to support the technique. The first
13 technique with a valid predicate in the list of techniques is used
14 to set up the graphics state of the effect. A technique with no
15 predicate is always assumed to be valid.
17 A technique can consist of several passes, which are run in
20 One feature not fully illustrated in the sample below is that
21 effects can inherit from each other. The parent effect is listed in
22 the "inherits-from" form. The child effect's property tree is
23 overlaid over that of the parent. This means that effects that
24 inherit from the example "default effect" below could be very
25 short, listing just new parameters and adding nothing to the
26 techniques section; alternatively, a technique could be altered or
27 customized in a child, listing (for example) a different shader
28 program. Terrain materials work in this way: for each material type
29 in materials.xml an effect is created that inherits from a single
30 default terrain effect. The parameters section of the effect is
31 filled in using the ambient, diffuse, etc. fields of the material.
33 Material animations will be implemented by creating a new effect
34 that inherits from one in a model, overriding the parameters that
37 Ultimately all OpenGL state will be setable in a technique. These
38 attributes and modes are currently implemented:
39 lighting - true, false
40 shade-model - flat, smooth
41 cull-face - front, back, front-back
42 rendering-hint - (OSG) opaque, transparent
43 render-bin - children: bin-number, bin-name
44 material - children: ambient, ambient-front, ambient-back, diffuse,
45 diffuse-front, diffuse-back, specular, specular-front,
46 specular-back, emissive, emissive-front, emissive-back, shininess,
47 shininess-front, shininess-back, color-mode
49 alpha-test - true, false
67 type - float, float-vec3, float-vec4, sampler-1d, sampler-2d,
70 front - fill, line, point
71 back - fill, line, point
76 <!-- <inherits-from>another-effect</inherits-from> -->
79 <ambient type="vec4d">
82 <diffuse type="vec4d">
85 <specular type="vec4d">
88 <emissive type="vec4d" variance="dynamic">
91 <shininess>1.2</shininess>
95 <image>city.png</image>
96 <filter>linear-mipmap-linear</filter>
98 <wrap-s>clamp</wrap-s>
99 <wrap-t>clamp-to-edge</wrap-t>
101 <wrap-r>clamp-to-border</wrap-r>
103 <!-- float, signed-integer, integer -->
104 <internal-format>normalized</internal-format>
109 <image>detail.png</image>
110 <filter>linear-mipmap-linear</filter>
112 <wrap-s>clamp</wrap-s>
113 <wrap-t>clamp-to-edge</wrap-t>
115 <wrap-r>clamp-to-border</wrap-r>
117 <!-- float, signed-integer, integer -->
118 <internal-format>normalized</internal-format>
121 <bump-height type="double">.05</bump-height>
122 <pattern-rotation type="vec4d">0 0 1 1.5708</pattern-rotation>
126 <!-- This is the general way to test for shader support -->
129 <value type="float">2.0</value>
133 <extension-supported>GL_ARB_shader_objects</extension-supported>
134 <extension-supported>GL_ARB_shading_language_100</extension-supported>
135 <extension-supported>GL_ARB_vertex_shader</extension-supported>
136 <extension-supported>GL_ARB_fragment_shader</extension-supported>
141 <lighting>true</lighting>
143 <ambient><use>material/ambient</use></ambient>
144 <diffuse><use>material/diffuse</use></diffuse>
145 <specular><use>material/specular</use></specular>
146 <shininess><use>material/shininess</use></shininess>
149 <texture2d><use>texture[0]/texture2d</use></texture2d>
152 <texture2d><use>texture[1]/texture2d</use></texture2d>
155 <name>bumpHeight</name>
157 <use>bump-height</use>
160 <name>patternRotation</name>
161 <type>float-vec4</type>
162 <use>pattern-rotation</use>
165 <name>baseTexture</name>
166 <type>sampler-2d</type>
170 <name>detailTexture</name>
171 <type>sampler-2d</type>
175 <!-- These two vertex shaders are linked together -->
188 <!-- This technique is always valid -->
191 <lighting>true</lighting>
193 <ambient><use>material/ambient</use></ambient>
194 <diffuse><use>material/diffuse</use></diffuse>
195 <specular><use>material/specular</use></specular>
198 <texture2d><use>texture[0]/texture2d</use></texture2d>