Effect framework: Difference between revisions

Jump to navigation Jump to search
+-heading levels: First level should not be used manually, it is automatically used for the page title; +related: Forum topic about which kind of groups an effect can be applied to
(+-heading levels: First level should not be used manually, it is automatically used for the page title; +related: Forum topic about which kind of groups an effect can be applied to)
Line 23: Line 23:
FlightGear.  
FlightGear.  


=Default Effects in Terrain Materials and Models=
== Default Effects in Terrain Materials and Models ==
Effects for terrain work in this way: for each material type in
Effects for terrain work in this way: for each material type in
materials.xml an effect is created that inherits from a single default
materials.xml an effect is created that inherits from a single default
Line 49: Line 49:
* texture type, image, filter, wrap-s, wrap-t
* texture type, image, filter, wrap-s, wrap-t


=Specifying Custom Effects=
== Specifying Custom Effects ==
You can specify the effects that will be used by FlightGear as the
You can specify the effects that will be used by FlightGear as the
base effect when it creates terrain and model effects.
base effect when it creates terrain and model effects.
Line 60: Line 60:
will be animated.
will be animated.


=Examples=
== Examples ==
The $FGDATA/Effects directory contains the effects definitions; look there for
The $FGDATA/Effects directory contains the effects definitions; look there for
examples. Effects/crop.eff is a good example of a complex effect.
examples. Effects/crop.eff is a good example of a complex effect.


=Application=
== Application ==
To apply an effect to a model or part of a model use:
To apply an effect to a model or part of a model use:


Line 77: Line 77:
The effect does not need the file extension.
The effect does not need the file extension.


===Parameters in model file===
=== Parameters in model file ===


Parameters can be put into the model files effect application as well. But only bool, int, float, string can be used there.
Parameters can be put into the model files effect application as well. But only bool, int, float, string can be used there.


===Chrome old usage===
=== Chrome old usage ===


Chrome, although now implemented as an effect, still retains the old method of application:
Chrome, although now implemented as an effect, still retains the old method of application:
Line 96: Line 96:
in order to maintain backward compatibility.
in order to maintain backward compatibility.


=The xml tags of an effect=
== The xml tags of an effect ==


==name==
=== name ===
The name of the effect
The name of the effect


==inherits-from==
=== inherits-from ===
One feature not fully illustrated in the sample below is that
One feature not fully illustrated in the sample below is that
effects can inherit from each other. The parent effect is listed in
effects can inherit from each other. The parent effect is listed in
Line 124: Line 124:
parameters section.
parameters section.


==Parameters==
=== Parameters ===
Custom parameters that controls the effect.
Custom parameters that controls the effect.


Note that parameters can use the <use> tags to enable properties to specify the values.
Note that parameters can use the <use> tags to enable properties to specify the values.


==Generate==
=== Generate ===


Often shader effects need tangent vectors to work properly. These  
Often shader effects need tangent vectors to work properly. These  
Line 173: Line 173:
holds the tangent value for the vertex.
holds the tangent value for the vertex.


==Technique==
=== Technique ===
A certain way of rendering this effect. Different pipelines typically have their own techniques.
A certain way of rendering this effect. Different pipelines typically have their own techniques.


===predicate===
==== predicate ====
A technique can contain a predicate that describes the OpenGL
A technique can contain a predicate that describes the OpenGL
functionality required to support the technique. The first
functionality required to support the technique. The first
Line 247: Line 247:
</syntaxhighlight>
</syntaxhighlight>


===pass===
==== pass ====
A technique can consist of several passes. A pass is basically an Open
A technique can consist of several passes. A pass is basically an Open
Scene Graph StateSet. Ultimately all OpenGL and OSG modes and state
Scene Graph StateSet. Ultimately all OpenGL and OSG modes and state
Line 322: Line 322:
changes.
changes.


====lighting====
===== lighting =====
true or false
true or false


====material====
===== material =====
children: active, ambient, ambient-front, ambient-back, diffuse,
children: active, ambient, ambient-front, ambient-back, diffuse,
diffuse-front, diffuse-back, specular, specular-front,
diffuse-front, diffuse-back, specular, specular-front,
Line 331: Line 331:
shininess-front, shininess-back, color-mode
shininess-front, shininess-back, color-mode


====blend====
===== blend =====
Children: active, source, destination, source-rgb, source-alpha, destination-rgb, destination-alpha
Children: active, source, destination, source-rgb, source-alpha, destination-rgb, destination-alpha


Line 345: Line 345:
</syntaxhighlight>
</syntaxhighlight>


====shade-model====
===== shade-model =====
flat or smooth
flat or smooth


====cull-face====
===== cull-face =====
front, back, front-back, off
front, back, front-back, off


====texture-unit====
===== texture-unit =====
Example:
Example:


Line 384: Line 384:
</syntaxhighlight>
</syntaxhighlight>


====vertex-program-two-side====
===== vertex-program-two-side =====
true or false
true or false


====polygon-mode====
===== polygon-mode =====
children: front, back
children: front, back


Valid values:  fill, line, point
Valid values:  fill, line, point


====vertex-program-point-size====
===== vertex-program-point-size =====
true, false
true, false


====uniform====
===== uniform =====
Data accessible by shaders.
Data accessible by shaders.


Line 402: Line 402:
type: bool, int, float, float-vec3, float-vec4, sampler-1d, sampler-2d, sampler-3d, sampler-1d-shadow, sampler-2d-shadow, sampler-cube
type: bool, int, float, float-vec3, float-vec4, sampler-1d, sampler-2d, sampler-3d, sampler-1d-shadow, sampler-2d-shadow, sampler-cube


====alpha-test====
===== alpha-test =====


active: true, false
active: true, false
Line 410: Line 410:
reference: 0 to 1
reference: 0 to 1


====render-bin====
===== render-bin =====
Sent to OSG.
Sent to OSG.


Line 417: Line 417:
bin-name: RenderBin, DepthSortedBin
bin-name: RenderBin, DepthSortedBin


====rendering-hint====
===== rendering-hint =====
Sent to OSG.
Sent to OSG.


Line 430: Line 430:
default = inherit renderbin details from parent node
default = inherit renderbin details from parent node


====program====
===== program =====
* vertex-shader
* vertex-shader
* geometry-shader
* geometry-shader
Line 452: Line 452:
See this page for more about shaders: [[Howto:Shader programming in FlightGear]]
See this page for more about shaders: [[Howto:Shader programming in FlightGear]]


=Uniforms passed to shaders outside the xml effect framework=
== Uniforms passed to shaders outside the xml effect framework ==


{| class="wikitable"
{| class="wikitable"
Line 551: Line 551:
|Defined by OSG
|Defined by OSG
|}
|}
== Related content ==
=== Forum topics ===
* {{forum link|t=37364|title=Application of effects}} - Testing which kind of groups an effect can be applied to and when


[[Category:Shader development]]
[[Category:Shader development]]

Navigation menu