Howto:Aircraft reflection shader: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (typo; add syntaxhighlight)
(24 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[[Image:B29 shader.jpg|thumb|270px|Reflection Shader applied to the [[Boeing B-29 Superfortress|B-29]]. It shows a shiny, high-reflective blank metal.]]
{{stub}}
Within [[Flightgear]] GIT and later, a reflection [[Shaders|shader]] effect is available. Only few aircrafts make already use of it, but much more will be expected soon.
{{forum|47|Effects & Shaders}}


==Reflection-Shader and Reflect-Bump-Spec-Shader==
{{caution|
We have currently two different Reflection-Shaders. A simple ReflectionShader which works also on not-UVmapped surfaces and a ReflectionShader including [http://wiki.flightgear.org/index.php/Howto:_Use_the_normal_map_effect_in_aircraft Normalmap]. The later one only works on UVmapped surfaces.
The [[model-combined effect]] shader has '''replaced''' the separate reflection shaders.
The first one is ideal for windows and even surfaces, the second one for bumpy surfaces.
This effect uses Cubemaps and Cubecrosses from data/Aircraft/Generic/Effects which contains the image of the environment which will be visible as Reflection. Depending on which you choose, the appearance of the model will later change dramatically.


==How to implement==
The separate reflection shaders should be considered '''deprecated''' and '''should not be used for new development'''.}}
===the simple Method===


[[File:B29 shader.jpg|thumb|270px|Reflection Shader applied to the [[Boeing B-29 Superfortress|B-29]]. It shows a shiny, high-reflective blank metal.]]
Within [[Flightgear]] GIT and later, a reflection [[Shaders|shader]] effect is available. A lot of aircraft make already use of it, but much more will be expected soon.
== Reflection-Shaders - history and description ==
We have currently different reflection shaders, which represents the different states of development process behind.
=== reflect.eff ===
{{caution|See caution at the top of the article}}
It all began with a simple ReflectionShader, which simply adds a spherical map on the surface of the object. This shader works on non UV-mapped surfaces. Ideal for simple chrome parts.
'''Example Aircraft:''' B29
=== reflect-bump-spec.eff ===
{{caution|See caution at the top of the article}}
Later it had been enhanced by a [[Howto: Use the normal map effect in aircraft|normal map]]. This makes the surface appear "bumpy" depending on the used normal map. The alpha channel of the normal map also defines the specularity of the surface. This shader works only on UV-mapped surfaces!
=== model-combined-deferred.eff and model-combined-transparent.eff ===
These shaders had been enhanced even more. You have now: reflections, normalmap and specularity map, dirt, lightmaps with 4 simulated lights per object in Default and [[Project Rembrandt|Rembrandt]]. In [[Atmospheric light scattering FAQ|ALS]] you will get in addition also a grain/ rain effect and the darkmap. This shader works only on UVmapped surfaces!
This shader inherits from [[Model-combined_effect|model-combined.eff]], an effect which should never be directly used, since it holds only the definition of the common parts of the two effects.
The model-combined-transparent.eff has the same features but has the necessary changes to correctly support transparent objects which represents transparent surfaces like glass.
'''Example Aircraft:''' EC 130 B4, EC 135 P2
=== What will be reflected on the surfaces? ===
All of these effects use Cubemaps and Cubecrosses from data/Aircraft/Generic/Effects which contains the image of the environment which will be visible as Reflection. Depending on which you choose, the appearance of the model will later change dramatically.
== How to implement the simple ReflectionShader: reflect.eff ==
{{caution|See caution at the top of the article}}
=== The simple and quick method ===
This is a simple and quick method for the simple ReflectionShader, but gives not the freedom to change the later appearance of the aircraft like setting the strength of the reflection or choosing a different cubemap.
This is a simple and quick method for the simple ReflectionShader, but gives not the freedom to change the later appearance of the aircraft like setting the strength of the reflection or choosing a different cubemap.


Line 15: Line 44:


Inside the <tt>AircraftName.xml</tt>, we need to put the following lines of code, shortly after or before other <animation> tag entries:
Inside the <tt>AircraftName.xml</tt>, we need to put the following lines of code, shortly after or before other <animation> tag entries:
 
<syntaxhighlight lang="xml">
  <nowiki><!-- REFLECTION --></nowiki>
  <nowiki><!-- REFLECTION --></nowiki>
     <effect>
     <effect>
Line 35: Line 64:
         <object-name>RHelevator</object-name>
         <object-name>RHelevator</object-name>
     </effect>
     </effect>
 
</syntaxhighlight>
Note that for each <object-name> tag, you need to indicate the aircraft's objects. If you are not the original aircraft author and do not know which parts to enter, or how they are named, use the other animations tags object names which indicate the pieces you require to be reflected (such as <object-name>fuselage</object-name> is an obvious one). Obviously do not enter things which you don't want to be reflected!
Note that for each <object-name> tag, you need to indicate the aircraft's objects. If you are not the original aircraft author and do not know which parts to enter, or how they are named, use the other animations tags object names which indicate the pieces you require to be reflected (such as <object-name>fuselage</object-name> is an obvious one). Obviously do not enter things which you don't want to be reflected!


Line 41: Line 70:
As an example the C160 Transall by helijah makes use of this simple method.
As an example the C160 Transall by helijah makes use of this simple method.


===a bit more difficult Method- but more freedom!===
=== a bit more difficult Method- but more freedom! ===


The next method describes how to add the effect of a customized simple ReflectionShader, which allows more freedom.
The next method describes how to add the effect of a customized simple ReflectionShader, which allows more freedom.


Creates a Folder inside your Models-folder called "Effects".
You'll still need to use the code above in your file but this time, you'll use your own effect shader (below). The difference is you'll replace:
Now you create a new .eff-file called like that: foo_effects.eff and save it to the "Effects"-folder:
<syntaxhighlight lang="xml">
<inherits-from>Aircraft/Generic/Effects/Fuselagereflect</inherits-from>
</syntaxhighlight>
with
<syntaxhighlight lang="xml">
<inherits-from>Aircraft/YourAircraftName/Effects/foo_reflect</inherits-from>
</syntaxhighlight>
Now we'll create this foo_reflect file.


<nowiki>foo_effects.eff</nowiki>
Create a Folder inside your Models-folder called "Effects".
<PropertyList>
Now you create a new .eff file named: foo_reflect.eff and save it to the "Effects" folder:
<name>Effects/ec130reflect</name>
<syntaxhighlight lang="xml">
<inherits-from>Effects/reflect</inherits-from>
<!--foo_reflect.eff-->
<PropertyList>
  <name>Effects/foo_reflect</name>
  <inherits-from>Effects/reflect</inherits-from>
   <parameters>
   <parameters>
     <texture n="5">
     <texture n="5">
    <type>cubemap</type>
      <type>cubemap</type>
  <!-- use this form for a cube cross  
  <!-- use this form for a cube cross  
    <image>Aircraft/Generic/Effects/CubeCrosses/real.blue_sky.png</image>-->
      <image>Aircraft/Generic/Effects/CubeCrosses/real.blue_sky.png</image>-->
  <!-- use this form for a 6 image cube map -->
  <!-- use this form for a 6 image cube map -->
    <images>
      <images>
         <positive-x>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_px.png</positive-x>
         <positive-x>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_px.png</positive-x>
         <negative-x>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_nx.png</negative-x>
         <negative-x>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_nx.png</negative-x>
Line 67: Line 106:
       </images>
       </images>
     </texture>
     </texture>
<texture n="6">
    <texture n="6">
    <image>Aircraft/Generic/Effects/Rainbow.png</image>
      <image>Aircraft/Generic/Effects/Rainbow.png</image>
    <filter>linear-mipmap-linear</filter>
      <filter>linear-mipmap-linear</filter>
    <wrap-s>repeat</wrap-s>
      <wrap-s>repeat</wrap-s>
    <wrap-t>repeat</wrap-t>
      <wrap-t>repeat</wrap-t>
    <internal-format>normalized</internal-format>
      <internal-format>normalized</internal-format>
</texture>
    </texture>
<texture n="7">
    <texture n="7">
    <image>Aircraft/Generic/Effects/FresnelLookUp.png</image>
      <image>Aircraft/Generic/Effects/FresnelLookUp.png</image>
    <filter>linear-mipmap-linear</filter>
      <filter>linear-mipmap-linear</filter>
    <wrap-s>repeat</wrap-s>
      <wrap-s>repeat</wrap-s>
    <wrap-t>repeat</wrap-t>
      <wrap-t>repeat</wrap-t>
    <internal-format>normalized</internal-format>
      <internal-format>normalized</internal-format>
</texture>
    </texture>
    <texture n="8">
      <texture n="8">
    <image>Aircraft/ec130/Models/Effects/greymap.png</image>
      <image>Aircraft/foo/Models/Effects/greymap.png</image>
    <filter>linear-mipmap-linear</filter>
      <filter>linear-mipmap-linear</filter>
    <wrap-s>repeat</wrap-s>
      <wrap-s>repeat</wrap-s>
    <wrap-t>repeat</wrap-t>
      <wrap-t>repeat</wrap-t>
    <internal-format>normalized</internal-format>
      <internal-format>normalized</internal-format>
</texture>
    </texture>
  <rendering-hint>transparent</rendering-hint>
    <rendering-hint>transparent</rendering-hint>
  <shade-model>smooth</shade-model>
    <shade-model>smooth</shade-model>
  <rainbowiness type="float">0.01</rainbowiness>
    <rainbowiness type="float">0.01</rainbowiness>
  <fresneliness>0.0</fresneliness>
    <fresneliness>0.0</fresneliness>
  <noisiness>0.0</noisiness>
    <noisiness>0.0</noisiness>
  <refl_correction>0.0</refl_correction>
    <refl_correction>0.0</refl_correction>
  <ambient_correction>0.0</ambient_correction>
    <ambient_correction>0.0</ambient_correction>
  <reflect_map>1</reflect_map>
    <reflect_map>1</reflect_map>
   </parameters>
   </parameters>
  </PropertyList>
  </PropertyList>
</syntaxhighlight>
'''Explanation:'''


The tags at the bottom:


* <rainbowiness> = adds a nice Rainbow-effect to the reflection. Perfect for the modern Airliner-windows or modern coatings.
* <fresneliness> = adds some black stripes to the reflection.
* <noisiness> = adds noise to the reflection. Usefull for dirt etc...
* <ambient_correction> = correct the appearance of the reflection at shadowed parts.
* <reflect_map> = enables the use of a greymap. If enabled the greymap will controll the strength of the reflection. Black = zero reflection, White = full reflection. For modern aircraft coatings a grey of 75-90% is usefull, for chromish parts about 10-25%.
* <refl_correction> = another parameter for controlling the strength of the reflection. Reflect_map and refl_correction are working together.
* ''"texture= n5"'' is the path to the image wich will be later the reflection. You can choose between cubemaps with 6 single images or a cubecross. You can take the one included in ''data/Aircraft/Generic/Effects'' or you can use your own.
* ''"texture= n6"'' is the path to the rainbow-texture.
* ''"texture= n7"'' path to the fresnel-texture.
* ''"texture= n8"''is the path to the greymap.


article compiled by Liam Gathercole and Heiko Schulz, please feel free to change/add more details if further enhancements can be made.
[[Category:Shaders]]
 
[[Category:Aircraft enhancement|Aircraft Reflection Shader]]
[[Category:Aircraft enhancement|Aircraft Reflection Shader]]
[[Category:Howto|Aircraft Reflection Shader]]
[[Category:Howto|Aircraft Reflection Shader]]

Revision as of 09:58, 25 October 2015

This article is a stub. You can help the wiki by expanding it.
Caution

The model-combined effect shader has replaced the separate reflection shaders.

The separate reflection shaders should be considered deprecated and should not be used for new development.

Reflection Shader applied to the B-29. It shows a shiny, high-reflective blank metal.

Within Flightgear GIT and later, a reflection shader effect is available. A lot of aircraft make already use of it, but much more will be expected soon.

Reflection-Shaders - history and description

We have currently different reflection shaders, which represents the different states of development process behind.

reflect.eff

Caution  See caution at the top of the article

It all began with a simple ReflectionShader, which simply adds a spherical map on the surface of the object. This shader works on non UV-mapped surfaces. Ideal for simple chrome parts.

Example Aircraft: B29

reflect-bump-spec.eff

Caution  See caution at the top of the article

Later it had been enhanced by a normal map. This makes the surface appear "bumpy" depending on the used normal map. The alpha channel of the normal map also defines the specularity of the surface. This shader works only on UV-mapped surfaces!

model-combined-deferred.eff and model-combined-transparent.eff

These shaders had been enhanced even more. You have now: reflections, normalmap and specularity map, dirt, lightmaps with 4 simulated lights per object in Default and Rembrandt. In ALS you will get in addition also a grain/ rain effect and the darkmap. This shader works only on UVmapped surfaces! This shader inherits from model-combined.eff, an effect which should never be directly used, since it holds only the definition of the common parts of the two effects. The model-combined-transparent.eff has the same features but has the necessary changes to correctly support transparent objects which represents transparent surfaces like glass.

Example Aircraft: EC 130 B4, EC 135 P2

What will be reflected on the surfaces?

All of these effects use Cubemaps and Cubecrosses from data/Aircraft/Generic/Effects which contains the image of the environment which will be visible as Reflection. Depending on which you choose, the appearance of the model will later change dramatically.

How to implement the simple ReflectionShader: reflect.eff

Caution  See caution at the top of the article

The simple and quick method

This is a simple and quick method for the simple ReflectionShader, but gives not the freedom to change the later appearance of the aircraft like setting the strength of the reflection or choosing a different cubemap.

Inside the Aircraft/AircraftName/Models folder, there should be a main xml file, which usually is AircraftName.xml. This file should be the one holding all information on visuals used in the aircraft. As such, we need to indicate which are to be reflectable!

Inside the AircraftName.xml, we need to put the following lines of code, shortly after or before other <animation> tag entries:

 <nowiki><!-- REFLECTION --></nowiki>
    <effect>
        <inherits-from>Aircraft/Generic/Effects/Fuselagereflect</inherits-from>
        <object-name>Fuselage</object-name>
        <object-name>RFdoor</object-name>
        <object-name>LFdoor</object-name>
        <object-name>LRdoor</object-name>
        <object-name>RRdoor</object-name>
        <object-name>Rmain.geardoor</object-name>
        <object-name>Lmain.geardoor</object-name>
        <object-name>Engines</object-name>
        <object-name>Reversers</object-name>
        <object-name>Tail</object-name>
        <object-name>Rudder</object-name>
        <object-name>RHstab</object-name>
        <object-name>LHstab</object-name>
        <object-name>LHelevator</object-name>
        <object-name>RHelevator</object-name>
    </effect>

Note that for each <object-name> tag, you need to indicate the aircraft's objects. If you are not the original aircraft author and do not know which parts to enter, or how they are named, use the other animations tags object names which indicate the pieces you require to be reflected (such as <object-name>fuselage</object-name> is an obvious one). Obviously do not enter things which you don't want to be reflected!

To see them in sim, ensure your View > Rendering options > Effects & shaders options are checked. As an example the C160 Transall by helijah makes use of this simple method.

a bit more difficult Method- but more freedom!

The next method describes how to add the effect of a customized simple ReflectionShader, which allows more freedom.

You'll still need to use the code above in your file but this time, you'll use your own effect shader (below). The difference is you'll replace:

<inherits-from>Aircraft/Generic/Effects/Fuselagereflect</inherits-from>

with

<inherits-from>Aircraft/YourAircraftName/Effects/foo_reflect</inherits-from>

Now we'll create this foo_reflect file.

Create a Folder inside your Models-folder called "Effects". Now you create a new .eff file named: foo_reflect.eff and save it to the "Effects" folder:

<!--foo_reflect.eff-->
<PropertyList>
  <name>Effects/foo_reflect</name>
  <inherits-from>Effects/reflect</inherits-from>
  <parameters>
    <texture n="5">
      <type>cubemap</type>
 <!-- use this form for a cube cross 
      <image>Aircraft/Generic/Effects/CubeCrosses/real.blue_sky.png</image>-->
 <!-- use this form for a 6 image cube map -->
      <images>
        <positive-x>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_px.png</positive-x>
        <negative-x>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_nx.png</negative-x>
        <positive-y>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_py.png</positive-y>
        <negative-y>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_ny.png</negative-y>
        <positive-z>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_pz.png</positive-z>
        <negative-z>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_nz.png</negative-z>
      </images>
    </texture>
    <texture n="6">
      <image>Aircraft/Generic/Effects/Rainbow.png</image>
      <filter>linear-mipmap-linear</filter>
      <wrap-s>repeat</wrap-s>
      <wrap-t>repeat</wrap-t>
      <internal-format>normalized</internal-format>
    </texture>
    <texture n="7">
      <image>Aircraft/Generic/Effects/FresnelLookUp.png</image>
      <filter>linear-mipmap-linear</filter>
      <wrap-s>repeat</wrap-s>
      <wrap-t>repeat</wrap-t>
      <internal-format>normalized</internal-format>
    </texture>
      <texture n="8">
      <image>Aircraft/foo/Models/Effects/greymap.png</image>
      <filter>linear-mipmap-linear</filter>
      <wrap-s>repeat</wrap-s>
      <wrap-t>repeat</wrap-t>
      <internal-format>normalized</internal-format>
    </texture>
    <rendering-hint>transparent</rendering-hint>
    <shade-model>smooth</shade-model>
    <rainbowiness type="float">0.01</rainbowiness>
    <fresneliness>0.0</fresneliness>
    <noisiness>0.0</noisiness>
    <refl_correction>0.0</refl_correction>
    <ambient_correction>0.0</ambient_correction>
    <reflect_map>1</reflect_map>
  </parameters>
 </PropertyList>

Explanation:

The tags at the bottom:

  • <rainbowiness> = adds a nice Rainbow-effect to the reflection. Perfect for the modern Airliner-windows or modern coatings.
  • <fresneliness> = adds some black stripes to the reflection.
  • <noisiness> = adds noise to the reflection. Usefull for dirt etc...
  • <ambient_correction> = correct the appearance of the reflection at shadowed parts.
  • <reflect_map> = enables the use of a greymap. If enabled the greymap will controll the strength of the reflection. Black = zero reflection, White = full reflection. For modern aircraft coatings a grey of 75-90% is usefull, for chromish parts about 10-25%.
  • <refl_correction> = another parameter for controlling the strength of the reflection. Reflect_map and refl_correction are working together.
  • "texture= n5" is the path to the image wich will be later the reflection. You can choose between cubemaps with 6 single images or a cubecross. You can take the one included in data/Aircraft/Generic/Effects or you can use your own.
  • "texture= n6" is the path to the rainbow-texture.
  • "texture= n7" path to the fresnel-texture.
  • "texture= n8"is the path to the greymap.