3d objects: .mesh files
Documentation on .mesh files and their properties.
Summary
Published: ??? by manavortex Last documented edit: May 01 2024 by manavortex
This page contains information on .mesh files and their properties.
Wait, that's not what I want!
See WKit Blender Plugin: Import/Export -> Meshes for a guide on export/import
To edit a mesh's appearance, check Changing materials, colors and textures
If you just want to use a textured material, check Using a textured material
To learn about mesh materials, see AMM: Textured items and Cyberpunk Materials using Custom Props
To hide parts of a mesh under different circumstances, check First Person Perspective Fixes
To stop copy-pasting so much, check ArchiveXL: dynamic materials
What's a mesh?
In the context of Cyberpunk, a mesh is the file that defines the and the of an object in the game world.
A mesh can have several submeshes, each of which has own material assignments. You can learn more about this on the sub-page for Submeshes, Materials and Chunks.
Mesh files for inanimate objects also tend to contain extensive physics parameters governing their physical weight and general behavior.
How the mesh is loaded
Meshes are loaded via Components (e.g. ). Components are defined either in mesh entity files or in an .app file, where each appearance has its own components array.
For more information on this, please check Submeshes, Materials and Chunks -> Chunkmasks: partially hiding meshes
Shadows
There are two ways of adding shadows to meshes:
Component property
To make a mesh cast a real-time shadow, set the component's property castShadows
to Always
.
Depending on your geometry, this can impact performance.
Shadow mesh
Many meshes have dedicated shadow meshes, which have a much lower level of detail and will be hidden by default. You can open any clothing item's mesh entity to see this in action.
Mesh Preview
You can see which submesh is which in the Mesh Preview
tab after opening the mesh file:
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FFvyxVSBnx3nbGMwSTNri%252Fmesh_preview_tab.png%3Falt%3Dmedia%26token%3Dfb35c1b7-b384-4f18-87a6-666b07e6726d&width=768&dpr=4&quality=100&sign=f592730b&sv=1)
With the boxes on the left, you can toggle submeshes on and off.
Submesh numbers correspond directly to a component's chunkMask property. For technical reasons, the chunkmask dropdown supports up to 64 entries — just ignore the missing numbers.
Material assignment
This section describes how materials are assigned inside each mesh. To learn more about submeshes and chunkmasks, check Submeshes, Materials and Chunks.
This page only contains mesh-specific information. Find more details on materials under Textures, Materials and Shaders.
Step 1: Appearances
An appearance
is the entry point into a mesh.
One appearance
has a number of chunkMaterials
, which tell Cyberpunk how they are supposed to look:
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FKaJ5Nd934NRNYqfgDWSh%252Fimage.png%3Falt%3Dmedia%26token%3Dbcf8b9df-d247-4352-8b17-7ea86ef9ab1e&width=768&dpr=4&quality=100&sign=f868c509&sv=1)
Wolvenkit will follow these entries to materialEntries, where they are defined:
The index
property in materialEntries will finally point at the material's instance, where you can find its properties. Depending on isLocalInstance
, that can be one of several places — find a list in Step 3: Material definition.
TL;DR
Summary:
Assign material for submesh in appearance -> chunkMaterials
Register the material by name in
materialEntries
Define the material in either
localMaterialInstances.materials
orexternalMaterials
Here's an overview:
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252Fgit-blob-395ce87c22eec240e09d079664380dc3d018da0a%252Fmeshes_appearances.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=919da3e1&sv=1)
ChunkMaterials
You can find more information on this under Submeshes, Materials and Chunks.
You assign materials based on the "chunks" (the individual submeshes) inside a mesh. Open the mesh file in Wolvenkit and open the "appearances" array, then make sure that each of your submeshes has an entry inside the array.
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FbWcHh0g9EBvmiMAFdayq%252Fmesh_material_appearance.png%3Falt%3Dmedia%26token%3D36687180-5d8c-4301-bfc7-43a2af9aac0c&width=768&dpr=4&quality=100&sign=3b230d16&sv=1)
Step 2: Material registry
Materials are registered in the array materialEntries
inside your mesh:
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FKBM1BW4HQWmmxgMznYWA%252Fmaterials_materialentries_overview.png%3Falt%3Dmedia%26token%3Dfc115cc4-a485-44fc-846b-1e0776844916&width=768&dpr=4&quality=100&sign=62adc1ed&sv=1)
While you can mix external and local materials, you can not mix preloaded and non-preloaded ones. For details, see below.
Property | Description |
---|---|
index | numerical index of corresponding material in target list (as defined by |
isLocalInstance | Selects the material target list.
True: local material in |
name | unique name of material, used to select the material via |
Preload… what?
Many of CDPR's early meshes use preloadLocalMaterialInstances
instead of localMaterialBuffer.materials
. As far as we are concerned, you can use the two interchangeably, but:
If you are using a mix of local and external materials, you must use the corresponding lists:
local | external |
---|---|
|
|
|
|
If you mix the two, the materials outside of preload
… will appear as transparent the first 1-2 times you trigger your item's appearance.
Step 3: Material definition
A material's actual definition (instance) can be in a CMaterialInstance
inside the mesh or in a .mi
file in the project. Wolvenkit will display material names as defined in the materialEntries
, making it easier for you to see what's what.
For more details on material instances, check Textures, Materials and Shaders -> Definition: Material
MaterialInstance: The local material
The materials themselves are inside the array localMaterialBuffer.materials
(or preloadLocalMaterials
in case of older meshes).
You can't go wrong by using those. However, if you don't have any properties that are unique to your mesh or appearance (for example a custom normal map), you might consider creating and using an external material instead.
A material instance looks like this:
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FGeevGtdQktU1Y6dLMSc7%252Fmaterial_docu_material_instance.png%3Falt%3Dmedia%26token%3D838d7a08-1147-4a46-b3fc-4e55091bd86e&width=768&dpr=4&quality=100&sign=5f204e26&sv=1)
You can find a guide about texture editing and adding custom textures in the section.
For an overview of materials that you might want to use for something, check here.
For how to find out which properties a material has, check here.
Material reference: reusing materials
A relative path to an external material, usually encapsulated in a .mi file. Use this if you don't need to add extra properties.
Last updated