Difference between revisions of "ArmA: Armed Assault: RVMAT"

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Shadows)
m (Text replacement - ";[ ]+ " to "; ")
 
(32 intermediate revisions by 12 users not shown)
Line 1: Line 1:
 +
{{TOC|side}}
 
=== Material theory ===
 
=== Material theory ===
  
 
==== Lighting ====
 
==== Lighting ====
Lighting and shading is what makes 3D scene appealing. In realtime render we still have to simplify so Artist must understand how shading works in engine to be able prepair the best realistic looking surfaces.
+
Lighting and shading is what makes 3D scenes appealing. In realtime render we still have to simplify so Artist must understand how shading works in engine to be able to prepare the most realistic looking surfaces.
  
 
ArmA engine counts lighting as '''T * (D.o + A) + S.o'''
 
ArmA engine counts lighting as '''T * (D.o + A) + S.o'''
Line 8: Line 9:
 
T = texture color
 
T = texture color
  
D = diffuse lighting  (collor, intensity and direction. Engine has just one light source of directional light  - sun or moon.) D is calculated as max(L.N,0)*sunLightColor - where L is light direction, N is surface direction (normal)
+
D = diffuse lighting  (color, intensity and direction. Engine has just one light source of directional light  - sun or moon.) D is calculated as max(L.N,0)*sunLightColor - where L is light direction, N is surface direction (normal)
  
A = ambient lighting  (collor and intensity. It is allways present at same intensity all over the scene and its value is done by overcast setting)
+
A = ambient lighting  (color and intensity. It is always present at same intensity all over the scene and its value is done by overcast setting)
  
S = specular (setting of material glossines and specularity)
+
S = specular (setting of material glossiness and specularity)
  
 
o = direction of light (1= pixel is lit, 0= pixel is in shadow)
 
o = direction of light (1= pixel is lit, 0= pixel is in shadow)
  
Simple materials count lighting per vertex by interpolating ligt direction between face edges (normals). It is simillar to well known Gouraud shading model. More complex materials use per pixel normal orientation.
+
Simple materials count lighting per vertex by interpolating light direction between face edges (normals). It is similar to well known Gouraud shading model. More complex materials use per pixel normal orientation.
  
Values for shading calculations are combined from textures, efect bitmaps, engine light settings (config) and material settings (*.rvmat).
+
Values for shading calculations are combined from textures, effect bitmaps, engine light settings (config) and material settings (*.rvmat).
  
 
==== Shadows ====
 
==== Shadows ====
 
Shadows are calculated in ArmA engine two types, depending on values in Video options and each model setting.
 
Shadows are calculated in ArmA engine two types, depending on values in Video options and each model setting.
  
Stencil buffer shadows are sharp and they are added after the whole scene has bin drawn.  Engine just subtracts diffuse ligh value on plces where stenvil shadow volume appeared. This results in fact that speculars are still present in shadows. Also when ambient and difuse settings of the material are not equal (and ForceDiffuse!=0) result color is not correct.
+
Stencil buffer shadows are sharp and they are added after the whole scene has been drawn.  Engine just subtracts diffuse light value on places where stencil shadow volume appears. This results in fact that speculars are still present in shadows. Also when ambient and diffuse settings of the material are not equal (and ForceDiffuse!=0) result color is not correct.
  
 
Shadow buffer makes one soft shadow map calculated on GCard for whole scene from the viewport. This affects the precision of the shadow.
 
Shadow buffer makes one soft shadow map calculated on GCard for whole scene from the viewport. This affects the precision of the shadow.
 +
  
 
==== Glossiness ====
 
==== Glossiness ====
Material specularity is defined by a curve ([[WikiPedia:Bidirectional reflectance function]]) that says how much light is reflected under all angles. In FP engine we use SPECULAR POWER or IRRADIANCE TABLE values in *rvmat files.
+
Material specularity is defined by a curve ({{Wikipedia|Bidirectional_reflectance_function|Bidirectional reflectance function}}) that says how much light is reflected under all angles. In ArmA engine we use SPECULAR POWER or IRRADIANCE TABLE values in *rvmat files.
  
 
==== Sections ====
 
