]> git.xonotic.org Git - xonotic/xonotic.wiki.git/blob - Materials.md
Update Compiling: add libtool dependency
[xonotic/xonotic.wiki.git] / Materials.md
1 DarkPlaces Wiki
2 ===============
3
4 Material creation for DP
5 ========================
6
7 Quick notes by LordHavoc (in need of cleanup and completion!):
8
9 All texture files are optional except for diffuse, a q3 shader allows additional options to be set but is not required for common materials.
10
11 Replacing Content
12 -----------------
13
14 Formats supported: tga (recommended), png (loads very slowly), jpg (loads slowly), pcx, wal, lmp
15
16 Usually you want to put replacement content in either `id1/` or another directory such as `pretty/` inside your quake directory, in DarkPlaces you can run multiple `-game` options at once (such as `-game ctf -game pretty -game dpmod` to have texture overrides from pretty, maps from ctf, and gameplay from dpmod) or multiple gamedirs specified with the gamedir console command (`gamedir ctf pretty dpmod`).
17
18 All texture layers are optional except diffuse (the others are NOT loaded without it)
19
20 **Replacing skins:**  
21 progs/player.mdl\_0.tga - diffuse  
22 progs/player.mdl\_0\_**norm**.tga - normalmap (can have alpha channel with bumpmap height for offsetmapping/reliefmapping)  
23 progs/player.mdl\_0\_**bump**.tga - bumpmap (not loaded if normalmap is present)  
24 progs/player.mdl\_0\_**glow**.tga - glow map (use `_luma` if tenebrae compatibility is a concern)  
25 progs/player.mdl\_0\_**luma**.tga - alternate tenebrae-compatible name for glow map (use one or the other)  
26 progs/player.mdl\_0\_**pants**.tga - pants image, greyscale and does not cover the same pixels as the diffuse texture (this is additive blended ('Screen' mode in photoshop) ontop of the diffuse texture with a color tint according to your pants color)  
27 progs/player.mdl\_0\_**shirt**.tga - shirt image, same type as pants  
28
29 **Replacing textures in specific maps:**  
30 textures/**e1m1**/ecop1\_6.tga  
31 textures/**e1m1**/ecop1\_6\_norm.tga  
32 textures/**e1m1**/ecop1\_6\_bump.tga  
33 textures/**e1m1**/ecop1\_6\_glow.tga  
34 textures/**e1m1**/ecop1\_6\_luma.tga  
35 textures/**e1m1**/ecop1\_6\_pants.tga - pants and shirt layers are possible on bmodel entities with quakec modifications to set their .colormap field  
36 textures/**e1m1**/ecop1\_6\_shirt.tga  
37
38 **Replacing textures in all maps:**  
39 textures/quake.tga  
40 textures/quake\_**norm**.tga  
41 textures/quake\_**bump**.tga  
42 textures/quake\_**glow**.tga  
43 textures/quake\_**luma**.tga  
44 textures/quake\_**pants**.tga  
45 textures/quake\_**shirt**.tga  
46
47 **Replacing hud and menu pictures:**
48 gfx/conchars.tga  
49
50 Diffuse Color + Alpha (Opacity)
51 -------------------------------
52
53 `textures/texturepackname/texturename.tga`  
54
55 Generally should have ambient occlusion baked into the color (in other words, the grooves are dark), but no shading.
56
57 NormalMap + Relief Height
58 -------------------------
59
60 `textures/texturepackname/texturename_norm.tga`  
61
62 The normalmap is OpenGL-style with green pointing up (often normalmap tools call this "inverted"), matching Doom3/Quake4/etc behavior, but contrary to several other games.  
63
64 The height channel is black for deep areas and white for being flush with the surface, the height is used only when offsetmapping (`r_glsl_offsetmapping`) or reliefmapping (`r_glsl_offsetmapping_reliefmapping` also on) are active.  
65
66 For best results the height channel should be fairly smooth, no fine bumps, just the overall shape of the material.  
67
68 Specular Color + Specular Exponent
69 ----------------------------------
70
71 `textures/texturepackname/texturename_gloss.tga`  
72
73 The specular (gloss) color is full color and basically indicates how bright the specular reflection should when a light illuminates this surface, it should be black where you want the surface to look dull and bright where you want a shiny appearance.
74
75 For best results, color the gloss according to the material involved, for example plastic or car paint has a white specular color, copper has an orange specular color, gold has a yellow specular color, steel has a very slight blue tint to its otherwise white specular color, aluminum also has a very slight tint.
76
77 Generally the specular color should have ambient occlusion baked into the color (just like the diffuse does).
78
79 The alpha channel of this texture will multiply the specular exponent (`r_shadow_glossexponent`), white alpha will be sharp highlights, dark alpha produces very broad highlights very bright highlights, in general sharp highlights indicate metal or hard plastic materials, aluminum has a different specular hardness than steel, etc.
80
81 Glow color
82 ----------
83
84 `textures/texturepackname/texturename_glow.tga`  
85
86 This is the luminous glow of the material, pretty much you want this to be black with color only where a light emitting part of the surface exists (for example a series of red dots for red LED lights).
87
88 Be sure not to have any glow color in the diffuse texture as it will not add up properly.
89
90 Alpha is unused at this time.
91
92 Reflection mask for cubemap environment mapping
93 -----------------------------------------------
94
95 `texturename_reflect.tga` - mask for the reflection, looks similar to gloss texture, basically this is where things will be shiny and what color of reflection (use orange for copper, yellow for gold, a slight blue tinted white color for steel, etc)
96
97 In shader: `dpreflectcube map/mapname/reflect1`
98
99 You can produce such a texture with this console command: `envmap map/mapname/reflect1 512`
100
101 Which will produce files such as:  
102 `map/mapname/reflect1px.tga map/mapname/reflect1py.tga map/mapname/reflect1pz.tga map/mapname/reflect1nx.tga map/mapname/reflect1ny.tga map/mapname/reflect1nz.tga`  
103
104 `map/mapname/reflect1ft.tga map/mapname/reflect1rt.tga map/mapname/reflect1bk.tga map/mapname/reflect1lf.tga map/mapname/reflect1up.tga map/mapname/reflect1dn.tga`  
105
106 The first 6 are a cubemap, the last 6 are a skybox, keep one or the other set of files, you don't need both.
107
108 Material description (.shader) file
109 -----------------------------------
110
111 In gamedir/scripts the engine will load all files with the extension .shader using a Quake3-compatible shader loader, however not all features will be utilized (for example it only supports one layer shaders, additional layers may be used to activate special behaviors - such as lightmapping - but will not be directly rendered).
112
113 The syntax of the Quake3-compatible .shader files is best explained by examples, so there are several here to look at.
114
115 Many additional features can be added to any shader with expected results, such as `tcmod scroll 1 0` (makes a texture scroll in one direction), `deformvertexes autosprite` (makes a surface consisting of quads render as billboards facing the view), `deformvertexes autosprite2` (makes a surface consisting of rectangular quads - not square - rotate around their long axis to face the view, useful for flame trail sprites and torch flames among other things)...
116
117 Lightmapped material
118 --------------------
119
120     textures/texturepackname/texturename
121     {
122         {
123             map $lightmap
124             rgbGen identity
125             tcGen lightmap
126         }
127         {
128             map textures/texturepackname/texturename
129             rgbGen identity
130             blendFunc GL_DST_COLOR GL_ZERO
131         }
132     }
133
134 Transparent additive-blend unlit material
135 -----------------------------------------
136
137     textures/texturepackname/texturename
138     {
139         surfaceparm noimpact
140         surfaceparm nolightmap
141         surfaceparm nomarks
142         surfaceparm nonsolid
143         surfaceparm nodlight
144         surfaceparm trans
145         {
146             map textures/texturepackname/texturename
147             blendfunc add
148             rgbgen identity
149         }
150     }
151
152 Note: you can omit some of the surfaceparms (keep trans!) when making a model material rather than a map material.
153
154 Model material
155 --------------
156
157     textures/texturepackname/texturename
158     {
159         {
160             map textures/texturepackname/texturename
161             rgbgen lightingDiffuse
162         }
163     }
164
165 Model material that does not cast shadows
166 -----------------------------------------
167
168     textures/texturepackname/texturename
169     {
170         dpnoshadow
171         {
172             map textures/texturepackname/texturename
173             rgbgen lightingDiffuse
174         }
175     }
176
177 Invisible shadow-casting model material
178 ---------------------------------------
179
180     textures/common/shadowmesh
181     {
182         dpshadow
183     }
184
185 Lightmapped material with reflection cubemap and dpmeshcollisions
186 -----------------------------------------------------------------
187
188     textures/texturepackname/texturename
189     {
190         dpreflectcube textures/texturepackname/reflect1
191         dpmeshcollisions
192         {
193             map $lightmap
194             rgbGen identity
195             tcGen lightmap
196         }
197         {
198             map textures/texturepackname/texturename
199             rgbGen identity
200             blendFunc GL_DST_COLOR GL_ZERO
201         }
202     }
203
204 DP Shader Commands
205 ------------------
206
207     dp_reflect distort r g b a
208
209 Makes surfaces of this shader reflective with `r_water`. The reflection is alpha blended on the texture with the given alpha, and modulated by the given color. distort is used in conjunction with the normalmap to simulate a nonplanar water surface.  
210
211     dp_refract distort r g b
212
213 Makes surfaces of this shader refractive with `r_water`. The refraction replaces the transparency of the texture. distort is used in conjunction with the normalmap to simulate a nonplanar water surface.  
214
215     dp_water <reflectmin> <reflectmax> <refractdistort> <reflectdistort> <refractr> <refractg><refractb>
216      <reflectr> <reflectg> <reflectb> <alpha>
217
218 This combines the effects of dp_reflect and dp_refract to simulate a water surface. However, the refraction and the reflection are mixed using a Fresnel equation that makes the amount of reflection slide from reflectmin when looking parallel to the water to reflectmax when looking directly into the water. The result of this reflection/refraction mix is then layered BELOW the texture of the shader, so basically, it "fills up" the alpha values of the water. The alpha value is a multiplicator for the alpha value on the texture (set this to a small value like 0.1) to emphasize the reflection and make the water transparent; but if `r_water` is 0, alpha isn't used, so the water can be very visible then too.
219
220     tcmod page <width> <height> <delay>
221
222 The texture is shifted by 1/<width> every <delay> seconds, and by 1/<height> every <delay>\*<width> seconds. It is some sort of animmap replacement that keeps all animation frames in a single texture.
223
224 To use it, make a texture with the frames aligned in a grid like this:
225
226     1   2   3   4
227     5   6   7   8
228
229 then align it in Radiant so only one of the animation frames can be seen on the surface, and specify "tcmod page 4 2 0.1". DP will then display the frames in order and the cycle will repeat every 0.8 seconds.