Howto:Aircraft reflection shader
|This article is a stub. You can help the wiki by|
| The FlightGear forum has a
subforum related to: Effects & Shaders
Reflection-Shaders - history and description
model-combined.eff and model-combined-deferred.eff
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:
The simple and quick method
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 aircraft model configuration file (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!
This method has a few parameters to influence how the reflection appears which can be set for every livery configuration:
- sim/model/civilian - a boolean to enable or disable the reflection.
- Civilian aircraft are usually glossy but military aircraft are not.
- sim/model/livery/shininess - a floating point value to specify the reflection factor.
- The range is between -1.0 and 0.0
- sim/model/livery/fresnel - a floating point value to specify the Fresnel factor.
- The range is between 0.0 and 1.0
These parameters can all be defined within a livery configuration file:
<PropertyList> <sim> <model> <civilian type="bool">true</civilian> <livery> <name type="string">Factory Demonstrator</name> <texture>Liveries/factory.png</texture> <shininess type="float">-0.5</shininess> <fresnel type="float">0.7</fresnel> </livery> </model> </sim> </PropertyList>
Adding a normal-map
It is also quite simple to to add a normal-map texture by expanding the section in the aircraft model configuration file:
<effect> <name>Effects/normalmap-reflection</name> <inherits-from>Aircraft/Generic/Effects/Fuselagereflect</inherits-from> <object-name>fuselage</object-name> <object-name>wing</object-name> <parameters> <texture n="2"> <image>Aircraft/AircraftName/Models/normalmap.png</image> </texture> </parameters> </effect>
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.
Customizing the reflection shader
To further customize the reflection shader take a look at the ALS technical notes