Mapdev:water: Difference between revisions

From Spring
Jump to navigationJump to search
m started figuring out the various aspects of water.. but have to leave now.. will continue later.
m cleaned up some more, learned a lot while reading source files and trying to figure out how water works..
Line 1: Line 1:
= Water =
= Water =
The 'water' engine feature can be used for more than just water, it can be Lava, Slime, and completely invisible for maps in space.
The 'water' engine feature can be used for more than just water, it can be Lava, Slime, and completely invisible for maps in space.
Water is always at zero elevation, the terrain is positioned above and below the water using the <code>minHeight</code> and <code>maxHeight</code> values(see [[Mapdev:height]]).
Shading of the water is split into two parts; the surface of the water and the surface of the ground under the water


Water has five different rendering modes which can be set ingame by the command:
Water has five different rendering modes which can be set ingame by the command:
Line 14: Line 18:
The relevant soure code [https://github.com/spring/spring/tree/bfc21aada48a6a606b039819ba55017fe3d4f29d/rts/Rendering/Env files]
The relevant soure code [https://github.com/spring/spring/tree/bfc21aada48a6a606b039819ba55017fe3d4f29d/rts/Rendering/Env files]


 
= Specifications =
 
Now because of the various graphical modes, and some options being shared, I've split this into sections.
= Specification =
Now because of the various graphical modes, and some options being shared, were going to list them separately.
== Options that are always relevant ==
== Options that are always relevant ==
=== mapinfo.lua ===
<code><pre>local mapinfo = {
<code><pre>local mapinfo = {
   ...
   ...
Line 27: Line 28:
   water = {
   water = {
       damage =  0.0,
       damage =  0.0,
       windSpeed = 1.0, --// does nothing yet
 
       absorb    = {0.0, 0.0, 0.0},
      baseColor = {0.0, 0.0, 0.0},
      minColor  = {0.0, 0.0, 0.0},
 
      forceRendering = false,
     },
     },
   ...
   ...
}</pre></code>
}</pre></code>
{{tag|name=tidalStrength|type=float}}
{{tag|name=voidWater|default=false|type=bool|description=If true, the water will not be drawn. Also the terrain under the water will not be drawn.}}
{{tag|name=damage|type=float}}
{{tag|name=absorb|type=float3|description=Used to calculate the colour of the terrain under the water, see below.}}
{{tag|name=baseCcolor|type=float3|description=Used to calculate the colour of the terrain under the water, see below.}}
{{tag|name=minColor|type=float3|description=Used to calculate the colour of the terrain under the water, see below.}}
The absorb, baseColor and minColor variables are used to alter the colour of the terrain under the water as defined in a glsl shader, see [https://github.com/spring/spring/blob/a71c17d710cc387c484e876971881837ecb0ff10/cont/base/springcontent/shaders/GLSL/SMFFragProg.glsl line 163].
{{tag|name=forceRendering|default=false|type=bool|description=If false, and the minimum height of the terrain is above 1.0, then the water will not be drawn.}}


== Basic ==
== Basic ==
Line 38: Line 60:
| {{FIXME}}need to place an image here
| {{FIXME}}need to place an image here
|}</center>
|}</center>
=== mapinfo.lua ===
<code><pre>local mapinfo = {
<code><pre>local mapinfo = {
   ...
   ...
Line 57: Line 78:


== Reflective ==
== Reflective ==
<center>
{| class="wikitable"
|+ Example
| {{FIXME}}need to place an image here
|}</center>
<code><pre>local mapinfo = {
  ...
  water = {
      surfaceColor  = {0.75, 0.8, 0.85},
  },
  ...
}</pre></code>
{{FIXME}}?
{{tag|name=surfaceColor|type=float3f|default={0.0, 0.0, 0.0}|description=Effects the reflected colour.}}
== Dynamic ==
== Dynamic ==
== Reflective and Refractive ==
== Bump Mapped ==
== All Options(to be deleted later) ==
<center>
<center>
{| class="wikitable"  
{| class="wikitable"  
Line 67: Line 101:
| {{FIXME}}need to place an image here
| {{FIXME}}need to place an image here
|}</center>
|}</center>
== mapinfo.lua ==
<code><pre>local mapinfo = {
<code><pre>local mapinfo = {
   ...
   ...
   tidalStrength = 0,
   water = {
   voidWater = false,
      surfaceColor  = {0.75, 0.8, 0.85},
      --foamTexture =  "",
   },
   ...
   ...
  water = {
}</pre></code>
      damage =  0.0,
 
{{tag|name=surfaceColor|type=float3f|default={0.0, 0.0, 0.0}|description=Effects the reflected colour.}}


      repeatX = 0.0,
{{FIXME}}?
      repeatY = 0.0,


      absorb    = {0.0, 0.0, 0.0},
== Reflective and Refractive ==
      baseColor = {0.0, 0.0, 0.0},
{{FIXME}}?
      minColor  = {0.0, 0.0, 0.0},


== Bump Mapped ==
<center>
{| class="wikitable"
|+ Example
| {{FIXME}}need to place an image here
|}</center>
<code><pre>local mapinfo = {
  ...
  water = {
       ambientFactor  = 1.0,
       ambientFactor  = 1.0,
       diffuseFactor  = 1.0,
       diffuseFactor  = 1.0,
Line 110: Line 153:


       shoreWaves = true,
       shoreWaves = true,
      forceRendering = false,


      --// undefined == load them from resources.lua!
      --texture =      "",
       --foamTexture =  "",
       --foamTexture =  "",
       --normalTexture = "",
       --normalTexture = "",
Line 120: Line 160:
       --  "",
       --  "",
       --},
       --},
      numTiles = 1,
      hasWaterPlane = true,


   },
   },
Line 125: Line 167:
}</pre></code>
}</pre></code>


=== Void Water ===
{{FIXME}}?
{{FIXME}} discussion on void water and use cases
<center>
{| class="wikitable"
|+ Example
| {{FIXME}}need to place an image here
|}</center>
 
=== Tidal Strength ===
{{FIXME}}Discussion on resourcing again.
 
 
=== Shore Waves ===
{{FIXME}}so much to put in here that i cant test and such because my hardware doesn't support it :|
 
== The Water Plane ==
The water plane is a rectangle the same size as the entire map with a position of <code>y = 0</code>, anything underneath the water plane is underwater. The terrain is positioned above and below the water plane using its <code>minHeight</code> and <code>maxHeight</code> values(see [[Mapdev:height]]).
 
To derive the exact value of grey on the heightmap that will be at the water plane use:
* <code>{{FIXME}}equation</code>
To derive the maxHeight given a grey value and a minheight use:
* <code>{{FIXME}}equation</code>
To derive the minHeight given a grey value and a maxheight use:
* <code>{{FIXME}}equation</code>
To derive the maxHeight and minHeight given a grey value and a total height use:
* <code>{{FIXME}}equation</code>


= Forum Discussions =
= Forum Discussions =

Revision as of 07:29, 21 February 2013

Water

The 'water' engine feature can be used for more than just water, it can be Lava, Slime, and completely invisible for maps in space.

Water is always at zero elevation, the terrain is positioned above and below the water using the minHeight and maxHeight values(see Mapdev:height).

Shading of the water is split into two parts; the surface of the water and the surface of the ground under the water

Water has five different rendering modes which can be set ingame by the command:

/water
  1. basic
  2. reflective
  3. dynamic
  4. reflective&refractive
  5. bumpmapped

The relevant soure code files

Specifications

Now because of the various graphical modes, and some options being shared, I've split this into sections.

Options that are always relevant

local mapinfo = {
   ...
   tidalStrength = 0,
   voidWater = false,
   ...
   water = {
      damage =  0.0,

      absorb    = {0.0, 0.0, 0.0},
      baseColor = {0.0, 0.0, 0.0},
      minColor  = {0.0, 0.0, 0.0},

      forceRendering = false,
    },
   ...
}

float tidalStrength  default: ? 

FIXME:

bool voidWater  default: false 

If true, the water will not be drawn. Also the terrain under the water will not be drawn.

float damage  default: ? 

FIXME:

float3 absorb  default: ? 

Used to calculate the colour of the terrain under the water, see below.

float3 baseCcolor  default: ? 

Used to calculate the colour of the terrain under the water, see below.

float3 minColor  default: ? 

Used to calculate the colour of the terrain under the water, see below.

The absorb, baseColor and minColor variables are used to alter the colour of the terrain under the water as defined in a glsl shader, see line 163.

bool forceRendering  default: false 

If false, and the minimum height of the terrain is above 1.0, then the water will not be drawn.

Basic

Example
FIXME: need to place an image here
local mapinfo = {
   ...
   water = {
      repeatX = 0.0,
      repeatY = 0.0,

      --texture = "",
   },
   ...
}

float repeatX  default: 0 

control the texture repetition

float repeatY  default: 0 

control the texture repetition

string texture  default: 0 

the texture image to use, searches the ./maps/ directory of the map archive.

Reflective

Example
FIXME: need to place an image here
local mapinfo = {
   ...
   water = {
      surfaceColor  = {0.75, 0.8, 0.85},
   },
   ...
}

FIXME: ?

float3f surfaceColor  default: {0.0, 0.0, 0.0} 

Effects the reflected colour.

Dynamic

Example
FIXME: need to place an image here
local mapinfo = {
   ...
   water = {
      surfaceColor  = {0.75, 0.8, 0.85},
      --foamTexture =   "",
   },
   ...
}

float3f surfaceColor  default: {0.0, 0.0, 0.0} 

Effects the reflected colour.

FIXME: ?

Reflective and Refractive

FIXME: ?

Bump Mapped

Example
FIXME: need to place an image here
local mapinfo = {
   ...
   water = {
      ambientFactor  = 1.0,
      diffuseFactor  = 1.0,
      specularFactor = 1.0,
      specularPower  = 20.0,

      planeColor = {0.0, 0.4, 0.0},

      surfaceColor  = {0.75, 0.8, 0.85},
      surfaceAlpha  = 0.55,
      diffuseColor  = {1.0, 1.0, 1.0},
      specularColor = {0.5, 0.5, 0.5},

      fresnelMin   = 0.2,
      fresnelMax   = 0.8,
      fresnelPower = 4.0,

      reflectionDistortion = 1.0,

      blurBase      = 2.0,
      blurExponent = 1.5,

      perlinStartFreq  =  8.0,
      perlinLacunarity = 3.0,
      perlinAmplitude  =  0.9,
      windSpeed = 1.0, --// does nothing yet

      shoreWaves = true,

      --foamTexture =   "",
      --normalTexture = "",
      --caustics = {
      --   "",
      --   "",
      --},
      numTiles = 1,
      hasWaterPlane = true,

   },
   ...
}

FIXME: ?

Forum Discussions