武装突袭 Wiki

RVMAT basics

简体 | 繁體

评论0 分享




Theory 编辑

Lighting 编辑

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

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

T = texture color

D = diffuse lighting (color, intensity and direction. ARMA 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 appeared. This results in speculars still being present in shadows. Also when ambient and diffuse settings of the material aren't equal (and ForceDiffuse!=0) then resulting color isn't 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 ([WikiPedia:Bidirectional reflectance function]) that says how much light is reflected under all angles. In ARMA engine we are able to use SPECULAR POWER, IRRADIANCE TABLE or FRESNEL 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.

Everytime when Graphics Card (GPU) is instructed to draw with new parameters, we call it scene section. It is usually when new object (*.p3d), texture or material appears. Sections are generated each time when there is need to change paramaters for rendering on Graphical Card (GPU). This is always when loading informations from CPU about independent OBJECT, TEXTURE, MATERIAL or bone limit is exceeded on the card. Overhead in instruction transfer between CPU and GPU then lowers rendering performance which could be used to render hundreds polygons or textures etc.

Texture (TGA) is assigned to individual faces. Material (RVMAT) is assigned to same faces separately thus it's possible use various materials on surface covered with one UV and CO map. Yet then are generated another sections. In STAGE 0 is possible change with RVMAT also difusse component texture. Sections may differ in individual LODs.

Procedural textures 编辑

Besides TGA/PAA textures ARMA engine can work with maps generated in real-time procedurally. Procedural Textures

Normal Map 编辑

The Normalmaps used in Arma are Tangent-space maps with the orientation X+ Y- (same as in Unreal Engine and 3dsmax renderer default setting)

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 Translucency. Part of the diffuse lighting that is reflected on surface in shadow. It works similar to ambient but wit different component of lighting. Unfortunately some shaders don't 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 that use also forcedDiffuse Alpha value setting for calculating how much light goes through (1= all).


Also called Luminescence. Values give amount of light that surface shines by himself. Use it for light-sources. 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 hot-spot 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 * 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 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 reflected light should not exceed 1 BUT this is not true on ArmA real-time materials that do render just sunlight hot-spot and miss environmental light.

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 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. Color Calibration. 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 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 hot-spot

Sp.. actual Specular setting of hot-spotmaterial

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 property that are used instead of old VERTEX LIGHTING PROPERTY settings.

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

Face is not count in Z-buffer. Used for alpha-transparent surfaces laid over another faces to fix shadow artifacts. (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

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

Fog Mode 编辑

Setting of various kinds of fog calculation:


Possible values are:

  • fog - fog used by usual opaque object, the more is object covered by fog, the closer is it's color to fog color
  • alpha - fog used by objects with alpha, the more is object covered by fog, the more transparent is
  • fogAlpha - combination of both above approaches, used for roads (alpha-out could be quicker than fogging)

combination of both approaches, used for roads, way to fade-away objects when object is not just normally fogging

  • none - no fog

Shader specific setting 编辑

Selecting shader.


Each shader uses specific "Stages"

class StageX

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

  • texture= (name and path to effect bitmap texture)

Must obey texture naming conventions Texture Naming Conventions otherwise there will be no proper automatic conversion made from TGA to PAA.

  • 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.

Material types 编辑

Inside O2 Material editor exist examples for most of shaders. Oxygen_2_-_Manual#MAT_plugin

Wikipage Vertex shader Pixel shader Notes
Material - General material Basic Normal
Material - DXTA material Basic NormalDXTA
Material - Basic detail map Basic Detail
Basic White
Basic WhiteAlpha
Material - Basic glass Basic AlphaShadow
Material - Normal map NormalMap NormalMap
Material - Normal map HQ specular NormalMap NormalMapSpecularMap NOHQ+SM
NormalMap NormalMapSpecularDIMap NOHQ+SMDI
Material - Normal map HQ detail map specular NormalMap NormalMapDetailSpecularMap NOHQ+DT+SM
NormalMap NormalMapDetailSpecularDIMap NOHQ+SMDI+DT
Material - Basic normal detail NormalMapDiffuse NormalMapDiffuse NormalMapDetail, per vertex lit
Water Water
Material - Water simple WaterSimple WaterSimple
NormalMapThrough NormalMapThrough
NormalMapThrough NormalMapThroughSimple
Material - Basic Tree crown NormalMapSpecularThrough NormalMapSpecularThrough TreeCrown colormap must be with continuous alpha
NormalMapSpecularThrough NormalMapSpecularThroughSimple
NormalMapThroughNoFade NormalMapThrough
NormalMapThroughNoFade NormalMapThroughSimple
NormalMapSpecularThroughNoFade NormalMapSpecularThrough
NormalMapSpecularThroughNoFade NormalMapSpecularThroughSimple
Material - Detail macro AS BasicAS DetailMacroAS DT+MC+AS
Material - Normal map macro AS NormalMapAS NormalMapMacroAS
Material - Normal map HQ specular macro AS NormalMapAS NormalMapMacroASSpecularMap NOHQ+MC+AS+SM
NormalMapAS NormalMapMacroASSpecularDIMap NOHQ+SMDI+MC+AS
Material - Normal map HQ detail specular macro AS NormalMapAS NormalMapDetailMacroASSpecularMap NOHQ+DT+MC+AS+SM
NormalMapAS NormalMapDetailMacroASSpecularDIMap NOHQ+SMDI+DT+MC+AS
Material - Normal map detail macro AS NormalMapDiffuseAS NormalMapDiffuseMacroAS NO+DT+MC+AS
Material - Basic glass reflectance Glass Glass
Terrain TerrainX X is number from 1 to 15 and presents mask as per which is choosen combination from 4 layers
Material - Antiwater Basic AlphaNoShadow in combination with empty alpha texture clears water from ship and is shadowless
Terrain TerrainSimpleX X is number from 1 to 15 and presents mask as per which is choosen combination from 4 layers
Super_shader Super Super SM 3.0 - shader with Fresnel for ArmA2
Multimaterial Multi Multi SM 3.0 - shader with multiple submaterials for ArmA2
Material - Tree Tree TreeNoFade SM 3.0 - shader for ArmA2 vegetation
Material - TreePRT TreePRT TreePRT SM 3.0 - shader for ArmA2 vegetation

List of individual 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 // Similar by function 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*/\

You can find More about material settings in Material templates

Physical properties编辑

Materials are also used in geometries for definition of physical properties.

Parameters for engine are saves into material tables *.bisurf and reference to them from material looks like:


Such file *.bisurf with physical properties looks like:

density=2500; // density of homogeneous object in kg/m3 // WikiPedia:List of Elements by density 
thickness=10; // non-homogeneous component casing thickness in mm, implemented since ARMA 2: Operation Arrowhead!
bulletPenetrability=150;  // distance in mm bullet (with speed 1000m/s) travels before it fully stops, simulation for calculation simplification calculate linear braking (ergo on third of distance is bullet decelerated to two thirds of original speed)

more about penetration Bullet penetrability

  • When components in Your model got materials with references to physical properties then use script which sets weight.