==== Sections ====
Textures and materials are linked to each face separately so artist can have varios materials on surface mapped with a single texture.  
+
Textures and materials are linked to each face separately so artist can have various materials on surface mapped with a single texture.  
  
Everytime when GCard is instructed to draw with new parameters, we call it scene section. It is usualy when appears new object (*.p3d), texture or material. This workload between GPU and CPU slows down rendering offten more than hundreds of new triangles.
+
Every time when GCard is instructed to draw with new parameters, we call it scene section. It is usually when appears new object (*.p3d), texture or material. This workload between GPU and CPU slows down rendering often more than hundreds of new triangles.
  
  
 
== RVMAT files ==
 
== RVMAT files ==
Those files are a sort of configs.  
+
Those files are a sort of config.  
  
 
=== Basic surface setting ===
 
=== Basic surface setting ===
  
  Ambient[]={0.9,0.9,0.9,1};  
+
  Ambient[]={0.9,0.9,0.9,1};
  
 
multiplies color values (color texture R,G,B,A) of the surface that is not lit by main directional light.  
 
multiplies color values (color texture R,G,B,A) of the surface that is not lit by main directional light.  
  
  Diffuse[]={0.9,0.9,0.9,1};  
+
  Diffuse[]={0.9,0.9,0.9,1};
  
multiplies color values of the surface that lit by main directional light.
+
multiplies color values of the surface that is lit by main directional light.
  
  ForcedDiffuse[]={0,0,0,0};  
+
  ForcedDiffuse[]={0,0,0,0};
those values help to simulate so called '''Transluency'''. Part of the diffuse lighting that is reflected on surface in shadow. It works simillar to ambient but wit different component of lighting. Unfortunately some shaders dont work well with forcedDiffuse.  
+
these values help to simulate so called '''Translucency'''. Part of the diffuse lighting that is reflected on surface in shadow. It works similar to ambient but with different component of lighting. Unfortunately some shaders don't work well with forcedDiffuse.  
  
 
  Ambient[]={1,1,1,1};
 
  Ambient[]={1,1,1,1};
  Diffuse[]={0.5,0.5,0.5,1};
+
  Diffuse[]={0.5,0.5,0.5,1};
  ForcedDiffuse {0.5,0.5,0.5,0}  
+
  ForcedDiffuse[]={0.5,0.5,0.5,0}  
 
This combination makes same result as old vertex property '''Half Lighted''' (surface is lit the same from all sides, it appears flat)
 
This combination makes same result as old vertex property '''Half Lighted''' (surface is lit the same from all sides, it appears flat)
  
For foliage surfaces there are special shaders taht use also forcedDiffuse Alpha value setting for calculating how much light goes through (1= all).  
+
For foliage surfaces there are special shaders that use also forcedDiffuse Alpha value setting for calculating how much light goes through (1= all).  
  
  emmisive[]={0,0,0,0};  
+
  emmisive[]={0,0,0,0};
Also called '''Luminiscence'''. Values give amount of light that surface shines by himself. Use it for lightsources. It will appeal shining but will not lit anything around.
+
Also called '''Luminescence'''. Values give amount of light that surface shines by itself. Use it for light sources. It will appeal shining but will not light anything around it.
  
  specular[]={0.3,0.3,0.3,0};  
+
  specular[]={0.3,0.3,0.3,0};
Used for making so called '''hotspot''' (in max it is Specular level+specular color). It is part of the light that is reflected from surface. Specular is calculated poer vertex or per pixel depending od specific shader.
+
Used for making so called '''hotspot''' (in max it is Specular level+specular color). It is part of the light that is reflected from surface. Specular is calculated per vertex or per pixel depending on specific shader.
  
 
  specularPower=40;
 
  specularPower=40;
