Static Environmental Reflections: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (→‎IOR table: fixed table)
m (Text replacement - "[[Image:" to "[[File:")
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
====Description====
{{Feature|informative|Published mainly for compatibility reason as SuperShader (including environmental map/fresnel) replaces this functionality.}}


''published mainly for compatibility reason as SuperShader (includes environmental map/fresnel) replacing 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.
 
This technology allows show environmental reflections on materials.Environment is static what only changes is only it is 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:
Environmental map may looks like this:


[[Image:EnvironmentalMap.jpg]]
[[File:EnvironmentalMap.jpg]]


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


====New shader for glass====
==== New shader for glass ====
 
[[File:Glass.jpg|Sklo]]
[[Image:Glass.jpg|Sklo]]


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.
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.
Line 25: Line 22:
Whole material for glass may look like this (it's good in future use second pass - here it is left out only for simplicity):
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};
<syntaxhighlight lang="cpp">
specular[]={1,1,1,0};
renderFlags[] = { NoAlphaWrite };
specularPower=5;
specular[] = { 1,1,1,0 };
PixelShaderID="Glass";
specularPower = 5;
VertexShaderID="Glass";
PixelShaderID = "Glass";
class Stage1
VertexShaderID = "Glass";
{
class Stage1
  texture="#(ai,64,64,1)fresnelGlass()";
{
  uvSource="none";
texture = "#(ai,64,64,1)fresnelGlass()";
};
uvSource = "none";
class Stage2
};
{
class Stage2
  texture="env_co.tga";
{
  uvSource="none";
texture = "env_co.tga";
};
uvSource = "none";
};
</syntaxhighlight>


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'').
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===
=== Imaging formula ===


Specular portion of imaging formula equation got following form:
Specular portion of imaging formula equation got following form:


<code>S = (ligthS * matS * (H.N)^P + envS * matS) * lerp(1, tD.rgb, tD.a)</code>
<code style="display: block">S = (lightS * matS * (H.N)^P + envS * matS) * lerp(1, tD.rgb, tD.a)</code>


,where ligthS is light color, envS is value from environmental map, matS is specular value from material, tD is value of basic (diffuse) texture.
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 ===
=== IOR table ===
{| class = "wikitable sortable"
 
! MATERIAL !! Index
{| class="wikitable sortable"
! Material
! Index
|-
|-
|Vacuum  
| Vacuum  
|1.00000 (exactly)
| 1.00000 (exactly)
|-
|-
|Air (STP)  
| Air (STP)  
|1.00029
| 1.00029
|-
|-
|Acetone  
| Acetone  
|1.36
| 1.36
|-
|-
|Alcohol  
| Alcohol  
|1.329
| 1.329
|-
|-
|Amorphous Selenium
| Amorphous Selenium
|2.92
| 2.92
|-
|-
|Calspar1
| Calspar1
|1.66
| 1.66
|-
|-
|Calspar2  
| Calspar2  
|1.486
| 1.486
|-
|-
|Carbon Disulfide
| Carbon Disulfide
|1.63
| 1.63
|-
|-
|Chromium Oxide
| Chromium Oxide
|2.705
| 2.705
|-
|-
|Copper Oxide
| Copper Oxide
|2.705
| 2.705
|-
|-
|Crown Glass
| Crown Glass
|1.52
| 1.52
|-
|-
|Crystal
| Crystal
|2.00
| 2.00
|-
|-
|Diamond  
| Diamond  
|2.417
| 2.417
|-
|-
|Emerald
| Emerald
|1.57
| 1.57
|-
|-
|Ethyl Alcohol
| Ethyl Alcohol
|1.36
| 1.36
|-
|-
|Flourite  
| Flourite  
|1.434
| 1.434
|-
|-
|Fused Quartz
| Fused Quartz
|1.46
| 1.46
|-
|-
|Heaviest Flint Glass
| Heaviest Flint Glass
|1.89
| 1.89
|-
|-
|Heavy Flint Glass
| Heavy Flint Glass
|1.65
| 1.65
|-
|-
|Glass
| Glass
|1.5
| 1.5
|-
|-
|Ice
| Ice
|1.309
| 1.309
|-
|-
|Iodine Crystal
| Iodine Crystal
|3.34
| 3.34
|-
|-
|Lapis Lazuli
| Lapis Lazuli
|1.61
| 1.61
|-
|-
|Light Flint Glass
| Light Flint Glass
|1.575
| 1.575
|-
|-
|Liquid Carbon Dioxide
| Liquid Carbon Dioxide
|1.20
| 1.20
|-
|-
|Polystyrene
| Polystyrene
|1.55
| 1.55
|-
|-
|Quartz 1
| Quartz 1
|1.644
| 1.644
|-
|-
|Quartz 2
| Quartz 2
|1.553
| 1.553
|-
|-
|Ruby
| Ruby
|1.77
| 1.77
|-
|-
|Sapphire
| Sapphire
|1.77
| 1.77
|-
|-
|Sodium Chloride (Salt) 1  
| Sodium Chloride (Salt) 1  
|1.544
| 1.544
|-
|-
|Sodium Chloride (Salt) 2
| Sodium Chloride (Salt) 2
|1.644
| 1.644
|-
|-
|Sugar Solution (30%)
| Sugar Solution (30%)
|1.38
| 1.38
|-
|-
|Sugar Solution (80%)
| Sugar Solution (80%)
|1.49
| 1.49
|-
|-
|Topaz
| Topaz
|1.61
| 1.61
|-
|-
|Water (20 C)
| Water (20 C)
|1.333
| 1.333
|-
|-
|Zinc Crown Glass
| Zinc Crown Glass
|1.517
| 1.517
|}


|-
{{GameCategory|arma2|Editing}}
|}

Latest revision as of 23:11, 20 November 2023

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:

EnvironmentalMap.jpg

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

New shader for glass

Sklo

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.

#(ai,64,64,1)fresnelGlass()

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

#(ai,64,64,1)fresnelGlass(1.9)

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