Effect framework: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 68: Line 68:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<effect>
<effect>
<inherits-from>Effects/light-cone</inherits-from>
  <inherits-from>Effects/light-cone</inherits-from>
<object-name>Cone</object-name>
  <object-name>Cone</object-name>
</effect>
</effect>
</syntaxhighlight>
</syntaxhighlight>


Line 86: Line 86:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<animation>
<animation>
<type>shader</type>
  <type>shader</type>
<shader>chrome</shader>
  <shader>chrome</shader>
<texture>glass_shader.png</texture>
  <texture>glass_shader.png</texture>
<object-name>windscreen</object-name>
  <object-name>windscreen</object-name>
</animation>
</animation>
</syntaxhighlight>
</syntaxhighlight>


Line 145: Line 145:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<generate>
<generate>
<tangent type="int">6</tangent>
  <tangent type="int">6</tangent>
<binormal type="int">7</binormal>
  <binormal type="int">7</binormal>
<normal type="int">8</normal>
  <normal type="int">8</normal>
</generate>
</generate>
</syntaxhighlight>
</syntaxhighlight>


Line 164: Line 164:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<program>
<program>
<vertex-shader>my_vertex_shader</vertex-shader>
  <vertex-shader>my_vertex_shader</vertex-shader>
<attribute>
  <attribute>
<name>my_tangent_attribute</name>
    <name>my_tangent_attribute</name>
<index>6</index>
    <index>6</index>
</attribute>
  </attribute>
<attribute>
  <attribute>
<name>my_binormal_attribute</name>
    <name>my_binormal_attribute</name>
<index>7</index>
    <index>7</index>
</attribute>
  </attribute>
</program>
</program>
</syntaxhighlight>
</syntaxhighlight>


Line 205: Line 205:
The proper way to test whether to enable a shader-based technique is:
The proper way to test whether to enable a shader-based technique is:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<predicate>
<predicate>
  <and>
  <and>
<property>/sim/rendering/shader-effects</property>
    <property>/sim/rendering/shader-effects</property>
<less-equal>
    <less-equal>
  <value type="float">1.0</value>
      <value type="float">1.0</value>
  <shader-language/>
      <shader-language/>
</less-equal>
    </less-equal>
  </and>
  </and>
</predicate>
</predicate>
</syntaxhighlight>
</syntaxhighlight>


Line 220: Line 220:
like this :
like this :
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
    <predicate>
<predicate>
      <and>
  <and>
        <property>/sim/rendering/shader-effects</property>
    <property>/sim/rendering/shader-effects</property>
<less-equal>
    <less-equal>
  <value type="float">2.0</value>
      <value type="float">2.0</value>
  <float-property>/sim/rendering/quality-level</float-property>
      <float-property>/sim/rendering/quality-level</float-property>
</less-equal>
    </less-equal>
<!-- other predicate conditions -->
    <!-- other predicate conditions -->
      </and>
  </and>
    </predicate>
</predicate>
</syntaxhighlight>
</syntaxhighlight>
      
      
Line 240: Line 240:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<predicate>
<predicate>
<and>
  <and>
  <property>/sim/rendering/shaders/quality-level</property>
    <property>/sim/rendering/shaders/quality-level</property>
  <property>/sim/rendering/shaders/model</property>
    <property>/sim/rendering/shaders/model</property>
  <or>
    <or>
<less-equal>
      <less-equal>
  <value type="float">2.0</value>
        <value type="float">2.0</value>
  <glversion/>
        <glversion/>
</less-equal>
      </less-equal>
<and>
      <and>
  <extension-supported>GL_ARB_shader_objects</extension-supported>
        <extension-supported>GL_ARB_shader_objects</extension-supported>
  <extension-supported>GL_ARB_shading_language_100</extension-supported>
        <extension-supported>GL_ARB_shading_language_100</extension-supported>
  <extension-supported>GL_ARB_vertex_shader</extension-supported>
        <extension-supported>GL_ARB_vertex_shader</extension-supported>
  <extension-supported>GL_ARB_fragment_shader</extension-supported>
        <extension-supported>GL_ARB_fragment_shader</extension-supported>
</and>
      </and>
  </or>
    </or>
</and>
  </and>
  </predicate>
</predicate>
</syntaxhighlight>
</syntaxhighlight>


Line 272: Line 272:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <blend>
<blend>
<active><use>blend/active</use></active>
  <active><use>blend/active</use></active>
<source>src-alpha</source>
  <source>src-alpha</source>
<destination>one-minus-src-alpha</destination>
  <destination>one-minus-src-alpha</destination>
  </blend>
</blend>
</syntaxhighlight>
</syntaxhighlight>


Line 287: Line 287:
constant. For example:
constant. For example:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<uniform>
<uniform>
<name>ColorsTex</name>
  <name>ColorsTex</name>
<type>sampler-1d</type>
  <type>sampler-1d</type>
<value type="int">2</value>
  <value type="int">2</value>
</uniform>
</uniform>
</syntaxhighlight>
</syntaxhighlight>
* The name of a property in the parameters section can be
* The name of a property in the parameters section can be
Line 297: Line 297:
section:
section:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<material>
<material>
<ambient><use>material/ambient</use></ambient>
  <ambient><use>material/ambient</use></ambient>
