Elaztek Developer Hub
Blamite Game Engine - blam!  00367.02.08.23.1815.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  });
54 
55  TAG_BLOCK(pbr_material,
56  {
57  bitfield16 flags;
58 
59  TAG_BLOCK(textures,
60  {
61  TAG_ENUM(texture_type,
62  {
63  diffuse,
64  normal,
65  specular,
66  metallic,
67  roughness,
68  detail_weight,
69  detail_0,
70  detail_1,
71  detail_2,
72  detail_3,
73  detail_normal_0,
74  detail_normal_1,
75  detail_normal_2,
76  detail_normal_3,
77  emissive,
78  reflection
79  });
80 
81  tag_reference texture;
82 
83  // SAMPLER PROPERTIES
84  material_filter_modes filter_mode_min;
85  material_filter_modes filter_mode_mag;
86  material_filter_modes filter_mode_mip;
87 
88  material_wrap_modes wrap_mode_x;
89  material_wrap_modes wrap_mode_y;
90  material_wrap_modes wrap_mode_z;
91 
92  real lod_bias;
93  real max_anisotropy;
94 
95  material_comparison_function sampler_comparison_function;
96 
97  color border_color;
98  real min_lod;
99  real max_lod;
100 
101  vector2 offset;
102  vector2 scale;
103  });
104 
105  // BRDF
106 
113  bitfield16 brdf_flags;
114 
115  TAG_ENUM(brdf,
116  {
117  default,
118  cook_torrance,
119  blinn_phong,
120  });
121 
122  // ALPHA
123  material_comparison_function alpha_comparison_function;
124 
125  bitfield16 alpha_flags;
126  real alpha_test_threshold;
127 
128  // COLORS
129  color diffuse_color;
130  color background_diffuse_color;
131  color emissive_color;
132 
133  // OTHER SHIT
134  real clear_coat;
135  real clear_coat_roughness;
136 
137  // TRANSPARENCY
138  real transparency;
139  bitfield16 transparency_flags;
140 
141  TAG_ENUM(transparency_mode,
142  {
143  none,
144  transparent,
145  fade,
146  refractive
147  });
148 
149  real refraction_strength;
150 
151  // WORKFLOWS
152  TAG_ENUM(workflow,
153  {
154  specular,
155  specular_fresnel,
156  metallic
157  });
158 
159  color specular_color;
160  real metalness;
161  real roughness;
162 
163 
164  });
165 };
166 #pragma pack(pop)
167 
169 {
170 public:
172  {
173  class_name_long = "material";
174  class_name_short = "mat";
175  version = 4;
176 
177  revisions = {
178  {1, "haloman30", "Initial implementation."},
179  {2, "haloman30", "Add settings for texture sampler."},
180  {3, "haloman30", "Combine sampler and texture fields into tag block, with each entry specifying a texture."},
181  {4, "haloman30", "Add fields for texture offset and scale."}
182  };
183 
184  tag_size = sizeof(material);
185 
186  fields =
187  {
188  new CommentField("Material", ""),
189 
190  new AsciiField("id", ""),
191  new Enum32Field("material type", "",
192  {
193  "pbr"
194  }),
195 
196  new BlockField(sizeof(material::pbr_material_entry), "pbr material", "",
197  {
198  new Bitfield16Field("", "",
199  {
200  "uses two sided lighting",
201  "receives shadows",
202  "use emissive as lightmap"
203  }),
204 
205  new BlockField(sizeof(material::pbr_material_entry::textures_entry), "textures", "",
206  {
207  new CommentField("TEXTURES", ""),
208  new Enum32Field("texture type", "",
209  {
210  "diffuse",
211  "normal",
212  "specular",
213  "metallic",
214  "roughness",
215  "detail_weight",
216  "detail_0",
217  "detail_1",
218  "detail_2",
219  "detail_3",
220  "detail_normal_0",
221  "detail_normal_1",
222  "detail_normal_2",
223  "detail_normal_3",
224  "emissive",
225  "reflection"
226  }),
227  new TagReferenceField("texture", "", { "bitm" }),
228 
229  new CommentField("SAMPLER", ""),
230  new Enum32Field("filter mode (min)", "",
231  {
232  "inherit from bitmap",
233  "none",
234  "point",
235  "linear",
236  "anisotropic"
237  }),
238  new Enum32Field("filter mode (mag)", "",
239  {
240  "inherit from bitmap",
241  "none",
242  "point",
243  "linear",
244  "anisotropic"
245  }),
246  new Enum32Field("filter mode (mip)", "",
247  {
248  "inherit from bitmap",
249  "none",
250  "point",
251  "linear",
252  "anisotropic"
253  }),
254  new Enum32Field("wrap mode x", "",
255  {
256  "wrap",
257  "mirror",
258  "clamp",
259  "border"
260  }),
261  new Enum32Field("wrap mode y", "",
262  {
263  "wrap",
264  "mirror",
265  "clamp",
266  "border"
267  }),
268  new Enum32Field("wrap mode z", "",
269  {
270  "wrap",
271  "mirror",
272  "clamp",
273  "border"
274  }),
275  new RealField("lod bias", ""),
276  new RealField("max anisotropy", ""),
277  new Enum32Field("sampler comparison function", "",
278  {
279  "always fail",
280  "always pass",
281  "less than",
282  "less than or equal",
283  "equal",
284  "not equal",
285  "greater than or equal",
286  "greater than",
287  "disabled"
288  }),
289  new ColorField("border color", ""),
290  new RealField("min lod", ""),
291  new RealField("max lod", ""),
292  new Vector2Field("offset", ""),
293  new Vector2Field("scale", "")
294  }),
295 
296  new CommentField("BRDF", "bidirectional reflectance distribution function"),
297  new Bitfield16Field("brdf flags", "",
298  {
299  "uncorrelated",
300  "separate diffuse fresnel",
301  "legacy math",
302  "full legacy"
303  }),
304  new Enum32Field("brdf function", "",
305  {
306  "default",
307  "cook-torrance",
308  "blinn-phong"
309  }),
310 
311  new CommentField("ALPHA", ""),
312  new Enum32Field("alpha comparison function", "",
313  {
314  "always fail",
315  "always pass",
316  "less than",
317  "less than or equal",
318  "equal",
319  "not equal",
320  "greater than or equal",
321  "greater than"
322  }),
323  new Bitfield16Field("alpha flags", "",
324  {
325  "shadow caster only",
326  "use alpha from texture"
327  }),
328  new RealField("alpha test threshold", ""),
329 
330  new CommentField("COLORS", ""),
331  new ColorField("diffuse color", ""),
332  new ColorField("background diffuse color", ""),
333  new ColorField("emissive color", ""),
334 
335 
336  new CommentField("CLEAR COAT", ""),
337  new RealField("clear coat amount", ""),
338  new RealField("clear coat roughness", ""),
339 
340  new CommentField("TRANSPARENCY", ""),
341  new RealField("transparency amount", ""),
342  new Bitfield16Field("transparency flags", "",
343  {
344  "use alpha from textures",
345  "change blend block"
346  }),
347  new Enum32Field("transparency mode", "",
348  {
349  "none",
350  "transparent",
351  "fade",
352  "refractive"
353  }),
354  new RealField("refraction strength", ""),
355 
356  new CommentField("WORKFLOWS", ""),
357  new Enum32Field("workflows", "",
358  {
359  "specular",
360  "specular (fresnel)",
361  "metallic"
362  }),
363  new ColorField("specular color", ""),
364  new RealField("metalness", ""),
365  new RealField("roughness", ""),
366 
367 
368  }),
369  };
370  }
371 };
372 
373 namespace Blam::Content::Tags
374 {
375  BLAM material* GetMaterialTag(std::string tag_path);
376 }
mat_cmp_less_equal
@ mat_cmp_less_equal
Definition: material.h:32
ascii
char ascii[128]
Typedef for an ascii field, used in tag data definitions.
Definition: tags.h:313
vector2
BlamVector2 vector2
Typedef for a vector2 field, used in tag definitions.
Definition: tags.h:316
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:151
RealField
Class representing a real tag field.
Definition: real.h:10
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:12
Vector2Field
Class representing a vector2 tag field.
Definition: vector.h:28
mat_fm_none
@ mat_fm_none
Definition: material.h:13
mat_cmp_equal
@ mat_cmp_equal
Definition: material.h:33
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:319
mat_cmp_always_fail
@ mat_cmp_always_fail
Definition: material.h:29
Bitfield16Field
Class representing a bitfield16 tag field.
Definition: bitfield.h:38
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, { default, 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;real clear_coat_roughness;real transparency;bitfield16 transparency_flags;TAG_ENUM(transparency_mode, { none, transparent, fade, refractive });real refraction_strength;TAG_ENUM(workflow, { specular, specular_fresnel, metallic });color specular_color;real metalness;real roughness;})
TagReferenceField
Class representing a tag reference, or tagref for short.
Definition: tagref.h:14
Enum32Field
Definition: enum.h:40
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: tagclass.h:49
material_wrap_modes
material_wrap_modes
Definition: material.h:19
mat_wrap_mirror
@ mat_wrap_mirror
Definition: material.h:22
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tagclass.h:47
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tagclass.h:48
mat_fm_anisotropic
@ mat_fm_anisotropic
Definition: material.h:16
tag_reference
Structure representing a tag reference.
Definition: tags.h:158
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tagclass.h:46
material
Structure representing a Material tag.
Definition: material.h:46
mat_cmp_not_equal
@ mat_cmp_not_equal
Definition: material.h:34
MaterialTagClass
Definition: material.h:168
material::id
ascii id
Definition: material.h:48
mat_cmp_always_pass
@ mat_cmp_always_pass
Definition: material.h:30
real
float real
Typedef for a 'real', aka a float.
Definition: tags.h:315
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:250
material::TAG_ENUM
TAG_ENUM(material_type, { pbr })
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: tagclass.h:53
BLAM
#define BLAM
Definition: material.h:7
ColorField
Class representing a color tag field.
Definition: color.h:13
mat_wrap_wrap
@ mat_wrap_wrap
Definition: material.h:21
tagclass.h
material_comparison_function
material_comparison_function
Definition: material.h:27
mat_cmp_disabled
@ mat_cmp_disabled
Definition: material.h:37
Blam::Content::Tags::GetMaterialTag
BLAM material * GetMaterialTag(std::string tag_path)
Definition: material.cpp:5
MaterialTagClass::MaterialTagClass
MaterialTagClass()
Definition: material.h:171
CommentField
Class representing a comment field.
Definition: comment.h:23
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:13
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: tagclass.h:43
BlamTagClass::fields
std::vector< BlamPluginField * > fields
A series of tag fields that store the layout of the tag.
Definition: tagclass.h:51