Elaztek Developer Hub
Blamite Game Engine - blam!  00388.06.24.23.2301.blamite
The core library for the Blamite Game Engine.
material.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #ifndef BLAM
7 #define BLAM
8 #endif
9 
11 {
17 };
18 
20 {
25 };
26 
28 {
38 };
39 
40 #pragma pack(push, 1)
41 
46 struct material
47 {
49 
50  TAG_ENUM(material_type,
51  {
52  pbr,
53  unlit
54  });
55 
56  TAG_BLOCK(unlit_material,
57  {
58 
59  });
60 
61  TAG_BLOCK(pbr_material,
62  {
63  bitfield16 flags;
64 
65  TAG_BLOCK(textures,
66  {
67  TAG_ENUM(texture_type,
68  {
69  diffuse,
70  normal,
71  specular,
72  metallic,
73  roughness,
74  detail_weight,
75  detail_0,
76  detail_1,
77  detail_2,
78  detail_3,
79  detail_normal_0,
80  detail_normal_1,
81  detail_normal_2,
82  detail_normal_3,
83  emissive,
84  reflection
85  });
86 
87  tag_reference texture;
88 
89  // SAMPLER PROPERTIES
90  material_filter_modes filter_mode_min;
91  material_filter_modes filter_mode_mag;
92  material_filter_modes filter_mode_mip;
93 
94  material_wrap_modes wrap_mode_x;
95  material_wrap_modes wrap_mode_y;
96  material_wrap_modes wrap_mode_z;
97 
98  real lod_bias;
99  real max_anisotropy;
100 
101  material_comparison_function sampler_comparison_function;
102 
103  color border_color;
104  real min_lod;
105  real max_lod;
106 
107  vector2 offset;
108  vector2 scale;
109  });
110 
111  // BRDF
112 
119  bitfield16 brdf_flags;
120 
121  TAG_ENUM(brdf,
122  {
123  default_brdf,
124  cook_torrance,
125  blinn_phong,
126  });
127 
128  // ALPHA
129  material_comparison_function alpha_comparison_function;
130 
131  bitfield16 alpha_flags;
132  real alpha_test_threshold;
133 
134  // COLORS
135  color diffuse_color;
136  color background_diffuse_color;
137  color emissive_color;
138 
139  // OTHER SHIT
140  real clear_coat;
141  real clear_coat_roughness;
142 
143  // TRANSPARENCY
144  real transparency;
145  bitfield16 transparency_flags;
146 
147  TAG_ENUM(transparency_mode,
148  {
149  none,
150  transparent,
151  fade,
152  refractive
153  });
154 
155  real refraction_strength;
156 
157  // WORKFLOWS
158  TAG_ENUM(workflow,
159  {
160  specular,
161  specular_fresnel,
162  metallic
163  });
164 
165  color specular_color;
166  real metalness;
167  real roughness;
168 
169 
170  });
171 
172  TAG_BLOCK(parameters,
173  {
174  bitfield8 debugging_flags;
175 
176  TAG_BLOCK(parameter_list,
177  {
178  bitfield16 input_flags;
179  ascii input_name;
180 
181  bitfield16 output_flags;
182 
183  TAG_ENUM(output_type,
184  {
185  material_property,
186  function
187  });
188 
189  ascii output_field_id;
190  });
191  });
192 
193  TAG_BLOCK(functions,
194  {
195 
196  });
197 };
198 #pragma pack(pop)
199 
201 {
202 public:
204  {
205  class_name_long = "material";
206  class_name_short = "mat";
207  version = 5;
208 
209  revisions = {
210  {1, "haloman30", "Initial implementation."},
211  {2, "haloman30", "Add settings for texture sampler."},
212  {3, "haloman30", "Combine sampler and texture fields into tag block, with each entry specifying a texture."},
213  {4, "haloman30", "Add fields for texture offset and scale."},
214  {5, "haloman30", "Add block for parameters, and empty blocks for unlit material and functions"}
215  };
216 
217  tag_size = sizeof(material);
218 
219  fields =
220  {
221  new CommentField("Material", ""),
222 
223  new AsciiField("id", ""),
224  new Enum32Field("material type", "",
225  {
226  "pbr",
227  "unlit"
228  }),
229 
230  new BlockField(sizeof(material::unlit_material_entry), "unlit material", "", {}),
231 
232  new BlockField(sizeof(material::pbr_material_entry), "pbr material", "",
233  {
234  new Bitfield16Field("", "",
235  {
236  "uses two sided lighting",
237  "receives shadows",
238  "use emissive as lightmap"
239  }),
240 
241  new BlockField(sizeof(material::pbr_material_entry::textures_entry), "textures", "",
242  {
243  new CommentField("TEXTURES", ""),
244  new Enum32Field("texture type", "",
245  {
246  "diffuse",
247  "normal",
248  "specular",
249  "metallic",
250  "roughness",
251  "detail_weight",
252  "detail_0",
253  "detail_1",
254  "detail_2",
255  "detail_3",
256  "detail_normal_0",
257  "detail_normal_1",
258  "detail_normal_2",
259  "detail_normal_3",
260  "emissive",
261  "reflection"
262  }),
263  new TagReferenceField("texture", "", { "bitm" }),
264 
265  new CommentField("SAMPLER", ""),
266  new Enum32Field("filter mode (min)", "",
267  {
268  "inherit from bitmap",
269  "none",
270  "point",
271  "linear",
272  "anisotropic"
273  }),
274  new Enum32Field("filter mode (mag)", "",
275  {
276  "inherit from bitmap",
277  "none",
278  "point",
279  "linear",
280  "anisotropic"
281  }),
282  new Enum32Field("filter mode (mip)", "",
283  {
284  "inherit from bitmap",
285  "none",
286  "point",
287  "linear",
288  "anisotropic"
289  }),
290  new Enum32Field("wrap mode x", "",
291  {
292  "wrap",
293  "mirror",
294  "clamp",
295  "border"
296  }),
297  new Enum32Field("wrap mode y", "",
298  {
299  "wrap",
300  "mirror",
301  "clamp",
302  "border"
303  }),
304  new Enum32Field("wrap mode z", "",
305  {
306  "wrap",
307  "mirror",
308  "clamp",
309  "border"
310  }),
311  new RealField("lod bias", ""),
312  new RealField("max anisotropy", ""),
313  new Enum32Field("sampler comparison function", "",
314  {
315  "always fail",
316  "always pass",
317  "less than",
318  "less than or equal",
319  "equal",
320  "not equal",
321  "greater than or equal",
322  "greater than",
323  "disabled"
324  }),
325  new ColorField("border color", ""),
326  new RealField("min lod", ""),
327  new RealField("max lod", ""),
328  new Vector2Field("offset", ""),
329  new Vector2Field("scale", "")
330  }),
331 
332  new CommentField("BRDF", "bidirectional reflectance distribution function"),
333  new Bitfield16Field("brdf flags", "",
334  {
335  "uncorrelated",
336  "separate diffuse fresnel",
337  "legacy math",
338  "full legacy"
339  }),
340  new Enum32Field("brdf function", "",
341  {
342  "default",
343  "cook-torrance",
344  "blinn-phong"
345  }),
346 
347  new CommentField("ALPHA", ""),
348  new Enum32Field("alpha comparison function", "",
349  {
350  "always fail",
351  "always pass",
352  "less than",
353  "less than or equal",
354  "equal",
355  "not equal",
356  "greater than or equal",
357  "greater than"
358  }),
359  new Bitfield16Field("alpha flags", "",
360  {
361  "shadow caster only",
362  "use alpha from texture"
363  }),
364  new RealField("alpha test threshold", ""),
365 
366  new CommentField("COLORS", ""),
367  new ColorField("diffuse color", ""),
368  new ColorField("background diffuse color", ""),
369  new ColorField("emissive color", ""),
370 
371 
372  new CommentField("CLEAR COAT", ""),
373  new RealField("clear coat amount", ""),
374  new RealField("clear coat roughness", ""),
375 
376  new CommentField("TRANSPARENCY", ""),
377  new RealField("transparency amount", ""),
378  new Bitfield16Field("transparency flags", "",
379  {
380  "use alpha from textures",
381  "change blend block"
382  }),
383  new Enum32Field("transparency mode", "",
384  {
385  "none",
386  "transparent",
387  "fade",
388  "refractive"
389  }),
390  new RealField("refraction strength", ""),
391 
392  new CommentField("WORKFLOWS", ""),
393  new Enum32Field("workflows", "",
394  {
395  "specular",
396  "specular (fresnel)",
397  "metallic"
398  }),
399  new ColorField("specular color", ""),
400  new RealField("metalness", ""),
401  new RealField("roughness", ""),
402 
403 
404  }),
405 
406  new BlockField(sizeof(material::parameters_entry), "parameters", "",
407  {
408  new Bitfield8Field("debugging flags", "",
409  {
410  "ignore all inputs"
411  }),
412 
413  new BlockField(sizeof(material::parameters_entry::parameter_list_entry), "parameter list", "",
414  {
415  new CommentField("INPUT OPTIONS", "These options determine what can provide inputs "
416  "to the material, and how they can do so."),
417 
418  new Bitfield16Field("input flags", "",
419  {
420  "block input from objects",
421  "block input from ui",
422  "block input from scripts"
423  }),
424  new AsciiField("", ""),
425 
426  new CommentField("OUTPUT OPTIONS", "These options determine where the parameter is output to, be "
427  "it directly to a property within the material, or to a function for additional processing."),
428 
429  new Bitfield16Field("output flags", "",
430  {
431  "unused"
432  }),
433  new Enum32Field("", "",
434  {
435  "material property",
436  "function"
437  }),
438  new AsciiField("", ""),
439  }),
440  }),
441 
442  new BlockField(sizeof(material::functions_entry), "functions", "", {})
443  };
444  }
445 };
446 
447 namespace Blam::Content::Tags
448 {
449  BLAM material* GetMaterialTag(std::string tag_path);
450 }
mat_cmp_less_equal
@ mat_cmp_less_equal
Definition: material.h:32
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:151
RealField
Class representing a real tag field.
Definition: real.h:16
material::TAG_ENUM
TAG_ENUM(material_type, { pbr, unlit })
mat_wrap_border
@ mat_wrap_border
Definition: material.h:24
mat_wrap_clamp
@ mat_wrap_clamp
Definition: material.h:23
AsciiField
Class representing an ascii tag field.
Definition: ascii.h:18
ascii
char ascii[128]
Typedef for an ascii field, used in tag data definitions.
Definition: tags.h:337
Vector2Field
Class representing a vector2 tag field.
Definition: vector.h:34
mat_fm_none
@ mat_fm_none
Definition: material.h:13
mat_cmp_equal
@ mat_cmp_equal
Definition: material.h:33
mat_cmp_always_fail
@ mat_cmp_always_fail
Definition: material.h:29
Bitfield16Field
Class representing a bitfield16 tag field.
Definition: bitfield.h:44
TagReferenceField
Class representing a tag reference, or tagref for short.
Definition: tagref.h:20
Enum32Field
Definition: enum.h:46
BlamTagClass::fields
std::vector< BlamTagClassField * > fields
A series of tag fields that store the layout of the tag.
Definition: tags.h:94
bitfield8
Typedef for a bitfield8 field, used in tag data definitions.
Definition: tags.h:259
mat_fm_linear
@ mat_fm_linear
Definition: material.h:15
BlamTagClass::revisions
std::vector< BlamTagClassRevision > revisions
List of all tag class revisions. Does not get written to tags, but is included in plugin files.
Definition: tags.h:92
material_wrap_modes
material_wrap_modes
Definition: material.h:19
mat_wrap_mirror
@ mat_wrap_mirror
Definition: material.h:22
material.h
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:90
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tags.h:91
mat_fm_anisotropic
@ mat_fm_anisotropic
Definition: material.h:16
tag_reference
Structure representing a tag reference.
Definition: tags.h:182
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:89
material
Structure representing a Material tag.
Definition: material.h:46
mat_cmp_not_equal
@ mat_cmp_not_equal
Definition: material.h:34
real
float real
Typedef for a 'real', aka a float.
Definition: tags.h:339
Blam::Content::Tags::GetTagData
BLAM BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: tags.cpp:80
MaterialTagClass
Definition: material.h:200
material::id
ascii id
Definition: material.h:48
mat_cmp_always_pass
@ mat_cmp_always_pass
Definition: material.h:30
mat_cmp_greater
@ mat_cmp_greater
Definition: material.h:36
fields.h
mat_fm_use_bitmap_state
@ mat_fm_use_bitmap_state
Definition: material.h:12
mat_cmp_greater_equal
@ mat_cmp_greater_equal
Definition: material.h:35
bitfield16
Typedef for a bitfield16 field, used in tag data definitions.
Definition: tags.h:274
mat_fm_point
@ mat_fm_point
Definition: material.h:14
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:96
BLAM
#define BLAM
Definition: material.h:7
material::TAG_BLOCK
TAG_BLOCK(unlit_material, { })
ColorField
Class representing a color tag field.
Definition: color.h:19
vector2
BlamVector2 vector2
Typedef for a vector2 field, used in tag definitions.
Definition: tags.h:340
mat_wrap_wrap
@ mat_wrap_wrap
Definition: material.h:21
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:33
tagclass.h
material_comparison_function
material_comparison_function
Definition: material.h:27
mat_cmp_disabled
@ mat_cmp_disabled
Definition: material.h:37
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:30
Blam::Content::Tags::GetMaterialTag
BLAM material * GetMaterialTag(std::string tag_path)
Definition: material.cpp:5
MaterialTagClass::MaterialTagClass
MaterialTagClass()
Definition: material.h:203
CommentField
Class representing a comment field.
Definition: comment.h:29
mat_cmp_less
@ mat_cmp_less
Definition: material.h:31
BlockField
Class representing a tag block field, also sometimes referred to as a struct or reflexive in the modd...
Definition: block.h:21
material_filter_modes
material_filter_modes
Definition: material.h:10
InternalUI::Colors::transparent
UI_API ImVec4 transparent()
Definition: debug_ui_colors.cpp:35
BlamTagClass
Class representing a tag class.
Definition: tags.h:86
Bitfield8Field
Class representing a bitfield8 tag field.
Definition: bitfield.h:33