Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.blamite
The core library for the Blamite Game Engine.
material.h
Go to the documentation of this file.
1 // material [mat] - Tag Definition //
3 // -------- //
4 // Author: haloman30 //
5 // Revision: 6 //
6 // -------- //
7 // Part of the Blamite Game Engine //
8 // Copyright (c) Elaztek Studios 2013 - 2023 //
10 
11 
12 #pragma once
13 
14 #include <string>
18 
19 #ifndef BLAM
20 #define BLAM
21 #endif
22 
24 {
26  none,
27  point,
28  linear,
30 };
32 {
33  wrap,
34  mirror,
35  clamp,
36  border,
37 };
39 {
42  less_than,
44  equal,
45  not_equal,
48  disabled,
49 };
50 
51 
52 #pragma pack(push, 1)
53 struct material
54 {
55  //Material
56 
58  TAG_ENUM(material_type,
59  {
60  pbr,
61  unlit,
62  });
63 
64  TAG_BLOCK(pbr_material,
65  {
66  bitfield16 flags;
67  TAG_BLOCK(textures,
68  {
69  //TEXTURES
70 
71  TAG_ENUM(texture_type,
72  {
73  diffuse,
74  normal,
75  specular,
76  metallic,
77  roughness,
78  detail_weight,
79  detail_0,
80  detail_1,
81  detail_2,
82  detail_3,
83  detail_normal_0,
84  detail_normal_1,
85  detail_normal_2,
86  detail_normal_3,
87  emissive,
88  reflection,
89  });
90 
91  tag_reference texture;
92  //SAMPLER
93 
94  material_filter_modes filter_mode_min;
95  material_filter_modes filter_mode_mag;
96  material_filter_modes filter_mode_mip;
97  material_wrap_modes wrap_mode_x;
98  material_wrap_modes wrap_mode_y;
99  material_wrap_modes wrap_mode_z;
100  real lod_bias;
101  real max_anisotropy;
102  material_comparison_function sampler_comparison_function;
103  color border_color;
104  real min_lod;
105  real max_lod;
106  vector2 offset;
107  vector2 scale;
108  });
109  //BRDF
110  /*bidirectional reflectance distribution function*/
111  bitfield16 brdf_flags;
112  TAG_ENUM(brdf_function,
113  {
114  default_brdf,
115  cook_torrance,
116  blinn_phong,
117  });
118 
119  //ALPHA
120 
121  material_comparison_function alpha_comparison_function;
122  bitfield16 alpha_flags;
123  real alpha_test_threshold;
124  //COLORS
125 
126  color diffuse_color;
127  color background_diffuse_color;
128  color emissive_color;
129  //CLEAR COAT
130 
131  real clear_coat_amount;
132  real clear_coat_roughness;
133  //TRANSPARENCY
134 
135  real transparency_amount;
136  bitfield16 transparency_flags;
137  TAG_ENUM(transparency_mode,
138  {
139  none,
140  transparent,
141  fade,
142  refractive,
143  });
144 
145  real refraction_strength;
146  //WORKFLOWS
147 
148  TAG_ENUM(workflows,
149  {
150  specular,
151  specular_fresnel,
152  metallic,
153  });
154 
155  color specular_color;
156  real metalness;
157  real roughness;
158  });
159  TAG_BLOCK(unlit_material,
160  {
161  bitfield16 flags;
162  TAG_BLOCK(textures,
163  {
164  //TEXTURES
165 
166  int8_t texture_type;
167  tag_reference texture;
168  //SAMPLER
169 
170  material_filter_modes filter_mode_min;
171  material_filter_modes filter_mode_mag;
172  material_filter_modes filter_mode_mip;
173  material_wrap_modes wrap_mode_x;
174  material_wrap_modes wrap_mode_y;
175  material_wrap_modes wrap_mode_z;
176  vector2 lod;
177  real lod_bias;
178  real max_anisotropy;
179  vector2 offset;
180  vector2 scale;
181  });
182  color diffuse_color;
183  //ALPHA
184 
185  material_comparison_function alpha_comparison_function;
186  bitfield16 alpha_flags;
187  real alpha_test_threshold;
188  });
189  TAG_BLOCK(input_parameters,
190  {
191  ascii name;
192  field_reference output_field;
193  bitfield8 flags;
194  });
195 };
196 #pragma pack(pop)
197 
199 {
200 public:
202  {
203  class_name_long = "material";
204  class_name_short = "mat";
205  version = 6;
206 
207  revisions = {
208  {1, "haloman30", "Initial implementation."},
209  {2, "haloman30", "Add settings for texture sampler."},
210  {3, "haloman30", "Combine sampler and texture fields into tag block, with each entry specifying a texture."},
211  {4, "haloman30", "Add fields for texture offset and scale."},
212  {5, "haloman30", "Add input parameters block"},
213  {6, "haloman30", "Add support for unlit materials"},
214 
215  };
216 
217  tag_size = 228;
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  new BlockField(100, "pbr material", "",
230  {
231  new Bitfield16Field("flags", "",
232  {
233  "uses two sided lighting",
234  "receives shadows",
235  "use emissive as lightmap",
236  }),
237  new BlockField(100, "textures", "",
238  {
239  new CommentField("TEXTURES",
240  ""),
241  new Enum32Field("texture type", "",
242  {
243  "diffuse",
244  "normal",
245  "specular",
246  "metallic",
247  "roughness",
248  "detail_weight",
249  "detail_0",
250  "detail_1",
251  "detail_2",
252  "detail_3",
253  "detail_normal_0",
254  "detail_normal_1",
255  "detail_normal_2",
256  "detail_normal_3",
257  "emissive",
258  "reflection",
259  }),
260  new TagReferenceField("texture", "", { "bitmap"}),
261  new CommentField("SAMPLER",
262  ""),
263  new Enum32Field("filter mode (min)", "",
264  {
265  "inherit from bitmap",
266  "none",
267  "point",
268  "linear",
269  "anisotropic",
270  }),
271  new Enum32Field("filter mode (mag)", "",
272  {
273  "inherit from bitmap",
274  "none",
275  "point",
276  "linear",
277  "anisotropic",
278  }),
279  new Enum32Field("filter mode (mip)", "",
280  {
281  "inherit from bitmap",
282  "none",
283  "point",
284  "linear",
285  "anisotropic",
286  }),
287  new Enum32Field("wrap mode x", "",
288  {
289  "wrap",
290  "mirror",
291  "clamp",
292  "border",
293  }),
294  new Enum32Field("wrap mode y", "",
295  {
296  "wrap",
297  "mirror",
298  "clamp",
299  "border",
300  }),
301  new Enum32Field("wrap mode z", "",
302  {
303  "wrap",
304  "mirror",
305  "clamp",
306  "border",
307  }),
308  new RealField("lod bias", ""),
309  new RealField("max anisotropy", ""),
310  new Enum32Field("sampler comparison function", "",
311  {
312  "always fail",
313  "always pass",
314  "less than",
315  "less than or equal",
316  "equal",
317  "not equal",
318  "greater than or equal",
319  "greater than",
320  "disabled",
321  }),
322  new ColorField("border color", ""),
323  new RealField("min lod", ""),
324  new RealField("max lod", ""),
325  new Vector2Field("offset", ""),
326  new Vector2Field("scale", ""),
327  }),
328  new CommentField("BRDF",
329  "bidirectional reflectance distribution function"),
330  new Bitfield16Field("brdf flags", "",
331  {
332  "uncorrelated",
333  "separate diffuse fresnel",
334  "legacy math",
335  "full legacy",
336  }),
337  new Enum32Field("brdf function", "",
338  {
339  "default",
340  "cook-torrance",
341  "blinn-phong",
342  }),
343  new CommentField("ALPHA",
344  ""),
345  new Enum32Field("alpha comparison function", "",
346  {
347  "always fail",
348  "always pass",
349  "less than",
350  "less than or equal",
351  "equal",
352  "not equal",
353  "greater than or equal",
354  "greater than",
355  "disabled",
356  }),
357  new Bitfield16Field("alpha flags", "",
358  {
359  "shadow caster only",
360  "use alpha from texture",
361  }),
362  new RealField("alpha test threshold", ""),
363  new CommentField("COLORS",
364  ""),
365  new ColorField("diffuse color", ""),
366  new ColorField("background diffuse color", ""),
367  new ColorField("emissive color", ""),
368  new CommentField("CLEAR COAT",
369  ""),
370  new RealField("clear coat amount", ""),
371  new RealField("clear coat roughness", ""),
372  new CommentField("TRANSPARENCY",
373  ""),
374  new RealField("transparency amount", ""),
375  new Bitfield16Field("transparency flags", "",
376  {
377  "use alpha from textures",
378  "change blend block",
379  }),
380  new Enum32Field("transparency mode", "",
381  {
382  "none",
383  "transparent",
384  "fade",
385  "refractive",
386  }),
387  new RealField("refraction strength", ""),
388  new CommentField("WORKFLOWS",
389  ""),
390  new Enum32Field("workflows", "",
391  {
392  "specular",
393  "specular (fresnel)",
394  "metallic",
395  }),
396  new ColorField("specular color", ""),
397  new RealField("metalness", ""),
398  new RealField("roughness", ""),
399  }),
400  new BlockField(48, "unlit material", "",
401  {
402  new Bitfield16Field("flags", "",
403  {
404  "enable planar reflections",
405  "enable diffuse color",
406  }),
407  new BlockField(89, "textures", "",
408  {
409  new CommentField("TEXTURES",
410  ""),
411  new Int8Field("texture type", ""),
412  new TagReferenceField("texture", "", { }),
413  new CommentField("SAMPLER",
414  ""),
415  new Enum32Field("filter mode (min)", "",
416  {
417  "inherit from bitmap",
418  "none",
419  "point",
420  "linear",
421  "anisotropic",
422  }),
423  new Enum32Field("filter mode (mag)", "",
424  {
425  "inherit from bitmap",
426  "none",
427  "point",
428  "linear",
429  "anisotropic",
430  }),
431  new Enum32Field("filter mode (mip)", "",
432  {
433  "inherit from bitmap",
434  "none",
435  "point",
436  "linear",
437  "anisotropic",
438  }),
439  new Enum32Field("wrap mode x", "",
440  {
441  "wrap",
442  "mirror",
443  "clamp",
444  "border",
445  }),
446  new Enum32Field("wrap mode y", "",
447  {
448  "wrap",
449  "mirror",
450  "clamp",
451  "border",
452  }),
453  new Enum32Field("wrap mode z", "",
454  {
455  "wrap",
456  "mirror",
457  "clamp",
458  "border",
459  }),
460  new Vector2Field("lod", ""),
461  new RealField("lod bias", ""),
462  new RealField("max anisotropy", ""),
463  new Vector2Field("offset", ""),
464  new Vector2Field("scale", ""),
465  }),
466  new ColorField("diffuse color", ""),
467  new CommentField("ALPHA",
468  ""),
469  new Enum32Field("alpha comparison function", "",
470  {
471  "always fail",
472  "always pass",
473  "less than",
474  "less than or equal",
475  "equal",
476  "not equal",
477  "greater than or equal",
478  "greater than",
479  "disabled",
480  }),
481  new Bitfield16Field("alpha flags", "",
482  {
483  "shadow caster only",
484  "use alpha from texture",
485  }),
486  new RealField("alpha test threshold", ""),
487  }),
488  new BlockField(149, "input parameters", "",
489  {
490  new AsciiField("name", ""),
491  new FieldReferenceField("output field", ""),
492  new Bitfield8Field("flags", "",
493  {
494  "enabled",
495  }),
496  }),
497 
498  };
499  }
500 };
501 
502 namespace Blam::Content::Tags
503 {
504  BLAM material* GetMaterialTag(std::string tag_path);
505 }
material_filter_modes::inherit_from_bitmap
@ inherit_from_bitmap
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:196
RealField
Class representing a real tag field.
Definition: real.h:16
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:359
material::TAG_BLOCK
TAG_BLOCK(pbr_material, { bitfield16 flags;TAG_BLOCK(textures, { TAG_ENUM(texture_type, { diffuse, normal, specular, metallic, roughness, detail_weight, detail_0, detail_1, detail_2, detail_3, detail_normal_0, detail_normal_1, detail_normal_2, detail_normal_3, emissive, reflection, });tag_reference texture;material_filter_modes filter_mode_min;material_filter_modes filter_mode_mag;material_filter_modes filter_mode_mip;material_wrap_modes wrap_mode_x;material_wrap_modes wrap_mode_y;material_wrap_modes wrap_mode_z;real lod_bias;real max_anisotropy;material_comparison_function sampler_comparison_function;color border_color;real min_lod;real max_lod;vector2 offset;vector2 scale;});bitfield16 brdf_flags;TAG_ENUM(brdf_function, { default_brdf, cook_torrance, blinn_phong, });material_comparison_function alpha_comparison_function;bitfield16 alpha_flags;real alpha_test_threshold;color diffuse_color;color background_diffuse_color;color emissive_color;real clear_coat_amount;real clear_coat_roughness;real transparency_amount;bitfield16 transparency_flags;TAG_ENUM(transparency_mode, { none, transparent, fade, refractive, });real refraction_strength;TAG_ENUM(workflows, { specular, specular_fresnel, metallic, });color specular_color;real metalness;real roughness;})
material_wrap_modes
material_wrap_modes
Definition: material.h:31
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:353
Vector2Field
Class representing a vector2 tag field.
Definition: vector.h:34
material_comparison_function::less_than_or_equal
@ less_than_or_equal
material_wrap_modes::wrap
@ wrap
Bitfield16Field
Class representing a bitfield16 tag field.
Definition: bitfield.h:44
bitmap_filtering_mode::point
@ point
TagReferenceField
Class representing a tag reference, or tagref for short.
Definition: tagref.h:20
Enum32Field
Definition: enum.h:46
int8_t
signed char int8_t
Definition: stdint.h:11
BlamTagClass::fields
std::vector< BlamTagClassField * > fields
A series of tag fields that store the layout of the tag.
Definition: tags.h:138
bitfield8
Typedef for a bitfield8 field, used in tag data definitions.
Definition: tags.h:275
bitmap_filtering_mode::anisotropic
@ anisotropic
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:137
material_comparison_function::less_than
@ less_than
Int8Field
Class representing an int8 tag field.
Definition: int.h:72
material.h
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:135
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tags.h:136
material_comparison_function::always_pass
@ always_pass
material_comparison_function::always_fail
@ always_fail
tag_reference
Structure representing a tag reference.
Definition: tags.h:215
field_reference
Structure representing a field reference.
Definition: tags.h:367
material_wrap_modes::border
@ border
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:134
material
Definition: material.h:53
real
float real
Typedef for a 'real', aka a float.
Definition: tags.h:355
material_filter_modes
material_filter_modes
Definition: material.h:23
uint32_t
unsigned int uint32_t
Definition: stdint.h:17
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:198
material::id
ascii id
Definition: material.h:57
bitmap_filtering_mode::none
@ none
bitmap_filtering_mode::linear
@ linear
fields.h
material_wrap_modes::mirror
@ mirror
material_comparison_function::greater_than_or_equal
@ greater_than_or_equal
bitfield16
Typedef for a bitfield16 field, used in tag data definitions.
Definition: tags.h:290
material_comparison_function::disabled
@ disabled
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:139
material_comparison_function::not_equal
@ not_equal
material::TAG_ENUM
TAG_ENUM(material_type, { pbr, unlit, })
BLAM
#define BLAM
Definition: material.h:20
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:356
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:71
tagclass.h
tags.h
tags.h
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:68
Blam::Content::Tags::GetMaterialTag
BLAM material * GetMaterialTag(std::string tag_path)
Definition: material.cpp:16
material_comparison_function::equal
@ equal
FieldReferenceField
Class representing a fieldref tag field.
Definition: fieldref.h:17
MaterialTagClass::MaterialTagClass
MaterialTagClass()
Definition: material.h:201
CommentField
Class representing a comment field.
Definition: comment.h:29
material_comparison_function::greater_than
@ greater_than
BlockField
Class representing a tag block field, also sometimes referred to as a struct or reflexive in the modd...
Definition: block.h:21
material_comparison_function
material_comparison_function
Definition: material.h:38
InternalUI::Colors::transparent
UI_API ImVec4 transparent()
Definition: debug_ui_colors.cpp:35
BlamTagClass
Class representing a tag class.
Definition: tags.h:131
name
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying reordering converting changing font name
Definition: ARPHICPL.TXT:16
Bitfield8Field
Class representing a bitfield8 tag field.
Definition: bitfield.h:33
material_wrap_modes::clamp
@ clamp