Static Environmental Reflections

From Bohemia Interactive Community
Revision as of 20:50, 16 July 2021 by Lou Montana (talk | contribs) (Some wiki formatting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Published mainly for compatibility reason as SuperShader (including environmental map/fresnel) replaces this functionality.

This technology allows show environmental reflections on materials.Environment is static what only changes is only its lighting accordingly to time of day.Environment is characterized by texture which is called environmental map.In our case environmental map presents hemisphere projection into plane.

Environmental map may looks like this:


For use gradually ensue set of shaders which will use environmental map.

New shader for glass


New shader was made which can work with environmental map.It's used for glass sheets.On input it has besides environmental map also lookup texture for fresnel equations.Is it possible to generate fresnel texture inside TexView2 with use of code. Yet it is easier to use procedural texture.


In this case is used index of refraction 1.7 - common glass. It's possible to enter it as parameter:


Whole material for glass may look like this (it's good in future use second pass - here it is left out only for simplicity):

renderFlags[] = { NoAlphaWrite };
specular[] = { 1,1,1,0 };
specularPower = 5;
PixelShaderID = "Glass";
VertexShaderID = "Glass";
class Stage1
	texture = "#(ai,64,64,1)fresnelGlass()";
	uvSource = "none";
class Stage2
	texture = "env_co.tga";
	uvSource = "none";

If very low value (0) appears inside alpha within basic glass texture then whole texel cease to draw (nothing will reflect in that spot and it will look like hole in glass).

Imaging formula

Specular portion of imaging formula equation got following form:

S = (lightS * matS * (H.N)^P + envS * matS) * lerp(1, tD.rgb, tD.a)

where lightS is light color, envS is value from environmental map, matS is specular value from material, tD is value of basic (diffuse) texture.

IOR table

Material Index
Vacuum 1.00000 (exactly)
Air (STP) 1.00029
Acetone 1.36
Alcohol 1.329
Amorphous Selenium 2.92
Calspar1 1.66
Calspar2 1.486
Carbon Disulfide 1.63
Chromium Oxide 2.705
Copper Oxide 2.705
Crown Glass 1.52
Crystal 2.00
Diamond 2.417
Emerald 1.57
Ethyl Alcohol 1.36
Flourite 1.434
Fused Quartz 1.46
Heaviest Flint Glass 1.89
Heavy Flint Glass 1.65
Glass 1.5
Ice 1.309
Iodine Crystal 3.34
Lapis Lazuli 1.61
Light Flint Glass 1.575
Liquid Carbon Dioxide 1.20
Polystyrene 1.55
Quartz 1 1.644
Quartz 2 1.553
Ruby 1.77
Sapphire 1.77
Sodium Chloride (Salt) 1 1.544
Sodium Chloride (Salt) 2 1.644
Sugar Solution (30%) 1.38
Sugar Solution (80%) 1.49
Topaz 1.61
Water (20 C) 1.333
Zinc Crown Glass 1.517