Howto:Illuminate faces: Difference between revisions

Jump to navigation Jump to search
m (Robot: Cosmetic changes)
 
(13 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{obsolete|Howto:Lightmap}}
Imagine you see a skyline with a countless amount of lights. Somewhere in front of you there's a stretched row of lights. That's the runway you will land on. That's how you will experience a flight in the dark of the night. In reality. But in [[FlightGear]] there aren't much illuminated buildings. So here's a [[:Category:Howto|howto]] that teaches you how to make lights and illuminated buildings. Enjoy!
Imagine you see a skyline with a countless amount of lights. Somewhere in front of you there's a stretched row of lights. That's the runway you will land on. That's how you will experience a flight in the dark of the night. In reality. But in [[FlightGear]] there aren't much illuminated buildings. So here's a [[:Category:Howto|howto]] that teaches you how to make lights and illuminated buildings. Enjoy!


Line 140: Line 142:
   </emission>
   </emission>
  </animation>
  </animation>
===Changing illumination color directly via parameters===
It is possible to perform the change of color through the use of properties through the tag '''<red-prop>, <green-prop> or <blue-prop>''' to be associated with a parameter defined in the property tree.
For example:
<source>
    <emission>
        <red>0.12</red>
        <green>0.0</green>
        <blue-prop>sim/G91/Test/V0_1B</blue-prop>
        <factor-prop>sim/G91/re_emit/gauge_red_light</factor-prop>
    </emission>
</source>
<factor-pro> always works on the three colors, so any color mixing should be managed using a NASAL or JSBSim function so that the colors are harmonized together.
In this example we mix two colors on a surface (for example the cockpit). The two colors correspond to the red used to illuminate the cockpit and the blue emitted by a wood lamp to illuminate the instrument quadrants. The mixing between the two colors has been assumed as 20% for Wood's light (a value quite close to reality for metallic surfaces), therefore two variables are prepared, one for red and the other for Wood's luve (UV ):
<source>
  setprop("sim/G91/re_emit/gauge_phosphorescent_light",pl_phosphorescent_emission * light_by_tension_bus);
  setprop("sim/G91/re_emit/gauge_UV_light_on_red_light",pl_phosphorescent_emission * light_by_tension_bus * 0.2);
</source>
The <factor-prop> at this point becomes constant and indicates the reflection factor of the material (high for a glossy or light and lower material for an opaque or dark material). In the example we use the value 0.12. The <factor-prop> tag cannot handle constant values and therefore the <factor> tag should be used, so it is possible to use the same function for different types of materials in different lighting contexts.
<source>
    <emission>
        <red-prop>sim/G91/re_emit/gauge_red_light</red-prop>
        <green>0.0</green>
        <blue-prop>sim/G91/re_emit/gauge_UV_light_on_red_light</blue-prop>
        <factor>0.12</factor>
    </emission>
</source>


=== Changing texture if illuminated ===
=== Changing texture if illuminated ===
To change the texture of an illuminated face we add one single row to the file.
To change the texture of an illuminated face we add one single row to the file.


'''NOTE: This does not work with any version newer than v1.0!'''
'''NOTE: This does not work with versions between GIT/2.2.0 snapshot releases and 1.0.0!'''


  <animation>
  <animation>
Line 183: Line 218:
For v1.9 or later, the way to change textures is the textranslate animation, which lets you "slide" across a texture map. This animation is applied to a single image which has the daytime and nighttime textures placed next to each other.
For v1.9 or later, the way to change textures is the textranslate animation, which lets you "slide" across a texture map. This animation is applied to a single image which has the daytime and nighttime textures placed next to each other.


