> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/redengine3-research/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.redmodding.org/redengine3-research/assets/shaders/materials.md).

# Materials

## What is a material?

Materials are a *specific* instance of a [shader](/redengine3-research/assets/shaders.md) file, to be used on a mesh or subset of meshes. Materials are contained inside **w2mi** (Witcher 2 material instance) files or within mesh files themselves as a **CMaterialInstance** chunk. While internal material instance chunks can be handy to have inside the mesh, external w2mi files can be used for multiple meshes.\
\
It's important to remember that materials are simply instances of shaders. The variables contained within the material only take effect when those same variables are present inside the base shader. For example, if **SpecularTexture** is not present within the base shader adding this property to a material instance will have absolutely no effect.

### The Daisy Chain

The mechanism behind the link between shaders and meshes can be thought of as a daisy chain. Meshes do not directly link shaders, but instead rely on a variable number of daisy chained materials. Some meshes may use a single internal material instance, which specifies a base shader.

The other approach which is just as, or perhaps more common is chaining several w2mi files together. The benefit of doing so, is the ability to globally adjust materials for hundreds or thousands of meshes. When chaining multiple materials together, the properties of each material overwrite those that are below.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.redmodding.org/redengine3-research/assets/shaders/materials.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
