Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Material.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_MATERIAL_H_
34#define DVD_MATERIAL_H_
35
36#include "MaterialEnums.h"
37
40
42
49
52
53namespace Divide {
54
55namespace Attorney {
56 class MaterialRenderBin;
57}
58
59class RenderBin;
60class RenderingComponent;
61
62struct NodeMaterialData;
63struct RenderStateBlock;
64
65enum class BlendProperty : U8;
66enum class ReflectorType : U8;
67
68constexpr F32 Specular_Glass = 0.5f;
69constexpr F32 Specular_Plastic = 0.5f;
70constexpr F32 Specular_Quarts = 0.57f;
71constexpr F32 Specular_Ice = 0.224f;
72constexpr F32 Specular_Water = 0.255f;
73constexpr F32 Specular_Milk = 0.277f;
74constexpr F32 Specular_Skin = 0.35f;
75
76enum class TextureSlot : U8 {
77 UNIT0 = 0,
78 OPACITY,
86 UNIT1,
87 COUNT
88};
89namespace Names {
90 static constexpr const char* textureSlot[] = {
91 "UNIT0",
92 "OPACITY",
93 "NORMALMAP",
94 "HEIGHTMAP",
95 "SPECULAR",
96 "METALNESS",
97 "ROUGHNESS",
98 "OCCLUSION",
99 "EMISSIVE",
100 "UNIT1",
101 "NONE"
102 };
103};
104
105static_assert(std::size(Names::textureSlot) == to_base(TextureSlot::COUNT) + 1);
106
107
108namespace TypeUtil {
109 [[nodiscard]] const char* MaterialDebugFlagToString(const MaterialDebugFlag unitType) noexcept;
110 [[nodiscard]] MaterialDebugFlag StringToMaterialDebugFlag(std::string_view name);
111
112 [[nodiscard]] const char* ShadingModeToString(ShadingMode shadingMode) noexcept;
113 [[nodiscard]] ShadingMode StringToShadingMode(std::string_view name);
114
115 [[nodiscard]] const char* TextureSlotToString(TextureSlot texUsage) noexcept;
116 [[nodiscard]] TextureSlot StringToTextureSlot(std::string_view name);
117
118 [[nodiscard]] const char* TextureOperationToString(TextureOperation textureOp) noexcept;
119 [[nodiscard]] TextureOperation StringToTextureOperation(std::string_view operation);
120
121 [[nodiscard]] const char* BumpMethodToString(BumpMethod bumpMethod) noexcept;
122 [[nodiscard]] BumpMethod StringToBumpMethod(std::string_view name);
123};
124
125class Material final : public CachedResource {
127
128 public:
129 static constexpr F32 MAX_SHININESS = 255.f;
130
135
136 template<typename T> using StatesPerVariant = eastl::array<T, to_base(RenderStagePass::VariantType::COUNT)>;
137 template<typename T> using StateVariantsPerPass = eastl::array<StatesPerVariant<T>, to_base(RenderPassType::COUNT)>;
138 template<typename T> using StatePassesPerStage = eastl::array<StateVariantsPerPass<T>, to_base(RenderStage::COUNT)>;
139
140 enum class UpdatePriority : U8 {
141 Default,
142 Medium,
143 High,
144 COUNT
145 };
146
147 struct ShaderData {
148 Str<64> _depthShaderVertSource = "baseVertexShaders";
151
152 Str<64> _colourShaderVertSource = "baseVertexShaders";
154
157
160 };
161
162 struct Properties {
163 friend class Material;
165
170 PROPERTY_RW(F32, shininess, 0.f);
171 PROPERTY_RW(F32, metallic, 0.f);
172 PROPERTY_RW(F32, roughness, 0.5f);
173 PROPERTY_RW(F32, occlusion, 1.0f);
174 PROPERTY_RW(F32, parallaxFactor, 1.0f);
175
177
179 PROPERTY_R(bool, isStatic, false);
180 PROPERTY_R(bool, isInstanced, false);
184 PROPERTY_R(bool, doubleSided, false);
188 PROPERTY_R(bool, usePackedOMR, false);
189
190 struct Overrides {
191 friend class Divide::Material;
192
194 PROPERTY_R_IW(bool, transparencyEnabled, true);
196 };
197
199
200 PROPERTY_R_IW(bool, cullUpdated, false);
201 PROPERTY_R_IW(bool, transparencyUpdated, false);
202 PROPERTY_R_IW(bool, needsNewShader, true);
203
204 public:
205 void hardwareSkinning(bool state) noexcept;
206 void texturesInFragmentStageOnly(bool state) noexcept;
207 void shadingMode(ShadingMode mode) noexcept;
208 void doubleSided(bool state) noexcept;
209 void receivesShadows(bool state) noexcept;
210 void isRefractive(bool state) noexcept;
211 void isStatic(bool state) noexcept;
212 void isInstanced(bool state) noexcept;
213 void ignoreTexDiffuseAlpha(bool state) noexcept;
214 void bumpMethod(BumpMethod newBumpMethod) noexcept;
215 void toggleTransparency(bool state) noexcept;
216 void useAlphaDiscard(bool state) noexcept;
217 void baseColour(const FColour4& colour) noexcept;
218
219 protected:
220 void saveToXML(const std::string& entryName, boost::property_tree::ptree& pt) const;
221 void loadFromXML(const std::string& entryName, const boost::property_tree::ptree& pt);
222 };
223
225 {
226 Handle<Texture> _ptr{ INVALID_HANDLE<Texture> };
229 bool _srgb{false};
231 };
232
233 public:
234 explicit Material( const ResourceDescriptor<Material>& descriptor );
235
236 static void OnStartup();
237 static void OnShutdown();
238 static void RecomputeShaders();
239 static void Update(U64 deltaTimeUS);
240
242 [[nodiscard]] Handle<Material> clone(const std::string_view nameSuffix);
243 [[nodiscard]] bool load(PlatformContext& context) override;
244 [[nodiscard]] bool unload() override;
246 [[nodiscard]] U32 update(U64 deltaTimeUS);
247
248 void rebuild();
249 void clearRenderStates();
250 void updateCullState();
251
252 void setPipelineLayout(PrimitiveTopology topology, const AttributeMap& shaderAttributes);
253
254 bool setSampler(TextureSlot textureUsageSlot,
255 SamplerDescriptor sampler);
256
257 bool setTexture(TextureSlot textureUsageSlot,
258 Handle<Texture> texture,
259 SamplerDescriptor sampler,
261 bool useInGeometryPasses = false);
262
263 bool setTexture( TextureSlot textureUsageSlot,
264 const ResourceDescriptor<Texture>& texture,
265 SamplerDescriptor sampler,
267 bool useInGeometryPasses = false );
268 void setTextureOperation(TextureSlot textureUsageSlot, TextureOperation op);
269
270 void lockInstancesForRead() const noexcept;
271 void unlockInstancesForRead() const noexcept;
272 void lockInstancesForWrite() const noexcept;
273 void unlockInstancesForWrite() const noexcept;
274
275 [[nodiscard]] const vector<Handle<Material>>& getInstancesLocked() const noexcept;
276 [[nodiscard]] const vector<Handle<Material>>& getInstances() const;
277
280 void setRenderStateBlock(const RenderStateBlock& renderStateBlock, RenderStage stage, RenderPassType pass, RenderStagePass::VariantType variant = RenderStagePass::VariantType::COUNT);
281
282 // Returns the material's hash value (just for the uploadable data)
283 void getData(U32 bestProbeID, NodeMaterialData& dataOut);
284
285 [[nodiscard]] FColour4 getBaseColour(bool& hasTextureOverride, Handle<Texture>& textureOut) const noexcept;
286 [[nodiscard]] FColour3 getEmissive(bool& hasTextureOverride, Handle<Texture>& textureOut) const noexcept;
287 [[nodiscard]] FColour3 getAmbient(bool& hasTextureOverride, Handle<Texture>& textureOut) const noexcept;
288 [[nodiscard]] FColour3 getSpecular(bool& hasTextureOverride, Handle<Texture>& textureOut) const noexcept;
289 [[nodiscard]] F32 getMetallic(bool& hasTextureOverride, Handle<Texture>& textureOut) const noexcept;
290 [[nodiscard]] F32 getRoughness(bool& hasTextureOverride, Handle<Texture>& textureOut) const noexcept;
291 [[nodiscard]] F32 getOcclusion(bool& hasTextureOverride, Handle<Texture>& textureOut) const noexcept;
292 [[nodiscard]] const TextureInfo& getTextureInfo(TextureSlot usage) const;
293 [[nodiscard]] const RenderStateBlock& getOrCreateRenderStateBlock(RenderStagePass renderStagePass);
294 [[nodiscard]] Handle<Texture> getTexture(TextureSlot textureUsage) const;
295 [[nodiscard]] DescriptorSet& getDescriptorSet(const RenderStagePass& renderStagePass);
296 [[nodiscard]] Handle<ShaderProgram> getProgramHandle(RenderStagePass renderStagePass) const;
297 [[nodiscard]] Handle<ShaderProgram> computeAndGetProgramHandle(RenderStagePass renderStagePass);
298 [[nodiscard]] bool hasTransparency() const noexcept;
299 [[nodiscard]] bool isReflective() const noexcept;
300 [[nodiscard]] bool isRefractive() const noexcept;
301 [[nodiscard]] bool canDraw(RenderStagePass renderStagePass, bool& shaderJustFinishedLoading);
302 [[nodiscard]] const ModuleDefines& shaderDefines(ShaderType type) const;
303
304 // type == ShaderType::Count = add to all stages
305 void addShaderDefine(ShaderType type, const string& define, bool addPrefix);
306
307 void saveToXML( const std::string& entryName, boost::property_tree::ptree& pt) const;
308 void loadFromXML( const std::string& entryName, const boost::property_tree::ptree& pt);
309
311 PROPERTY_RW(ShaderData, baseShaderData);
312 PROPERTY_RW(ComputeShaderCBK, computeShaderCBK);
313 PROPERTY_RW(ComputeRenderStateCBK, computeRenderStateCBK);
314 PROPERTY_RW(RecomputeShadersCBK, recomputeShadersCBK);
315 POINTER_R_IW(Material, baseMaterial, nullptr);
317 PROPERTY_R_IW(DescriptorSet, descriptorSetSecondaryPass);
318 PROPERTY_R_IW(DescriptorSet, descriptorSetMainPass);
319 PROPERTY_R_IW(DescriptorSet, descriptorSetPrePass);
320 PROPERTY_R_IW(DescriptorSet, descriptorSetShadow);
321 PROPERTY_RW(bool, ignoreXMLData, false);
322 PROPERTY_RW(bool, ignoreShaderCache, false);
323 PROPERTY_R_IW(AttributeMap, shaderAttributes);
325 private:
326 void getSortKeys(RenderStagePass renderStagePass, I64& shaderKey, I64& textureKey, bool& transparencyFlag) const;
327 void addShaderDefineInternal(ShaderType type, const string& define, bool addPrefix);
328
329 void updateTransparency();
330
331 void recomputeShaders();
332
333 void setShaderProgramInternal(ShaderProgramDescriptor shaderDescriptor, RenderStagePass stagePass);
334
335 void computeAndAppendShaderDefines( ShaderProgramDescriptor& shaderDescriptor, RenderStagePass renderStagePass) const;
336
337 [[nodiscard]] ShaderProgramInfo& shaderInfo(RenderStagePass renderStagePass);
338
339 [[nodiscard]] const ShaderProgramInfo& shaderInfo(RenderStagePass renderStagePass) const;
340
341 void saveRenderStatesToXML(const std::string& entryName, boost::property_tree::ptree& pt) const;
342 void loadRenderStatesFromXML(const std::string& entryName, const boost::property_tree::ptree& pt);
343
344 void saveTextureDataToXML(const std::string& entryName, boost::property_tree::ptree& pt) const;
345 void loadTextureDataFromXML(const std::string& entryName, const boost::property_tree::ptree& pt);
346
347 bool setTextureLocked(TextureSlot textureUsageSlot,
348 Handle<Texture> texture,
349 SamplerDescriptor sampler,
351 bool useInGeometryPasses);
352
353 bool setTextureLocked(TextureSlot textureUsageSlot,
354 const ResourceDescriptor<Texture>& texture,
355 SamplerDescriptor sampler,
357 bool useInGeometryPasses);
358
359 [[nodiscard]] bool usesTextureInShader(TextureSlot slot, bool isPrePass, bool isShadowPass) const noexcept;
360
361 private:
362 GFXDevice* _context = nullptr;
363
365 {
367 bool _isSet{false};
368 };
369
372
375
378
380
382
383 static bool s_shadersDirty;
384};
385
387
388namespace Attorney {
390 static void getSortKeys(Material* material, const RenderStagePass renderStagePass, I64& shaderKey, I64& textureKey, bool& hasTransparency) {
391 material->getSortKeys(renderStagePass, shaderKey, textureKey, hasTransparency);
392 }
393
394 friend class Divide::RenderBin;
395};
396} //namespace Attorney
397
398}; // namespace Divide
399
400#endif //DVD_MATERIAL_H_
401
402#include "Material.inl"
#define PROPERTY_RW(...)
Convenience method to add a class member with public read access and write access.
#define PROPERTY_R_IW(...)
Convenience method to add a class member with public read access but protected write access including...
#define POINTER_R_IW(...)
Convenience method to add a class member with public read access but protected write access including...
#define TYPEDEF_SMART_POINTERS_FOR_TYPE(T)
static void getSortKeys(Material *material, const RenderStagePass renderStagePass, I64 &shaderKey, I64 &textureKey, bool &hasTransparency)
Definition: Material.h:390
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
U32 update(U64 deltaTimeUS)
Returns a bit mask composed of UpdateResult flags.
Definition: Material.cpp:276
static void OnStartup()
Definition: Material.cpp:121
void setRenderStateBlock(const RenderStateBlock &renderStateBlock, RenderStage stage, RenderPassType pass, RenderStagePass::VariantType variant=RenderStagePass::VariantType::COUNT)
Definition: Material.cpp:883
DELEGATE_STD< ShaderProgramDescriptor, Material *, RenderStagePass > ComputeShaderCBK
Definition: Material.h:132
void loadRenderStatesFromXML(const std::string &entryName, const boost::property_tree::ptree &pt)
Definition: Material.cpp:1255
bool setTextureLocked(TextureSlot textureUsageSlot, Handle< Texture > texture, SamplerDescriptor sampler, TextureOperation op, bool useInGeometryPasses)
Definition: Material.cpp:360
eastl::array< T, to_base(RenderStagePass::VariantType::COUNT)> StatesPerVariant
Definition: Material.h:136
FColour4 getBaseColour(bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept
Definition: Material.cpp:1010
Handle< ShaderProgram > computeAndGetProgramHandle(RenderStagePass renderStagePass)
Definition: Material.cpp:516
bool canDraw(RenderStagePass renderStagePass, bool &shaderJustFinishedLoading)
Definition: Material.cpp:554
Handle< Texture > getTexture(TextureSlot textureUsage) const
Definition: Material.inl:68
SharedMutex _textureLock
Definition: Material.h:374
void unlockInstancesForWrite() const noexcept
Definition: Material.inl:52
static constexpr F32 MAX_SHININESS
Definition: Material.h:129
F32 getRoughness(bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept
Definition: Material.cpp:1064
static void RecomputeShaders()
Definition: Material.cpp:131
static void OnShutdown()
Definition: Material.cpp:126
bool hasTransparency() const noexcept
Definition: Material.inl:74
void getData(U32 bestProbeID, NodeMaterialData &dataOut)
Definition: Material.cpp:1086
const TextureInfo & getTextureInfo(TextureSlot usage) const
Definition: Material.inl:117
DELEGATE_STD< void > RecomputeShadersCBK
Definition: Material.h:134
void loadFromXML(const std::string &entryName, const boost::property_tree::ptree &pt)
Definition: Material.cpp:1192
F32 getMetallic(bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept
Definition: Material.cpp:1053
FColour3 getEmissive(bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept
Definition: Material.cpp:1022
void addShaderDefine(ShaderType type, const string &define, bool addPrefix)
Definition: Material.inl:102
void updateCullState()
Definition: Material.cpp:313
void setShaderProgramInternal(ShaderProgramDescriptor shaderDescriptor, RenderStagePass stagePass)
Definition: Material.cpp:437
FColour3 getAmbient(bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept
Definition: Material.cpp:1034
eastl::array< StateVariantsPerPass< T >, to_base(RenderStage::COUNT)> StatePassesPerStage
Definition: Material.h:138
Handle< Material > clone(const std::string_view nameSuffix)
Return a new instance of this material with the name composed of the base material's name and the giv...
Definition: Material.cpp:222
void lockInstancesForRead() const noexcept
Definition: Material.inl:37
static void Update(U64 deltaTimeUS)
Definition: Material.cpp:136
std::array< TextureInfo, to_base(TextureSlot::COUNT)> _textures
Definition: Material.h:379
GFXDevice * _context
Definition: Material.h:362
bool usesTextureInShader(TextureSlot slot, bool isPrePass, bool isShadowPass) const noexcept
Definition: Material.cpp:785
DescriptorSet & getDescriptorSet(const RenderStagePass &renderStagePass)
Definition: Material.cpp:1127
void addShaderDefineInternal(ShaderType type, const string &define, bool addPrefix)
Definition: Material.inl:122
void setTextureOperation(TextureSlot textureUsageSlot, TextureOperation op)
Definition: Material.cpp:425
void clearRenderStates()
Definition: Material.cpp:301
void saveTextureDataToXML(const std::string &entryName, boost::property_tree::ptree &pt) const
Definition: Material.cpp:1287
vector< Handle< Material > > _instances
Definition: Material.h:377
bool isReflective() const noexcept
Definition: Material.inl:80
SharedMutex _instanceLock
Definition: Material.h:376
StatePassesPerStage< RenderStateBlockEntry > _defaultRenderStates
Definition: Material.h:371
std::array< ModuleDefines, to_base(ShaderType::COUNT)> _extraShaderDefines
Definition: Material.h:373
const RenderStateBlock & getOrCreateRenderStateBlock(RenderStagePass renderStagePass)
Definition: Material.cpp:940
static bool s_shadersDirty
Definition: Material.h:383
ShaderProgramInfo & shaderInfo(RenderStagePass renderStagePass)
Definition: Material.inl:92
bool isRefractive() const noexcept
Definition: Material.inl:86
FColour3 getSpecular(bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept
Definition: Material.cpp:1042
void updateTransparency()
Definition: Material.cpp:906
void recomputeShaders()
Definition: Material.cpp:488
bool setSampler(TextureSlot textureUsageSlot, SamplerDescriptor sampler)
Definition: Material.cpp:348
DELEGATE_STD< void, Material *, RenderStagePass, RenderStateBlock & > ComputeRenderStateCBK
Definition: Material.h:133
StatePassesPerStage< ShaderProgramInfo > _shaderInfo
Definition: Material.h:370
const ModuleDefines & shaderDefines(ShaderType type) const
Definition: Material.inl:138
const vector< Handle< Material > > & getInstancesLocked() const noexcept
Definition: Material.inl:57
void getSortKeys(RenderStagePass renderStagePass, I64 &shaderKey, I64 &textureKey, bool &transparencyFlag) const
Definition: Material.cpp:995
bool unload() override
Definition: Material.cpp:843
void setPipelineLayout(PrimitiveTopology topology, const AttributeMap &shaderAttributes)
Definition: Material.cpp:331
bool setTexture(TextureSlot textureUsageSlot, Handle< Texture > texture, SamplerDescriptor sampler, TextureOperation op, bool useInGeometryPasses=false)
Definition: Material.cpp:415
F32 getOcclusion(bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept
Definition: Material.cpp:1075
void computeAndAppendShaderDefines(ShaderProgramDescriptor &shaderDescriptor, RenderStagePass renderStagePass) const
Definition: Material.cpp:607
size_t _shaderAttributesHash
Definition: Material.h:381
eastl::array< StatesPerVariant< T >, to_base(RenderPassType::COUNT)> StateVariantsPerPass
Definition: Material.h:137
const vector< Handle< Material > > & getInstances() const
Definition: Material.inl:62
void saveRenderStatesToXML(const std::string &entryName, boost::property_tree::ptree &pt) const
Definition: Material.cpp:1211
Handle< ShaderProgram > getProgramHandle(RenderStagePass renderStagePass) const
Definition: Material.cpp:539
void loadTextureDataFromXML(const std::string &entryName, const boost::property_tree::ptree &pt)
Definition: Material.cpp:1324
void saveToXML(const std::string &entryName, boost::property_tree::ptree &pt) const
Definition: Material.cpp:1183
void lockInstancesForWrite() const noexcept
Definition: Material.inl:47
void unlockInstancesForRead() const noexcept
Definition: Material.inl:42
This class contains a list of "RenderBinItem"'s and stores them sorted depending on designation.
Definition: RenderBin.h:112
An API-independent representation of a texture.
Definition: Texture.h:83
FColour4 WHITE
Random stuff added for convenience.
Definition: Colours.cpp:8
static constexpr const char * textureSlot[]
Definition: Material.h:90
TextureSlot StringToTextureSlot(std::string_view name)
Definition: Material.cpp:51
BumpMethod StringToBumpMethod(std::string_view name)
Definition: Material.cpp:69
const char * BumpMethodToString(BumpMethod bumpMethod) noexcept
Definition: Material.cpp:64
const char * ShadingModeToString(ShadingMode shadingMode) noexcept
Definition: Material.cpp:82
const char * TextureSlotToString(TextureSlot texUsage) noexcept
Definition: Material.cpp:46
const char * MaterialDebugFlagToString(const MaterialDebugFlag unitType) noexcept
Definition: Material.cpp:28
TextureOperation StringToTextureOperation(std::string_view operation)
Definition: Material.cpp:105
const char * TextureOperationToString(TextureOperation textureOp) noexcept
Definition: Material.cpp:100
ShadingMode StringToShadingMode(std::string_view name)
Definition: Material.cpp:87
MaterialDebugFlag StringToMaterialDebugFlag(std::string_view name)
Definition: Material.cpp:33
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
bool load() override
std::function< Ret(Args...) > DELEGATE_STD
constexpr F32 Specular_Quarts
Definition: Material.h:70
constexpr F32 Specular_Milk
Definition: Material.h:73
MaterialDebugFlag
Definition: MaterialEnums.h:37
uint8_t U8
vector< ModuleDefine > ModuleDefines
std::shared_mutex SharedMutex
Definition: SharedMutex.h:43
constexpr F32 Specular_Skin
Definition: Material.h:74
BlendProperty
Specifies how the red, green, blue, and alpha source blending factors are computed.
TextureOperation
How should each texture be added.
eastl::vector< Type > vector
Definition: Vector.h:42
constexpr F32 Specular_Glass
Definition: Material.h:68
constexpr F32 Specular_Plastic
Definition: Material.h:69
constexpr F32 Specular_Water
Definition: Material.h:72
ShaderType
Available shader stages.
constexpr F32 Specular_Ice
Definition: Material.h:71
int64_t I64
uint32_t U32
TranslucencySource
TextureSlot
Definition: Material.h:76
uint64_t U64
constexpr auto to_base(const Type value) -> Type
PROPERTY_R_IW(bool, ignoreTexDiffuseAlpha, false)
PROPERTY_R_IW(bool, useAlphaDiscard, true)
PROPERTY_R_IW(bool, transparencyEnabled, true)
void receivesShadows(bool state) noexcept
void doubleSided(bool state) noexcept
PROPERTY_RW(FColour3, specular, DefaultColours::BLACK)
PROPERTY_R(bool, receivesShadows, true)
void texturesInFragmentStageOnly(bool state) noexcept
void isInstanced(bool state) noexcept
PROPERTY_R(bool, isInstanced, false)
void bumpMethod(BumpMethod newBumpMethod) noexcept
PROPERTY_R_IW(bool, transparencyUpdated, false)
PROPERTY_R_IW(bool, needsNewShader, true)
PROPERTY_RW(Overrides, overrides)
PROPERTY_R(bool, isStatic, false)
void ignoreTexDiffuseAlpha(bool state) noexcept
PROPERTY_RW(F32, occlusion, 1.0f)
PROPERTY_RW(F32, shininess, 0.f)
void hardwareSkinning(bool state) noexcept
void baseColour(const FColour4 &colour) noexcept
void saveToXML(const std::string &entryName, boost::property_tree::ptree &pt) const
PROPERTY_RW(F32, parallaxFactor, 1.0f)
PROPERTY_RW(SpecularGlossiness, specGloss)
PROPERTY_R(bool, hardwareSkinning, false)
PROPERTY_RW(FColour3, emissive, DefaultColours::BLACK)
PROPERTY_R(ShadingMode, shadingMode, ShadingMode::COUNT)
void isStatic(bool state) noexcept
PROPERTY_R(bool, texturesInFragmentStageOnly, true)
PROPERTY_RW(F32, metallic, 0.f)
PROPERTY_RW(FColour3, ambient, DefaultColours::BLACK)
PROPERTY_R(FColour4, baseColour, DefaultColours::WHITE)
PROPERTY_R_IW(bool, cullUpdated, false)
void loadFromXML(const std::string &entryName, const boost::property_tree::ptree &pt)
void toggleTransparency(bool state) noexcept
PROPERTY_RW(F32, roughness, 0.5f)
void shadingMode(ShadingMode mode) noexcept
PROPERTY_R(bool, usePackedOMR, false)
If the metalness textures has 3 (or 4) channels, those channels are interpreted automatically as R: O...
void useAlphaDiscard(bool state) noexcept
PROPERTY_R(bool, isRefractive, false)
PROPERTY_R(BumpMethod, bumpMethod, BumpMethod::NONE)
PROPERTY_R(TranslucencySource, translucencySource, TranslucencySource::COUNT)
PROPERTY_R(bool, doubleSided, false)
Definition: Material.h:365
Str< 32 > _shadowShaderVertVariant
Definition: Material.h:150
Str< 64 > _depthShaderFragSource
Definition: Material.h:155
Str< 64 > _colourShaderFragSource
Definition: Material.h:158
Str< 32 > _colourShaderVertVariant
Definition: Material.h:153
Str< 32 > _depthShaderVertVariant
Definition: Material.h:149
Str< 64 > _colourShaderVertSource
Definition: Material.h:152
Str< 32 > _depthShaderFragVariant
Definition: Material.h:156
Str< 32 > _colourShaderFragVariant
Definition: Material.h:159
Str< 64 > _depthShaderVertSource
Definition: Material.h:148
bool _useInGeometryPasses
Setting this to false will fallback to auto-usage selection (e.g. opacity tex will be used for alpha ...
Definition: Material.h:230
SamplerDescriptor _sampler
Definition: Material.h:227
Handle< Texture > _ptr
Definition: Material.h:226
TextureOperation _operation
Definition: Material.h:228