Howto:Aircraft reflection shader: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
mNo edit summary
Line 102: Line 102:


article compiled by Liam Gathercole and Heiko Schulz, please feel free to change/add more details if further enhancements can be made.
article compiled by Liam Gathercole and Heiko Schulz, please feel free to change/add more details if further enhancements can be made.
 
--[[User:HHS|HHS]] 21:30, 22 September 2010 (UTC)
[[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 21:30, 22 September 2010

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. Only few aircrafts make already use of it, but much more will be expected soon.

Reflection-Shader and Reflect-Bump-Spec-Shader

We have currently two different Reflection-Shaders. A simple ReflectionShader which works also on not-UVmapped surfaces and a ReflectionShader including Normalmap. The later one only works on UVmapped surfaces. 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 simple 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:

<!-- REFLECTION -->
   <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.

Creates a Folder inside your Models-folder called "Effects". Now you create a new .eff-file called like that: foo_effects.eff and save it to the "Effects"-folder:

<!--foo_effects.eff-->
<PropertyList>
<name>Effects/ec130reflect</name>
<inherits-from>Effects/reflect</inherits-from>
 <parameters>
   <texture n="5">
   <type>cubemap</type>
    <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/ec130/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>


article compiled by Liam Gathercole and Heiko Schulz, please feel free to change/add more details if further enhancements can be made. --HHS 21:30, 22 September 2010 (UTC)