Line 76: Line 78:
  
 
  '''pixel RGB on screen ='''  
 
  '''pixel RGB on screen ='''  
  ((RVMAT ambient * RGB texture * Enviroment ambient)  
+
  ((RVMAT ambient * RGB texture * Environment ambient)  
  + (RVMAT diffuse * RGB texture * Enviroment diffuse * light direction)  
+
  + (RVMAT diffuse * RGB texture * Environment diffuse * light direction)  
 
  + (RVMAT forced diffuse * RGB texture * Environment diffuse)  
 
  + (RVMAT forced diffuse * RGB texture * Environment diffuse)  
  + RVMAT emisive materialu * RGB texture  
+
  + RVMAT emissive material * RGB texture  
  + (RVMAT spekular * Environment diffuse * light direction)
+
  + (RVMAT specular * Environment diffuse * light direction)
  
Color values are usualy in range 0-1, but it can be more. FP engine calculates light in high dynamic range, with values exceeding 0-255 RGB depth. Final RGB in monitor is calculated for each frame depending od eye/optics Aperture (shutter) settings [[http://community.bistudio.com/wiki/setAperture]].
+
Color values are usually in the range 0-1, but it can be more. ArmA engine calculates light in high dynamic range, with values exceeding 0-255 RGB depth. Final RGB in monitor is calculated for each frame depending on eye/optics Aperture (shutter) settings [[setAperture]]/[[setApertureNew]].
  
Realistic surfaces do not reflect 100% of incoming light. The more light is reflected as specular the less diffuse it has. Sum of diffuse, forced diffuse and specular should not exceed 1.
+
Realistic surfaces do not reflect 100% of incoming light. The more light is reflected the less diffuse it has. Sum of diffuse, forced diffuse and reflected light should not exceed 1 BUT this is not true on ArmA realtime materials that do render just sunlight hotspot and miss environmental light - those would look too dark.  
  
Diffuse for many usual surfaces is between 40%-80%. If you aim for maximum realistic surface settings, study photoreference. RVMAT settings allow you to put as much color range as possible in texture and than modify it to realistic values with maximum dynamic range.
+
Diffuse for many usual surfaces is between 40%-80%. If you aim for maximum realistic surface settings, study photo reference. RVMAT settings allow you to put as much color range as possible in texture and then modify it to realistic values with maximum dynamic range.
  
Realistic surfaces usualy reflect directional and scattered light the same way - Diffuse and Ambient are equal. FP engine has environment settings with values for diffuse and ambient (scene contrast) based on real world light recording. [[Kalibrace barev (Color Calibration)]]. It is not wise to compensate contrast in material settings.  
+
Realistic surfaces usually reflect directional and scattered light the same way - Diffuse and Ambient are equal. ArmA engine has environment settings with values for diffuse and ambient (scene contrast) based on real world light recording. It is not wise to compensate contrast in material settings.  
  
Lower diffuse values are used for spongy materials (some light is transfered to forceDiffuse). Lower ambient values can be used on surfaces where global ambient should be reduced, such as Interiors. It is usualy made using Ambient Light maps.
+
Lower diffuse values are used for spongy materials (some light is transferred to forceDiffuse). Lower ambient values can be used on surfaces where global ambient should be reduced, such as Interiors. It is usually made using Ambient Light maps.
  
  
 
==== Specular color ====
 
==== Specular color ====
  
Usualy we set RGB values collor neutral. But sometimes it is efective to tint color in rvmat. Most obvious it is in specular settings of some glossy metal surfaces.  
+
Usually we set RGB values color neutral. But sometimes it is effective to tint color in rvmat. Most obvious it is in specular settings of some glossy metal surfaces.  
  
 
If I want a specific color, I count:
 
If I want a specific color, I count:
Line 101: Line 103:
 
'''X= B/(Sp*Db)'''
 
'''X= B/(Sp*Db)'''
  
'''B'''.. desired collor of hotspot
+
'''B'''.. desired color of hotspot
  
 
'''Sp'''.. actual Specular setting of material
 
'''Sp'''.. actual Specular setting of material
  
'''Db'''.. collor of environment light (Ambient and Difuse change during day and overcast) O2 environment editor shows actual collors used in buldiozer preview.
+
'''Db'''.. color of environment light (Ambient and Diffuse change during day and overcast) O2 environment editor shows actual colors used in buldozer preview.
  
'''X''' ..number that i use to multiply Specular to get desired collor.
+
'''X''' ..number that I use to multiply Specular to get desired color.
  
 
=== Render flags ===
 
=== Render flags ===
  
Special shading property that are used instead of old VERTEX LIGHTING PROPERTY settings.
+
Special shading properties that are used instead of old VERTEX LIGHTING PROPERTY settings.
  
  renderFlags[] = {flag,flag};  
+
  renderFlags[] = {flag,flag};
  
 
* '''NoZWrite'''  
 
* '''NoZWrite'''  
Face is not count in Z-buffer. Used for alphatransparent surfaces layed over another faces to fix shadow artefacts. (for example squad logo)
+
Face is not counted in Z-buffer. Used for alpha transparent surfaces laid over another face to fix shadow artefacts. (for example squad logo)
 
   
 
   
 
* '''NoColorWrite'''  
 
* '''NoColorWrite'''  
Disables calculation in color chanels. Face is calculated just in alpha and Z-buffer.
+
Disables calculation in color channels. Face is calculated just in alpha and Z-buffer.
  
 
* '''NoAlphaWrite'''  
 
* '''NoAlphaWrite'''  
Disables calculation in alpha chanels. Used for transparent glass that has 2 pass material.
+
Disables calculation in alpha channels. Used for transparent glass that has 2 pass material.
  
 
* '''AddBlend'''
 
* '''AddBlend'''
Allows adding alphatransparent surface collor to the bacground. Used for fire particles.  
+
Allows adding alpha transparent surface color to the background. Used for fire particles.  
  
 
* '''LandShadow'''
 
* '''LandShadow'''
Line 131: Line 133:
  
 
* '''AlphaTest32'''
 
* '''AlphaTest32'''
Defines thereshold where pixel becomes transparent at drop off to discrete alpha. The bigger value, the more pixels are used (Alphatest64, Alphatest128)
+
Defines threshold where pixel becomes transparent at drop off to discrete alpha. The bigger value, the more pixels are used (Alphatest64, Alphatest128)
  
* surfaceInfo="data\wood.bisurf";  
+
* surfaceInfo="data\wood.bisurf";
Link to surface phisics settings file.  
+
Link to surface physics settings file.  
  
 
* '''mainLight'''  
 
* '''mainLight'''  
  
 
* '''fogMode=FogAlpha'''   
 
* '''fogMode=FogAlpha'''   
Setting for behavior in fog. Used for roads - surface diapears by modifiing also alpha chanel.  
+
Setting for behaviour in fog. Used for roads - surface disappears by modifying also the alpha channel.  
  
'''Always in Shadow''' can be archieved with setting RVMAT diffuse[]={0,0,0,0} + reasonable specular reduction.
+
'''Always in Shadow''' can be achieved with setting RVMAT diffuse[]={0,0,0,0} + reasonable specular reduction.
  
 
=== Shader specific setting ===
 
=== Shader specific setting ===
Line 154: Line 156:
 
  class StageX
 
  class StageX
  
Each stage define parameters for shader calculation, ususlay as links to efect bitmaps.
+
Each stage defines parameters for shader calculation, usually as links to effect bitmaps.
  
* texture= (name and path to efect bitmap texture)
+
* texture= (name and path to effect bitmap texture)
Must obey texture naming conventions [[Konvence_pojmenov%C3%A1n%C3%AD_textur_%28Texture_Naming_Conventions%29]] otherwise there will be not proper automatic conversion made from TGA to PAA.
 
  
* Filter="Anizotropic";
+
* Filter="Anisotropic";
Default is Anizotropic, but in some situations you can use Point, Linear, Trilinear.
+
Default is Anisotropic, but in some situations you can use Point, Linear, Trilinear.
  
* uvSource="tex";  
+
* uvSource="tex";
 
can be: none, tex, tex1 (second UV set)
 
can be: none, tex, tex1 (second UV set)
  
 
* class uvTransform
 
* class uvTransform
Offset, deformation or repeating ot texture in given UV set.
+
Offset, deformation or repeating of texture in given UV set.
 +
 
 +
== List of shaders ==
 +
 
 +
Pixel shaders:
 +
 
 +
{| class="wikitable"
 +
|+
 +
|-
 +
| AlphaNoShadow || Shadow alpha (no shadow) write
 +
|-
 +
| AlphaShadow || Shadow alpha write
 +
|-
 +
| Detail || Detail texturing
 +
|-
 +
| DetailMacroAS ||
 +
|-
 +
| Grass || Special shader to allow volumetric shadows to be cast on grass clutter
 +
|-
 +
| Interpolation ||
 +
|-
 +
| Normal || Diffuse color modulate, alpha replicate
 +
|-
 +
| NormalDXTA || Diffuse color modulate, alpha replicate, DXT alpha correction
 +
|-
 +
| NormalMap || Normal map shader
 +
|-
 +
| NormalMapDetailMacroASSpecularDIMap ||
 +
|-
 +
| NormalMapDetailMacroASSpecularMap ||
 +
|-
 +
| NormalMapDetailSpecularDIMap ||
 +
|-
 +
| NormalMapDetailSpecularMap || Similar to NormalMapDiffuse
 +
|-
 +
| NormalMapDiffuse ||
 +
|-
 +
| NormalMapDiffuseMacroAS ||
 +
|-
 +
| NormalMapGrass || Normal map shader - through lighting
 +
|-
 +
| NormalMapMacroAS ||
 +
|-
 +
| NormalMapMacroASSpecularDIMap ||
 +
|-
 +
| NormalMapMacroASSpecularMap ||
 +
|-
 +
| NormalMapSpecularDIMap || Same as NormalMapSpecularMap, but uses _SMDI texture
 +
|-
 +
| NormalMapSpecularMap ||
 +
|-
 +
| NormalMapSpecularThrough || Normal map shader - through lighting
 +
|-
 +
| NormalMapThrough || Normal map shader - through lighting
 +
|-
 +
| Refract || Refraction textures
 +
|-
 +
| SpriteRefract || Refraction in particle effects
 +
|-
 +
| Terrain ||
 +
|-
 +
| Water || Sea water
 +
|-
 +
| WaterSimple || Small water
 +
|-
 +
| White ||
 +
|-
 +
| WhiteAlpha ||
 +
|}
 +
 
 +
Vertex shaders:
 +
 
 +
{| class="wikitable"
 +
|+
 +
|-
 +
| Basic || No extra info
 +
|-
 +
| BasicAlpha || Basic with per-vertex alpha
 +
|-
 +
| BasicAS || Ambient shadow
 +
|-
 +
| NormalMap || Normal map
 +
|-
 +
| NormalMapAlpha || Normal map with per-vertex alpha
 +
|-
 +
| NormalMapAS ||
 +
|-
 +
| NormalMapDiffuse || Normal map + detail map
 +
|-
 +
| NormalMapDiffuseAlpha || Normal map + detail map + per-vertex alpha
 +
|-
 +
| NormalMapDiffuseAS ||
 +
|-
 +
| NormalMapSpecularThrough || Normal map - tree shader
 +
|-
 +
| NormalMapSpecularThroughNoFade || Normal map with specular - tree shader - without face fading
 +
|-
 +
| NormalMapThrough || Normal map - tree shader
 +
|-
 +
| NormalMapThroughNoFade || Normal map - tree shader - without face fading
 +
|-
 +
| Point || Anti-aliased points
 +
|-
 +
| ShadowVolume || Shadow volumes
 +
|-
 +
| Sprite || Particle effects
 +
|-
 +
| Super || Used for glass
 +
|-
 +
| Terrain || One pass terrain, no alpha mask - based on VSNormalMapDiffuse
 +
|-
 +
| TerrainAlpha || terrain with alpha mask - based on VSNormalMapDiffuseAlpha
 +
|-
 +
| Water || Per-vertex water animation
 +
|-
 +
| WaterSimple || Per-vertex water animation (without foam)
 +
|}
 +
 
 +
Every specific type of material uses fixed combination of vertex and pixel shader with fixed stage numbers and type of texture. Use Material Templates in O2PE Material editor or check *.rvmat files in BI models.
  
===Phisical properties===
+
== Surface physical properties ==
  
RVMAT files are also used in geometry LODs for defining phisical properties.
+
RVMAT files are also used in geometry LODs for defining physical properties (the idea behind this is to be able to use one set of physical material definitions on many different surfaces that may still have different visual representation). It is done via a link to *.bisurf file.  
It is done vial link to *.bisurf file.  
 
  
 
  '''surfaceInfo='''"data\wood.bisurf";
 
  '''surfaceInfo='''"data\wood.bisurf";
  
 
Content of a '''*.bisurf''' definition:
 
Content of a '''*.bisurf''' definition:
 
+
   
'''density='''2500 ''// kg/m3''  
 
 
  '''rough='''0.1;
 
  '''rough='''0.1;
 
  '''dust='''0.1;
 
  '''dust='''0.1;
 
  '''bulletPenetrability='''150; ''
 
  '''bulletPenetrability='''150; ''
  // distance in mm that will bullet with speed 1000 m/s go until stops. Slowdown is calculated linear.  
+
  // distance in mm that a bullet with speed 1000 m/s go until it stops. Slowdown is calculated linear.  
 
  '''soundEnviron='''Empty;
 
  '''soundEnviron='''Empty;
 
  '''isWater='''false;
 
  '''isWater='''false;
 
  '''thickness='''10 ''// not implemented in ArmA
 
  '''thickness='''10 ''// not implemented in ArmA
 +
'''density='''2500 ''// kg/m3, but it has actually no real value to ArmA engine too''
 +
 +
== See Also ==
 +
[[Material_templates]] - Arma2 rvmat information for common surface types.
 +
 +
[[Bullet_penetrability]] - Arma2 information on how penetration works.
 +
 +
{{GameCategory|arma1|Addon Editing}}

Latest revision as of 00:55, 8 August 2021

Material theory

Lighting

Lighting and shading is what makes 3D scenes appealing. In realtime render we still have to simplify so Artist must understand how shading works in engine to be able to prepare the most realistic looking surfaces.

ArmA engine counts lighting as T * (D.o + A) + S.o

T = texture color

D = diffuse lighting (color, intensity and direction. Engine has just one light source of directional light - sun or moon.) D is calculated as max(L.N,0)*sunLightColor - where L is light direction, N is surface direction (normal)

A = ambient lighting (color and intensity. It is always present at same intensity all over the scene and its value is done by overcast setting)

S = specular (setting of material glossiness and specularity)

o = direction of light (1= pixel is lit, 0= pixel is in shadow)

Simple materials count lighting per vertex by interpolating light direction between face edges (normals). It is similar to well known Gouraud shading model. More complex materials use per pixel normal orientation.

Values for shading calculations are combined from textures, effect bitmaps, engine light settings (config) and material settings (*.rvmat).

Shadows

Shadows are calculated in ArmA engine two types, depending on values in Video options and each model setting.

Stencil buffer shadows are sharp and they are added after the whole scene has been drawn. Engine just subtracts diffuse light value on places where stencil shadow volume appears. This results in fact that speculars are still present in shadows. Also when ambient and diffuse settings of the material are not equal (and ForceDiffuse!=0) result color is not correct.

Shadow buffer makes one soft shadow map calculated on GCard for whole scene from the viewport. This affects the precision of the shadow.


Glossiness

Material specularity is defined by a curve (Bidirectional reflectance function) that says how much light is reflected under all angles. In ArmA engine we use SPECULAR POWER or IRRADIANCE TABLE values in *rvmat files.

Sections

Textures and materials are linked to each face separately so artist can have various materials on surface mapped with a single texture.

Every time when GCard is instructed to draw with new parameters, we call it scene section. It is usually when appears new object (*.p3d), texture or material. This workload between GPU and CPU slows down rendering often more than hundreds of new triangles.


RVMAT files

Those files are a sort of config.

Basic surface setting

Ambient[]={0.9,0.9,0.9,1};

multiplies color values (color texture R,G,B,A) of the surface that is not lit by main directional light.

Diffuse[]={0.9,0.9,0.9,1};

multiplies color values of the surface that is lit by main directional light.

ForcedDiffuse[]={0,0,0,0};

these values help to simulate so called Translucency. Part of the diffuse lighting that is reflected on surface in shadow. It works similar to ambient but with different component of lighting. Unfortunately some shaders don't work well with forcedDiffuse.

Ambient[]={1,1,1,1};
Diffuse[]={0.5,0.5,0.5,1};
ForcedDiffuse[]={0.5,0.5,0.5,0} 

This combination makes same result as old vertex property Half Lighted (surface is lit the same from all sides, it appears flat)

For foliage surfaces there are special shaders that use also forcedDiffuse Alpha value setting for calculating how much light goes through (1= all).

emmisive[]={0,0,0,0};

Also called Luminescence. Values give amount of light that surface shines by itself. Use it for light sources. It will appeal shining but will not light anything around it.

specular[]={0.3,0.3,0.3,0};

Used for making so called hotspot (in max it is Specular level+specular color). It is part of the light that is reflected from surface. Specular is calculated per vertex or per pixel depending on specific shader.

specularPower=40;

Also called Glossiness. Defines how sharp the hotspot will be. Some shaders use IRRADIANCE TABLE instead of this value.

MaterialSettings.jpg


All above mentioned settings can be calculated in some shaders per pixel using effect bitmaps.

All components are together used in calculation of surface shading:

pixel RGB on screen = 
((RVMAT ambient * RGB texture * Environment ambient) 
+ (RVMAT diffuse * RGB texture * Environment diffuse * light direction) 
+ (RVMAT forced diffuse * RGB texture * Environment diffuse) 
+ RVMAT emissive material * RGB texture 
+ (RVMAT specular * Environment diffuse * light direction)

Color values are usually in the range 0-1, but it can be more. ArmA engine calculates light in high dynamic range, with values exceeding 0-255 RGB depth. Final RGB in monitor is calculated for each frame depending on eye/optics Aperture (shutter) settings setAperture/setApertureNew.

Realistic surfaces do not reflect 100% of incoming light. The more light is reflected the less diffuse it has. Sum of diffuse, forced diffuse and reflected light should not exceed 1 BUT this is not true on ArmA realtime materials that do render just sunlight hotspot and miss environmental light - those would look too dark.

Diffuse for many usual surfaces is between 40%-80%. If you aim for maximum realistic surface settings, study photo reference. RVMAT settings allow you to put as much color range as possible in texture and then modify it to realistic values with maximum dynamic range.

Realistic surfaces usually reflect directional and scattered light the same way - Diffuse and Ambient are equal. ArmA engine has environment settings with values for diffuse and ambient (scene contrast) based on real world light recording. It is not wise to compensate contrast in material settings.

Lower diffuse values are used for spongy materials (some light is transferred to forceDiffuse). Lower ambient values can be used on surfaces where global ambient should be reduced, such as Interiors. It is usually made using Ambient Light maps.


Specular color

Usually we set RGB values color neutral. But sometimes it is effective to tint color in rvmat. Most obvious it is in specular settings of some glossy metal surfaces.

If I want a specific color, I count:

X= B/(Sp*Db)

B.. desired color of hotspot

Sp.. actual Specular setting of material

Db.. color of environment light (Ambient and Diffuse change during day and overcast) O2 environment editor shows actual colors used in buldozer preview.

X ..number that I use to multiply Specular to get desired color.

Render flags

Special shading properties that are used instead of old VERTEX LIGHTING PROPERTY settings.

renderFlags[] = {flag,flag};
  • NoZWrite

Face is not counted in Z-buffer. Used for alpha transparent surfaces laid over another face to fix shadow artefacts. (for example squad logo)

  • NoColorWrite

Disables calculation in color channels. Face is calculated just in alpha and Z-buffer.

  • NoAlphaWrite

Disables calculation in alpha channels. Used for transparent glass that has 2 pass material.

  • AddBlend

Allows adding alpha transparent surface color to the background. Used for fire particles.

  • LandShadow

For terrain.

  • AlphaTest32

Defines threshold where pixel becomes transparent at drop off to discrete alpha. The bigger value, the more pixels are used (Alphatest64, Alphatest128)

  • surfaceInfo="data\wood.bisurf";

Link to surface physics settings file.

  • mainLight
  • fogMode=FogAlpha

Setting for behaviour in fog. Used for roads - surface disappears by modifying also the alpha channel.

Always in Shadow can be achieved with setting RVMAT diffuse[]={0,0,0,0} + reasonable specular reduction.

Shader specific setting

Selecting shader.

PixelShaderID=".....";
VertexShaderID=".....";

Each shader uses specific "Stages"

class StageX

Each stage defines parameters for shader calculation, usually as links to effect bitmaps.

  • texture= (name and path to effect bitmap texture)
  • Filter="Anisotropic";

Default is Anisotropic, but in some situations you can use Point, Linear, Trilinear.

  • uvSource="tex";

can be: none, tex, tex1 (second UV set)

  • class uvTransform

Offset, deformation or repeating of texture in given UV set.

List of shaders

Pixel shaders:

AlphaNoShadow Shadow alpha (no shadow) write
AlphaShadow Shadow alpha write
Detail Detail texturing
DetailMacroAS
Grass Special shader to allow volumetric shadows to be cast on grass clutter
Interpolation
Normal Diffuse color modulate, alpha replicate
NormalDXTA Diffuse color modulate, alpha replicate, DXT alpha correction
NormalMap Normal map shader
NormalMapDetailMacroASSpecularDIMap
NormalMapDetailMacroASSpecularMap
NormalMapDetailSpecularDIMap
NormalMapDetailSpecularMap Similar to NormalMapDiffuse
NormalMapDiffuse
NormalMapDiffuseMacroAS
NormalMapGrass Normal map shader - through lighting
NormalMapMacroAS
NormalMapMacroASSpecularDIMap
NormalMapMacroASSpecularMap
NormalMapSpecularDIMap Same as NormalMapSpecularMap, but uses _SMDI texture
NormalMapSpecularMap
NormalMapSpecularThrough Normal map shader - through lighting
NormalMapThrough Normal map shader - through lighting
Refract Refraction textures
SpriteRefract Refraction in particle effects
Terrain
Water Sea water
WaterSimple Small water
White
WhiteAlpha

Vertex shaders:

Basic No extra info
BasicAlpha Basic with per-vertex alpha
BasicAS Ambient shadow
NormalMap Normal map
NormalMapAlpha Normal map with per-vertex alpha
NormalMapAS
NormalMapDiffuse Normal map + detail map
NormalMapDiffuseAlpha Normal map + detail map + per-vertex alpha
NormalMapDiffuseAS
NormalMapSpecularThrough Normal map - tree shader
NormalMapSpecularThroughNoFade Normal map with specular - tree shader - without face fading
NormalMapThrough Normal map - tree shader
NormalMapThroughNoFade Normal map - tree shader - without face fading
Point Anti-aliased points
ShadowVolume Shadow volumes
Sprite Particle effects
Super Used for glass
Terrain One pass terrain, no alpha mask - based on VSNormalMapDiffuse
TerrainAlpha terrain with alpha mask - based on VSNormalMapDiffuseAlpha
Water Per-vertex water animation
WaterSimple Per-vertex water animation (without foam)

Every specific type of material uses fixed combination of vertex and pixel shader with fixed stage numbers and type of texture. Use Material Templates in O2PE Material editor or check *.rvmat files in BI models.

Surface physical properties

RVMAT files are also used in geometry LODs for defining physical properties (the idea behind this is to be able to use one set of physical material definitions on many different surfaces that may still have different visual representation). It is done via a link to *.bisurf file.

surfaceInfo="data\wood.bisurf";

Content of a *.bisurf definition:

rough=0.1;
dust=0.1;
bulletPenetrability=150; 
// distance in mm that a bullet with speed 1000 m/s go until it stops. Slowdown is calculated linear. 
soundEnviron=Empty;
isWater=false;
thickness=10 // not implemented in ArmA
density=2500 // kg/m3, but it has actually no real value to ArmA engine too

See Also

Material_templates - Arma2 rvmat information for common surface types.

Bullet_penetrability - Arma2 information on how penetration works.