Quake II RTX doxygen  1.0 dev
material.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2019, NVIDIA CORPORATION. All rights reserved.
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18 
19 #ifndef __MATERIAL_H_
20 #define __MATERIAL_H_
21 
22 #include "shared/shared.h"
23 #include "refresh/refresh.h"
24 
25 #define MAX_PBR_MATERIALS 4096
26 
27 typedef struct image_s image_t;
28 
29 //
30 // PBR material
31 //
32 
33 typedef struct pbr_material_s {
34  char name[MAX_QPATH];
38  float bump_scale;
42  uint32_t flags;
48 
49 // returns index of given material in table
51 
52 // registration sequence : set material PBR textures
53 qerror_t MAT_RegisterPBRMaterial(pbr_material_t * mat, image_t * image_diffuse, image_t * image_normals, image_t * image_emissive);
54 
55 // registration sequence : update registration sequence of images used by the material
57 
58 // update material when a skin is applied
59 pbr_material_t const * MAT_UpdatePBRMaterialSkin(image_t * image_diffuse);
60 
61 qerror_t MAT_SetPBRMaterialAttribute(pbr_material_t * mat, char const * token, char const * value);
62 
63 //
64 // materials table
65 //
66 
67 // initialize materials table (call on client init)
69 
70 // reset materials textures (call before loading a level)
71 qerror_t MAT_ResetUnused();
72 
73 // returns pointer to materials in table
75 
76 // returns number of materials in table
78 
79 // find material in table by index (index < num materials)
81 
82 // find a material by key (ex. textures/e1u1/ceil1_1.wal)
83 pbr_material_t * MAT_FindPBRMaterial(char const * name);
84 
85 // reload materials CSV file while the game is running
86 qerror_t MAT_ReloadPBRMaterials();
87 
88 // save materials CSV file (in edit mode)
89 qerror_t MAT_SavePBRMaterials();
90 
91 // prints material properties on console
93 
94 // replaces the material kind field with the given value
95 uint32_t MAT_SetKind(uint32_t material, uint32_t kind);
96 
97 // tests if the material is of a given kind
98 qboolean MAT_IsKind(uint32_t material, uint32_t kind);
99 
100 #endif // __MATERIAL_H_
pbr_material_s::name
char name[MAX_QPATH]
Definition: material.h:34
pbr_material_s::next_frame
int next_frame
Definition: material.h:45
image_t
struct image_s image_t
Definition: material.h:27
pbr_material_s::image_normals
image_t * image_normals
Definition: material.h:36
pbr_material_s::image_emissive
image_t * image_emissive
Definition: material.h:37
MAT_GetPBRMaterialsTable
const pbr_material_t * MAT_GetPBRMaterialsTable()
Definition: material.c:139
MAT_IsKind
qboolean MAT_IsKind(uint32_t material, uint32_t kind)
Definition: material.c:665
pbr_material_s::flags
uint32_t flags
Definition: material.h:42
pbr_material_s::specular_scale
float specular_scale
Definition: material.h:40
MAT_UpdateRegistration
void MAT_UpdateRegistration(pbr_material_t *mat)
Definition: material.c:421
pbr_material_s::emissive_scale
float emissive_scale
Definition: material.h:41
pbr_material_s::bump_scale
float bump_scale
Definition: material.h:38
pbr_material_s::num_frames
int num_frames
Definition: material.h:44
pbr_material_s
Definition: material.h:33
MAT_RegisterPBRMaterial
qerror_t MAT_RegisterPBRMaterial(pbr_material_t *mat, image_t *image_diffuse, image_t *image_normals, image_t *image_emissive)
Definition: material.c:397
MAT_ReloadPBRMaterials
qerror_t MAT_ReloadPBRMaterials()
Definition: material.c:347
pbr_material_s::image_diffuse
image_t * image_diffuse
Definition: material.h:35
MAT_GetNumPBRMaterials
int MAT_GetNumPBRMaterials()
Definition: material.c:144
MAT_InitializePBRmaterials
qerror_t MAT_InitializePBRmaterials()
Definition: material.c:341
pbr_material_s::enable_light_styles
int enable_light_styles
Definition: material.h:46
MAT_GetPBRMaterialIndex
int MAT_GetPBRMaterialIndex(pbr_material_t const *mat)
Definition: material.c:149
MAT_SetKind
uint32_t MAT_SetKind(uint32_t material, uint32_t kind)
Definition: material.c:660
MAT_UpdatePBRMaterialSkin
const pbr_material_t * MAT_UpdatePBRMaterialSkin(image_t *image_diffuse)
Definition: material.c:517
MAT_FindPBRMaterial
pbr_material_t * MAT_FindPBRMaterial(char const *name)
Definition: material.c:465
pbr_material_t
struct pbr_material_s pbr_material_t
pbr_material_s::registration_sequence
int registration_sequence
Definition: material.h:43
MAT_GetPBRMaterial
pbr_material_t * MAT_GetPBRMaterial(int index)
Definition: material.c:457
MAT_SavePBRMaterials
qerror_t MAT_SavePBRMaterials()
Definition: material.c:391
pbr_material_s::rough_override
float rough_override
Definition: material.h:39
MAT_PrintMaterialProperties
void MAT_PrintMaterialProperties(pbr_material_t const *mat)
Definition: material.c:549
MAT_ResetUnused
qerror_t MAT_ResetUnused()
Definition: material.c:433
MAT_SetPBRMaterialAttribute
qerror_t MAT_SetPBRMaterialAttribute(pbr_material_t *mat, char const *token, char const *value)
Definition: material.c:570