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

From Bohemia Interactive Community
Jump to navigation Jump to search
m (ArmA:RVMAT moved to ArmA: RVMAT)
(No difference)

Revision as of 15:12, 27 June 2007

Material theory


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.

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

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)

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)

S = specular (setting of material glossines and specularity)

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.

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


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.

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


Material specularity is defined by a curve (WikiPedia: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.


Textures and materials are linked to each face separately so artist can have varios 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.

RVMAT files

Those files are a sort of configs.

Basic surface setting


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


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


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.

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 taht use also forcedDiffuse Alpha value setting for calculating how much light goes through (1= all).


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.


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.


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


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 * Enviroment ambient) 
+ (RVMAT diffuse * RGB texture * Enviroment diffuse * light direction) 
+ (RVMAT forced diffuse * RGB texture * Environment diffuse) 
+ RVMAT emisive materialu * RGB texture 
+ (RVMAT spekular * Environment diffuse * light direction)

Color values are usualy in 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 od eye/optics Aperture (shutter) settings [[1]].

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.

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.

Realistic surfaces usualy 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.

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.

If I want a specific color, I count:

X= B/(Sp*Db)

B.. desired collor of hotspot

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.

X ..number that i use to multiply Specular to get desired collor.

Render flags

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

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

Face is not count in Z-buffer. Used for alphatransparent surfaces layed over another faces to fix shadow artefacts. (for example squad logo)

  • NoColorWrite

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

  • NoAlphaWrite

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

  • AddBlend

Allows adding alphatransparent surface collor to the bacground. Used for fire particles.

  • LandShadow

For terrain.

  • AlphaTest32

Defines thereshold 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 phisics settings file.

  • mainLight
  • fogMode=FogAlpha

Setting for behavior in fog. Used for roads - surface diapears by modifiing also alpha chanel.

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

Shader specific setting

Selecting shader.


Each shader uses specific "Stages"

class StageX

Each stage define parameters for shader calculation, ususlay as links to efect bitmaps.

  • texture= (name and path to efect bitmap texture)
  • Filter="Anizotropic";

Default is Anizotropic, 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 ot texture in given UV set.

List of shaders

Pixel shaders:

Normal            /*diffuse color modulate, alpha replicate*/
NormalDXTA        /*diffuse color modulate, alpha replicate, DXT alpha correction*/
NormalMap         /*normal map shader*/
NormalMapThrough  /*normal map shader - through lighting*/
NormalMapSpecularThrough  /*normal map shader - through lighting*/
NormalMapGrass    /*normal map shader - through lighting*/
NormalMapDiffuse  /**/
NormalMapDetailSpecularMap // Simillar to NormalMapDiffuse 
NormalMapSpecularDIMap                  // Same as NormalMapSpecularMap, but uses _SMDI texture
Detail            /*detail texturing*/
Interpolation     /**/
Water             /*sea water*/
WaterSimple       /*small water*/
White             /**/
WhiteAlpha        /**/
AlphaShadow       /*shadow alpha write*/
AlphaNoShadow     /*shadow alpha (no shadow) write*/
Terrain           /**/
DetailMacroAS     /**/
Grass             /**Special shader to allow volumetric shadows casted on grass clutter**/

Vertex shaders:

Basic                 /*no extra info*/
NormalMap             /*normal map*/
NormalMapDiffuse      /*normal map + detail map*/
BasicAlpha            /*basic with per-vertex alpha*/
NormalMapAlpha        /*normal map with per-vertex alpha*/
NormalMapDiffuseAlpha /*normal map + detail map + per-vertex alpha*/
ShadowVolume          /*shadow volumes*/
Water                 /*per-vertex water animation*/
WaterSimple           /*per-vertex water animation (without foam)*/
Sprite                /*particle effects*/
Point                 /*anti-aliased points*/
NormalMapThrough      /*normal map - tree shader*/
NormalMapSpecularThrough /*normal map - tree shader*/
TerrainAlpha          /*terrain with alpha mask - based on VSNormalMapDiffuseAlpha*/
Terrain               /*one pass terrain, no alpha mask - based on VSNormalMapDiffuse*/
BasicAS               /*ambient shadow*/
NormalMapThroughNoFade         /*normal map - tree shader - without face fading*/\
NormalMapSpecularThroughNoFade /*normal map with specular - tree shader - without face fading*/\

Surface physical properties

RVMAT files are also used in geometry LODs for defining physical properties. It is done vial link to *.bisurf file.


Content of a *.bisurf definition:

// distance in mm that will bullet with speed 1000 m/s go until stops. Slowdown is calculated linear. 
thickness=10 // not implemented in ArmA
density=2500 // kg/m3, but it has actualy no real value to ArmA engine too