</material>
</material>
</syntaxhighlight>
</syntaxhighlight>
Then, in the parameters section of the effect:
Then, in the parameters section of the effect:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<parameters>
<parameters>
<material>
  <material>
<ambient type="vec4d">0.2 0.2 0.2 1.0</ambient>
    <ambient type="vec4d">0.2 0.2 0.2 1.0</ambient>
</material>
  </material>
</parameters>
</parameters>
</syntaxhighlight>
</syntaxhighlight>
It's worth pointing out that the "material" property in a
It's worth pointing out that the "material" property in a
Line 323: Line 323:
YET]. For example:
YET]. For example:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<parameters>
<parameters>
<chrome-light><use>/rendering/scene/chrome-light</use></chrome-light>
  <chrome-light><use>/rendering/scene/chrome-light</use></chrome-light>
</parameters>
</parameters>
</syntaxhighlight>
</syntaxhighlight>
The type is determined by what is expected by the technique
The type is determined by what is expected by the technique
Line 350: Line 350:
Example:
Example:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
                <blend>
<blend>
                        <active>true</active>
  <active>true</active>
                        <source>one-minus-dst-alpha</source>
  <source>one-minus-dst-alpha</source>
<destination>src-alpha-saturate</destination>
  <destination>src-alpha-saturate</destination>
</blend>
</blend>
</syntaxhighlight>
</syntaxhighlight>


Line 363: Line 363:
Example:
Example:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
                <blend>1</blend>
<blend>1</blend>
</syntaxhighlight>
</syntaxhighlight>


Line 408: Line 408:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
                <texture-unit>
<texture-unit>
                        <unit>3</unit>
  <unit>3</unit>
<image>Textures/Terrain/void.png</image>
  <image>Textures/Terrain/void.png</image>
<type>2d</type>
  <type>2d</type>
<filter>linear-mipmap-linear</filter>
  <filter>linear-mipmap-linear</filter>
                        <mag-filter>linear-mipmap-linear</mag-filter>
  <mag-filter>linear-mipmap-linear</mag-filter>
<wrap-s>repeat</wrap-s>
  <wrap-s>repeat</wrap-s>
<wrap-t>repeat</wrap-t>
  <wrap-t>repeat</wrap-t>
                        <wrap-r>repeat</wrap-r>
  <wrap-r>repeat</wrap-r>
<internal-format>normalized</internal-format>
  <internal-format>normalized</internal-format>
                        <mipmap-control>
  <mipmap-control>
                            <function-r>average</function-r>
    <function-r>average</function-r>
    <function-g>min</function-g>
    <function-g>min</function-g>
                            <function-b>sum</function-b>
    <function-b>sum</function-b>
    <function-a>product</function-a>
    <function-a>product</function-a>
                        </mipmap-control>
  </mipmap-control>
                        <environment>
  <environment>
                            <mode>decal</mode>  
    <mode>decal</mode>
                            <color>0.0 0.1 0.6 1.0</color>
    <color>0.0 0.1 0.6 1.0</color>
                        </environment>
  </environment>
                        <point-sprite>true</point-sprite>
  <point-sprite>true</point-sprite>
                        <texenv-combine>operand0-rgb</texenv-combine>
  <texenv-combine>operand0-rgb</texenv-combine>
                        <texgen>
  <texgen>
                            <mode>S</mode>
    <mode>S</mode>
                            <planes>0.075, 0.0, 0.0, 0.5</planes>
    <planes>0.075, 0.0, 0.0, 0.5</planes>
                        </texgen>
  </texgen>
</texture-unit>
</texture-unit>
</syntaxhighlight>
</syntaxhighlight>


Line 516: Line 516:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<program>
<program>
<vertex-shader n="0">Shaders/lcd.vert</vertex-shader>
  <vertex-shader n="0">Shaders/lcd.vert</vertex-shader>
<fragment-shader n="0">Shaders/lcd.frag</fragment-shader>
  <fragment-shader n="0">Shaders/lcd.frag</fragment-shader>
<fragment-shader n="1">Shaders/noise.frag</fragment-shader>
  <fragment-shader n="1">Shaders/noise.frag</fragment-shader>
<fragment-shader n="2">Shaders/filters-ALS.frag</fragment-shader>
  <fragment-shader n="2">Shaders/filters-ALS.frag</fragment-shader>
</program>
</syntaxhighlight>
 
example for clustered lightning in compositor:
 
<syntaxhighlight lang="xml">
<program>
<vertex-shader n="0">Shaders/lcd.vert</vertex-shader>
<fragment-shader n="0">Shaders/lcd.frag</fragment-shader>
<fragment-shader n="1">Shaders/noise.frag</fragment-shader>
<fragment-shader n="2">Shaders/filters-ALS.frag</fragment-shader>
                                <fragment-shader n="3">Shaders/ALS/clustered-include.frag</fragment-shader>
                                <uniform-block-binding>
                  <name>PointLightBlock</name>
                  <index>5</index>
                </uniform-block-binding>
                <uniform-block-binding>
                  <name>SpotLightBlock</name>
                  <index>6</index>
                </uniform-block-binding>
</program>
</program>
</syntaxhighlight>
</syntaxhighlight>


See this page for more about shaders: [[Howto:Shader programming in FlightGear]]
See this page for more about shaders: [[Howto:Shader programming in FlightGear]]
343

edits

Navigation menu