The width in pixels of texture map (if it is being moved sideways) should be an integral power of two (eg. 2<sup>0</sup>=1, 2<sup>1</sup>=2, 2<sup>2</sup>=4, 2<sup>3</sup>=8, 2<sup>4</sup>=16 and so on). For this example, this texture map has two sides that are each 256 pixels wide. The '''left side''' is for day-time textures, the '''right side''' is for night-time textures. Each night-time texture is positioned exactly 256 pixels to the right of the day-time texture. Here is an example taken from the shared model [http://scenemodels.flightgear.org/modeledit.php?id=1570 German village house - grey roof]:
The width in pixels of texture map (if it is being moved sideways) should be an integral power of two (eg. 2<sup>0</sup>=1, 2<sup>1</sup>=2, 2<sup>2</sup>=4, 2<sup>3</sup>=8, 2<sup>4</sup>=16 and so on). For this example, this texture map has two sides that are each 256 pixels wide. The '''left side''' is for day-time textures, the '''right side''' is for night-time textures. Each night-time texture is positioned exactly 256 pixels to the right of the day-time texture. Here is an example taken from the shared model [https://scenery.flightgear.org/app.php?c=Models&a=view&id=1570 German village house - grey roof]:
[[File:Germanvillagehouse1_day.png|thumb|day-time textures]]  
[[File:Germanvillagehouse1_day.png|thumb|day-time textures]]  
[[File:Germanvillagehouse1_night.png|thumb|night-time textures]]
[[File:Germanvillagehouse1_night.png|thumb|night-time textures]]
Line 189: Line 224:
[[File:Germanvillagehouse1.png]]
[[File:Germanvillagehouse1.png]]


When you have made that texture map, you apply the day-time textures as default textures to the model either in [[Blender]] or [[SketchUp]].
When you have made that texture map, you apply the day-time textures as default textures to the model in your favourite modeling software (e.g. [[Blender]] or [[SketchUp]]).


Finally you have to add two bits of code to the XML file: 1) Code that tells FG to move the texture to the left during night-time and 2) code that illuminates the model during night-time.
Finally you have to add two bits of code to the XML file:  
# Code that tells FG to move the texture to the left during night-time
# Code that illuminates the model during night-time


The following code tells FG to translate the texture halfway across horizontally at nightfall:
The following code tells FlightGear to translate the texture halfway across horizontally at nightfall (setting <tt>y</tt> instead would translate it vertically):


<syntaxhighlight lang="xml">
   <animation>
   <animation>
     <type>textranslate</type>  
     <type>textranslate</type>  
Line 201: Line 239:
     <step> 1.57 </step>
     <step> 1.57 </step>
     <factor>0.318471338</factor>
     <factor>0.318471338</factor>
    <nowiki><center></nowiki>
      <x-m> 0 </x-m>
      <y-m> 0 </y-m>
      <z-m> 0 </z-m>
    </center>
     <axis>  
     <axis>  
       <x> -1 </x>  
       <x> -1 </x>  
       <y>  0 </y>  
       <y>  0 </y>  
      <z>  0 </z>
     </axis>  
     </axis>  
   </animation>
   </animation>
The 3d object (the house) which "wears" the texture is called <tt>germanvillagehouse1</tt> here. This name refers to the name given to the respective object in the AC file. For more information on object names, see [[AC files: Understanding and changing .ac code#Identifying an object|AC files: Basic changes to textures and colors]].
</syntaxhighlight>


In order to illuminate the object during dark, add the block of code introduced above: [[Howto: Illuminate faces#Illuminate during dark|Illuminate during dark]]. Finally you will have two blocks of code: One that moves the texture at dusk and one that illuminates the object at dusk. Make sure both of them use the right object name. The light will be switched off and the texture will be switched back to day-time texture when the sun rises above an angle of 1.57. Two essential tags here are <step> and <factor>. The <step> tag indicates that the texture should be translated in a single step only when the value passes 1.57 or a multiple thereof; without it the texture would be translated continuously. The <factor> tag is equal to 0.5/1.57, which normalizes the sun angle in radians to a value between 0 and 1 for translating the texture.
The 3d object (the house) which "wears" the texture is called <tt>germanvillagehouse1</tt> here. This name refers to the name given to the respective object in the AC file. For more information on object names, see [[AC files: Understanding and changing .ac code#Identifying an object|AC files: identifying an object]].
 
In order to illuminate the object during dark, add the block of code introduced above: [[Howto: Illuminate faces#Illuminate during dark|Illuminate during dark]]. Finally you will have two blocks of code: One that moves the texture at dusk and one that illuminates the object at dusk. Make sure both of them use the right object name. The light will be switched off and the texture will be switched back to day-time texture when the sun rises above an angle of 1.57. Two essential tags here are <step> and <factor>.  
* '''<step>''' indicates that the texture should be translated in a single step only when the value passes 1.57 or a multiple thereof; without it the texture would be translated continuously.  
* '''<factor>''' is equal to 0.5/1.57, which normalizes the sun angle in radians to a value between 0 and 1 for translating the texture.


=== Flashing light ===
=== Flashing light ===
Line 239: Line 275:


You can set the values (time in seconds that a certain object is shown) to your needs. The upper ones are for the LightsOn object, the lower ones for the LightsOff object.
You can set the values (time in seconds that a certain object is shown) to your needs. The upper ones are for the LightsOn object, the lower ones for the LightsOff object.
== Related content ==
* [[Howto: Lightmap|Lightmap effect]], allows for easy and nice looking lighting, without switching textures.


[[Category:Howto|Illuminate faces]]
[[Category:Howto|Illuminate faces]]
[[Category:Scenery enhancement|Illuminate faces]]
[[Category:Scenery enhancement|Illuminate faces]]
408

edits

Navigation menu