Elaztek Developer Hub
Blamite Game Engine - blam!  00453.06.08.26.0624.blamite
The core library for the Blamite Game Engine.
shader.h
Go to the documentation of this file.
1 // shader [rmsh] - Tag Definition //
3 // -------- //
4 // Part of the Blamite Game Engine //
5 // Copyright (c) Elaztek Studios 2013 - 2023 //
7 
8 
9 #pragma once
10 
11 #include <string>
12 #include <blam/api/v1/types/tags.h>
14 
15 #ifndef BLAM
16 #define BLAM
17 #endif
18 
19 #define tag_rmsh "rmsh"
20 
22 {
23  float1,
24  float2,
25  float3,
26  float4,
27 };
28 
29 
30 #pragma pack(push, 1)
31 struct shader
32 {
33  TAG_ENUM8(shader_method,
34  {
35  raw,
36  pbs,
37  });
38 
40  {
42  bool unused1 : 1;
43  bool unused2 : 1;
44  bool unused3 : 1;
45  bool unused4 : 1;
46  bool unused5 : 1;
47  bool unused6 : 1;
48  bool unused7 : 1;
49  bool unused8 : 1;
50  bool unused9 : 1;
51  bool unused10 : 1;
52  bool unused11 : 1;
53  bool unused12 : 1;
54  bool unused13 : 1;
55  bool unused14 : 1;
56  bool unused15 : 1;
57  };
58 
66  TAG_BLOCK(programs,
67  {
68  TAG_ENUM8(type,
69  {
70  vertex,
71  pixel,
72  geometry,
73  hull,
74  domain,
75  compute,
76  });
77 
78  data_reference syntax_code;
79  data_reference target;
80  data_reference entry_point;
81  data_reference program;
82  });
83  TAG_ENUM8(shader_type,
84  {
85  universal,
86  });
87 
88  TAG_BLOCK(global_parameters,
89  {
90  });
91  TAG_BLOCK(instance_parameters,
92  {
94  struct bitfield8_flags
95  {
96  bool is_array : 1;
97  bool pass_to_pixel_shader : 1;
98  bool unused2 : 1;
99  bool unused3 : 1;
100  bool unused4 : 1;
101  bool unused5 : 1;
102  bool unused6 : 1;
103  bool unused7 : 1;
104  };
105 
106  bitfield8_flags flags;
107  data_reference name;
108  int32_t array_size;
109  });
111 };
112 #pragma pack(pop)
113 
115 {
116 public:
118  {
119  class_name_long = "shader";
120  class_name_short = "rmsh";
121  version = 0;
122 
123  revisions = {
124 
125  };
126 
127  tag_size = 324;
128 
129  fields =
130  {
131  new Enum8Field("shader method", "",
132  {
133  "raw",
134  "pbs",
135  }),
136  new Bitfield16Field("flags", "",
137  {
138  "prefer referenced programs",
139  }),
140  new CommentField("[raw] shader programs",
141  "The parameters listed below are only valid when shader method is set to \"raw\". This approach allows direct creation of shader programs and does not include any additional code or functionality offered with PBR or Unlit materials."),
142  new TagReferenceField("vertex program", "", { "rmsp"}),
143  new TagReferenceField("pixel program", "", { }),
144  new TagReferenceField("geometry program", "", { "rmsp"}),
145  new TagReferenceField("hull program", "", { }),
146  new TagReferenceField("domain program", "", { }),
147  new TagReferenceField("compute program", "", { }),
148  new BlockField(129, "programs", "",
149  {
150  new Enum8Field("type", "",
151  {
152  "vertex",
153  "pixel",
154  "geometry",
155  "hull",
156  "domain",
157  "compute",
158  }),
159  new DataReferenceField("syntax code", ""),
160  new DataReferenceField("target", ""),
161  new DataReferenceField("entry point", ""),
162  new DataReferenceField("program", ""),
163  }),
164  new CommentField("$$$ WARNING",
165  "The fields below are used only for using shaders which directly extend from PBR materials. While functional, they are also more error-prone and shader errors can (and often will) result in outright engine crashes.\n"
166  "\n"
167  "You are strongly encouraged to *only* use standalone shader programs as outlined above. If you experience performance problems using them with many objects, you may use the below shader approach - however this functionality may be removed outright in the future."),
168  new CommentField("[pbr] shader config",
169  "The parameters listed below are only valid when shader method is set to \"pbr\". This approach aims to offer the same functionality as raw shaders, but does so while basing off of PBR materials, allowing some additional functionality out of the box."),
170  new Enum8Field("shader type", "",
171  {
172  "universal",
173  }),
174  new BlockField(0, "global parameters", "",
175  {
176  }),
177  new BlockField(38, "instance parameters", "",
178  {
179  new Enum8Field("type", "",
180  {
181  "float1",
182  "float2",
183  "float3",
184  "float4",
185  }),
186  new Bitfield8Field("flags", "",
187  {
188  "is array",
189  "pass to pixel shader",
190  }),
191  new DataReferenceField("name", ""),
192  new Int32Field("array size", ""),
193  }),
194  new DataReferenceField("source", ""),
195 
196  };
197  }
198 };
199 
200 namespace Blam::Content::Tags
201 {
202  BLAM shader* GetShaderTag(std::string tag_path);
203 }
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:181
shader::TAG_BLOCK
TAG_BLOCK(programs, { TAG_ENUM8(type, { vertex, pixel, geometry, hull, domain, compute, });data_reference syntax_code;data_reference target;data_reference entry_point;data_reference program;})
shader::bitfield16_flags::unused10
bool unused10
Definition: shader.h:51
shader::hull_program
tag_reference hull_program
Definition: shader.h:63
shader::bitfield16_flags
Definition: shader.h:39
shader::bitfield16_flags::unused14
bool unused14
Definition: shader.h:55
shader_parameter_type::float2
@ float2
shader::vertex_program
tag_reference vertex_program
Definition: shader.h:60
uint8_t
unsigned char uint8_t
Definition: stdint.h:15
shader::flags
bitfield16_flags flags
Bitfield data for flags. See #bitfield16_flags for details.
Definition: shader.h:59
DataReferenceField
Class representing a data reference, or dataref for short.
Definition: dataref.h:19
Bitfield16Field
Class representing a bitfield16 tag field.
Definition: bitfield.h:44
shader::domain_program
tag_reference domain_program
Definition: shader.h:64
TagReferenceField
Class representing a tag reference, or tagref for short.
Definition: tagref.h:20
Blam::API::v1::Tags::GetTagData
BLAM_EXT_API BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: api.cpp:208
BlamTagClass::fields
std::vector< BlamTagClassField * > fields
A series of tag fields that store the layout of the tag.
Definition: tags.h:209
shader::bitfield16_flags::unused2
bool unused2
Definition: shader.h:43
shader::bitfield16_flags::unused15
bool unused15
Definition: shader.h:56
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:208
int32_t
int int32_t
Definition: stdint.h:13
shader
Definition: shader.h:31
shader::bitfield16_flags::unused8
bool unused8
Definition: shader.h:49
shader::bitfield16_flags::unused11
bool unused11
Definition: shader.h:52
shader::bitfield16_flags::unused4
bool unused4
Definition: shader.h:45
plugins.h
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:206
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tags.h:207
shader::pixel_program
tag_reference pixel_program
Definition: shader.h:61
tag_reference
Structure representing a tag reference.
Definition: tags.h:289
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:205
shader::TAG_ENUM8
TAG_ENUM8(shader_method, { raw, pbs, })
shader::bitfield16_flags::unused6
bool unused6
Definition: shader.h:47
Enum8Field
Definition: enum.h:33
shader::bitfield16_flags::unused1
bool unused1
Definition: shader.h:42
BLAM
#define BLAM
Definition: shader.h:16
shader::bitfield16_flags::unused3
bool unused3
Definition: shader.h:44
Int32Field
Class representing an int32 tag field.
Definition: int.h:46
shader::bitfield16_flags::unused12
bool unused12
Definition: shader.h:53
shader::compute_program
tag_reference compute_program
Definition: shader.h:65
data_reference
Structure representing a data reference.
Definition: tags.h:342
shader::bitfield16_flags::unused13
bool unused13
Definition: shader.h:54
shader::bitfield16_flags::unused7
bool unused7
Definition: shader.h:48
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:210
shader_parameter_type::float4
@ float4
shader::bitfield16_flags::unused5
bool unused5
Definition: shader.h:46
shader::bitfield16_flags::prefer_referenced_programs
bool prefer_referenced_programs
Definition: shader.h:41
shader.h
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:132
Blam::Content::Tags::GetShaderTag
BLAM shader * GetShaderTag(std::string tag_path)
Definition: shader.cpp:13
ShaderTagClass
Definition: shader.h:114
tags.h
ShaderTagClass::ShaderTagClass
ShaderTagClass()
Definition: shader.h:117
shader_parameter_type::float3
@ float3
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:125
CommentField
Class representing a comment field.
Definition: comment.h:29
BlockField
Class representing a tag block field, also sometimes referred to as a struct or reflexive in the modd...
Definition: block.h:19
tag_rmsh
#define tag_rmsh
Definition: shader.h:19
shader_parameter_type
shader_parameter_type
Definition: shader.h:21
BlamTagClass
Class representing a tag class.
Definition: tags.h:202
shader::source
data_reference source
Definition: shader.h:110
Bitfield8Field
Class representing a bitfield8 tag field.
Definition: bitfield.h:33
shader_parameter_type::float1
@ float1
shader::geometry_program
tag_reference geometry_program
Definition: shader.h:62
api.h
shader::bitfield16_flags::unused9
bool unused9
Definition: shader.h:50
BlamTagData::tag_class
std::string tag_class
The tag's short class name.
Definition: tags.h:146