On this page
What goes into a material
There is no separate material file. Each mesh LOD stores its own list of materials, one per draw call: which shader technique, which textures in which slots, how alpha is used, and which range of the vertex and index buffers it covers.
What a material holds#
| Field | Example (the jeep, geometry 1, material 0) | Who reads it |
|---|---|---|
| alpha mode | 0 opaque (1 blend, 2 test) | the draw: blending, alpha test, the view-sorted index copies below |
| effect file | BundledMesh.fx | nobody: every retail loader skips it and picks the shader by mesh kind |
| technique | ColormapGloss | the shader permutation (below) |
| maps | objects/vehicles/bri_jeep_willys/textures/bri_jeep_willys.dds | the texture slots, in order |
| vertex start / count, index start / count | the batch's slice of the buffers | DrawIndexedPrimitive |
The fields and their order are bf2-mesh template.rs Material; an alpha-blend batch's indices are stored eight times, pre-sorted for eight view directions (MeshFile::sorted_index_copies; the bundled draw picks the copy for the camera's yaw).

The CON lines behind it#
The material list comes from the exporter, not from CON. CON names the geometry and how the object uses it:
GeometryTemplate.create BundledMesh bri_jeep_willys
CollisionManager.createTemplate bri_jeep_willys
ObjectTemplate.create PlayerControlObject bri_jeep_willys
ObjectTemplate.collisionMesh bri_jeep_willys
ObjectTemplate.mapMaterial 0 Metal 4500
ObjectTemplate.mapMaterial 1 glassHeadLights 4500
ObjectTemplate.geometry bri_jeep_willysmapMaterial maps the collision mesh's face materials to game materials (hit effects, penetration, sounds); it is not the render material. The render side's tweakables are GeometryTemplate.* lines in the tweak (LOD distances, maxTextureRepeat, compressVertexData; see the house on meshes).
How the renderer picks the pipeline#
- Mesh kind picks the shader family: static meshes
RaShaderSTM, bundledRaShaderBM, skinnedRaShaderSM(bf2-renderstaticmesh.rs,bundledmesh.rs,skinned.rs); the.fxname in the file is ignored. - Technique words set state flags: the bundled reader lower-cases the technique and looks for
animated(UV animation),envmap,colormapgloss,alpha_test,alpha_one,cockpit,nohemilight; the maps add a normal map (_b.ddsin map 1) or a GI map (bf2-renderbundledmesh.rsmodule doc,BmFlags). - Permutation bits: the flags become a bit set over the family's literal table (Heroes has its own,
literals_in), andpermutation_forfinds the generated shader permutation whose literals give the same bits (staticmesh.rs/bundledmesh.rspermutation_bits,permutation_for). - Fallback: no match logs
Couldn't find shader bits: <bits> looked up name: <name>and draws with the default shader, a flat colour (staticmesh.rsdefault_shader, the retailfindShadermiss branch).
Static meshes add the lightmap and the detail / dirt / crack layers as literals of the same table; each layer reads its own TEXCOORD set (bf2-mesh MeshFile::texcoords). Skinned hero items use SoldierItem.fx with the composed hero atlas (textures).
The passes these pipelines run in (shadows, the opaque and the sorted transparent queue, post effects) are on the render pipeline page.
How it is tested#
- The material scripts of every mod run through the port's reader (
crates/bf2-physics/tests/retail_materials.rs). - Render materials: every shipped mesh's materials are read with the mesh (meshes); the shader permutation tables are held against the original's order and literal table (
crates/bf2-render/tests/basics.rs). - The shipped shaders all parse, translate and validate (
crates/bf2-shaders/tests/retail.rs).
This page cites no address, so no test names one: what is proven is that every shipped file is read, not that a material looks as in the original.
In the code#
| What | Where |
|---|---|
| a mesh's materials and texture coordinate sets | crates/bf2-mesh |
| the shaders and their translation | crates/bf2-shaders |
| choosing and running the pipelines | crates/bf2-render |
| the physics materials (friction, damage modifiers, effects of a pair), which are another thing with the same name | crates/bf2-physics/src/material.rs (damage and armor) |
docs/dev/assets/material.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.