![]() |
Divide Framework 0.1
A free and open-source 3D Framework under heavy development
|
#include <Material.h>
Classes | |
struct | Properties |
struct | RenderStateBlockEntry |
struct | ShaderData |
struct | TextureInfo |
Public Types | |
enum class | UpdatePriority : U8 { Default , Medium , High , COUNT } |
using | SpecularGlossiness = vec2< F32 > |
using | ComputeShaderCBK = DELEGATE_STD< ShaderProgramDescriptor, Material *, RenderStagePass > |
using | ComputeRenderStateCBK = DELEGATE_STD< void, Material *, RenderStagePass, RenderStateBlock & > |
using | RecomputeShadersCBK = DELEGATE_STD< void > |
template<typename T > | |
using | StatesPerVariant = eastl::array< T, to_base(RenderStagePass::VariantType::COUNT)> |
template<typename T > | |
using | StateVariantsPerPass = eastl::array< StatesPerVariant< T >, to_base(RenderPassType::COUNT)> |
template<typename T > | |
using | StatePassesPerStage = eastl::array< StateVariantsPerPass< T >, to_base(RenderStage::COUNT)> |
Public Member Functions | |
Material (const ResourceDescriptor< Material > &descriptor) | |
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 give name suffix (clone calls CreateResource internally!). | |
bool | load (PlatformContext &context) override |
Loading and unloading interface. | |
bool | unload () override |
U32 | update (U64 deltaTimeUS) |
Returns a bit mask composed of UpdateResult flags. | |
void | rebuild () |
void | clearRenderStates () |
void | updateCullState () |
void | setPipelineLayout (PrimitiveTopology topology, const AttributeMap &shaderAttributes) |
bool | setSampler (TextureSlot textureUsageSlot, SamplerDescriptor sampler) |
bool | setTexture (TextureSlot textureUsageSlot, Handle< Texture > texture, SamplerDescriptor sampler, TextureOperation op, bool useInGeometryPasses=false) |
bool | setTexture (TextureSlot textureUsageSlot, const ResourceDescriptor< Texture > &texture, SamplerDescriptor sampler, TextureOperation op, bool useInGeometryPasses=false) |
void | setTextureOperation (TextureSlot textureUsageSlot, TextureOperation op) |
void | lockInstancesForRead () const noexcept |
void | unlockInstancesForRead () const noexcept |
void | lockInstancesForWrite () const noexcept |
void | unlockInstancesForWrite () const noexcept |
const vector< Handle< Material > > & | getInstancesLocked () const noexcept |
const vector< Handle< Material > > & | getInstances () const |
void | setRenderStateBlock (const RenderStateBlock &renderStateBlock, RenderStage stage, RenderPassType pass, RenderStagePass::VariantType variant=RenderStagePass::VariantType::COUNT) |
void | getData (U32 bestProbeID, NodeMaterialData &dataOut) |
FColour4 | getBaseColour (bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept |
FColour3 | getEmissive (bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept |
FColour3 | getAmbient (bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept |
FColour3 | getSpecular (bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept |
F32 | getMetallic (bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept |
F32 | getRoughness (bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept |
F32 | getOcclusion (bool &hasTextureOverride, Handle< Texture > &textureOut) const noexcept |
const TextureInfo & | getTextureInfo (TextureSlot usage) const |
const RenderStateBlock & | getOrCreateRenderStateBlock (RenderStagePass renderStagePass) |
Handle< Texture > | getTexture (TextureSlot textureUsage) const |
DescriptorSet & | getDescriptorSet (const RenderStagePass &renderStagePass) |
Handle< ShaderProgram > | getProgramHandle (RenderStagePass renderStagePass) const |
Handle< ShaderProgram > | computeAndGetProgramHandle (RenderStagePass renderStagePass) |
bool | hasTransparency () const noexcept |
bool | isReflective () const noexcept |
bool | isRefractive () const noexcept |
bool | canDraw (RenderStagePass renderStagePass, bool &shaderJustFinishedLoading) |
const ModuleDefines & | shaderDefines (ShaderType type) const |
void | addShaderDefine (ShaderType type, const string &define, bool addPrefix) |
void | saveToXML (const std::string &entryName, boost::property_tree::ptree &pt) const |
void | loadFromXML (const std::string &entryName, const boost::property_tree::ptree &pt) |
PROPERTY_RW (Properties, properties) | |
PROPERTY_RW (ShaderData, baseShaderData) | |
PROPERTY_RW (ComputeShaderCBK, computeShaderCBK) | |
PROPERTY_RW (ComputeRenderStateCBK, computeRenderStateCBK) | |
PROPERTY_RW (RecomputeShadersCBK, recomputeShadersCBK) | |
POINTER_R_IW (Material, baseMaterial, nullptr) | |
PROPERTY_RW (UpdatePriority, updatePriorirty, UpdatePriority::Default) | |
PROPERTY_R_IW (DescriptorSet, descriptorSetSecondaryPass) | |
PROPERTY_R_IW (DescriptorSet, descriptorSetMainPass) | |
PROPERTY_R_IW (DescriptorSet, descriptorSetPrePass) | |
PROPERTY_R_IW (DescriptorSet, descriptorSetShadow) | |
PROPERTY_RW (bool, ignoreXMLData, false) | |
PROPERTY_RW (bool, ignoreShaderCache, false) | |
Useful for debugging. | |
PROPERTY_R_IW (AttributeMap, shaderAttributes) | |
PROPERTY_R_IW (PrimitiveTopology, topology, PrimitiveTopology::COUNT) | |
![]() | |
CachedResource (const ResourceDescriptorBase &descriptor, std::string_view typeName) | |
virtual bool | load (PlatformContext &context) |
Loading and unloading interface. | |
virtual bool | postLoad () |
virtual bool | unload () |
void | setState (ResourceState currentState) final |
![]() | |
Resource (std::string_view resourceName, std::string_view typeName) | |
ResourceState | getState () const noexcept |
PROPERTY_R (Str< 32 >, typeName) | |
PROPERTY_R (Str< 256 >, resourceName) | |
![]() | |
GUIDWrapper () noexcept | |
GUIDWrapper (const GUIDWrapper &old) noexcept | |
GUIDWrapper (GUIDWrapper &&old) noexcept | |
virtual | ~GUIDWrapper ()=default |
FORCE_INLINE I64 | getGUID () const noexcept |
GUIDWrapper & | operator= (const GUIDWrapper &old)=delete |
GUIDWrapper & | operator= (GUIDWrapper &&other)=delete |
Static Public Member Functions | |
static void | OnStartup () |
static void | OnShutdown () |
static void | RecomputeShaders () |
static void | Update (U64 deltaTimeUS) |
![]() | |
static I64 | generateGUID () noexcept |
Static Public Attributes | |
static constexpr F32 | MAX_SHININESS = 255.f |
Private Member Functions | |
void | getSortKeys (RenderStagePass renderStagePass, I64 &shaderKey, I64 &textureKey, bool &transparencyFlag) const |
void | addShaderDefineInternal (ShaderType type, const string &define, bool addPrefix) |
void | updateTransparency () |
void | recomputeShaders () |
void | setShaderProgramInternal (ShaderProgramDescriptor shaderDescriptor, RenderStagePass stagePass) |
void | computeAndAppendShaderDefines (ShaderProgramDescriptor &shaderDescriptor, RenderStagePass renderStagePass) const |
ShaderProgramInfo & | shaderInfo (RenderStagePass renderStagePass) |
const ShaderProgramInfo & | shaderInfo (RenderStagePass renderStagePass) const |
void | saveRenderStatesToXML (const std::string &entryName, boost::property_tree::ptree &pt) const |
void | loadRenderStatesFromXML (const std::string &entryName, const boost::property_tree::ptree &pt) |
void | saveTextureDataToXML (const std::string &entryName, boost::property_tree::ptree &pt) const |
void | loadTextureDataFromXML (const std::string &entryName, const boost::property_tree::ptree &pt) |
bool | setTextureLocked (TextureSlot textureUsageSlot, Handle< Texture > texture, SamplerDescriptor sampler, TextureOperation op, bool useInGeometryPasses) |
bool | setTextureLocked (TextureSlot textureUsageSlot, const ResourceDescriptor< Texture > &texture, SamplerDescriptor sampler, TextureOperation op, bool useInGeometryPasses) |
bool | usesTextureInShader (TextureSlot slot, bool isPrePass, bool isShadowPass) const noexcept |
Private Attributes | |
GFXDevice * | _context = nullptr |
StatePassesPerStage< ShaderProgramInfo > | _shaderInfo {} |
StatePassesPerStage< RenderStateBlockEntry > | _defaultRenderStates {} |
std::array< ModuleDefines, to_base(ShaderType::COUNT)> | _extraShaderDefines {} |
SharedMutex | _textureLock {} |
SharedMutex | _instanceLock |
vector< Handle< Material > > | _instances {} |
std::array< TextureInfo, to_base(TextureSlot::COUNT)> | _textures |
size_t | _shaderAttributesHash { 0u } |
Static Private Attributes | |
static bool | s_shadersDirty = false |
Friends | |
class | Attorney::MaterialRenderBin |
Additional Inherited Members | |
![]() | |
PROPERTY_RW (ResourcePath, assetLocation) | |
PROPERTY_RW (Str< 256 >, assetName) | |
PROPERTY_R (size_t, descriptorHash) | |
virtual void | setState (ResourceState currentState) |
![]() | |
Mutex | _callbackLock {} |
![]() | |
std::atomic< ResourceState > | _resourceState |
![]() | |
const I64 | _guid |
Definition at line 125 of file Material.h.
using Divide::Material::ComputeRenderStateCBK = DELEGATE_STD<void, Material*, RenderStagePass, RenderStateBlock&> |
Definition at line 133 of file Material.h.
using Divide::Material::ComputeShaderCBK = DELEGATE_STD<ShaderProgramDescriptor, Material*, RenderStagePass> |
Definition at line 132 of file Material.h.
using Divide::Material::RecomputeShadersCBK = DELEGATE_STD<void> |
Definition at line 134 of file Material.h.
using Divide::Material::SpecularGlossiness = vec2<F32> |
Definition at line 131 of file Material.h.
using Divide::Material::StatePassesPerStage = eastl::array<StateVariantsPerPass<T>, to_base(RenderStage::COUNT)> |
Definition at line 138 of file Material.h.
using Divide::Material::StatesPerVariant = eastl::array<T, to_base(RenderStagePass::VariantType::COUNT)> |
Definition at line 136 of file Material.h.
using Divide::Material::StateVariantsPerPass = eastl::array<StatesPerVariant<T>, to_base(RenderPassType::COUNT)> |
Definition at line 137 of file Material.h.
|
strong |
Enumerator | |
---|---|
Default | |
Medium | |
High | |
COUNT |
Definition at line 140 of file Material.h.
|
explicit |
Definition at line 141 of file Material.cpp.
|
inline |
Definition at line 102 of file Material.inl.
|
inlineprivate |
Definition at line 122 of file Material.inl.
bool Divide::Material::canDraw | ( | RenderStagePass | renderStagePass, |
bool & | shaderJustFinishedLoading | ||
) |
Definition at line 554 of file Material.cpp.
void Divide::Material::clearRenderStates | ( | ) |
Definition at line 301 of file Material.cpp.
Return a new instance of this material with the name composed of the base material's name and the give name suffix (clone calls CreateResource internally!).
Definition at line 222 of file Material.cpp.
|
private |
Definition at line 607 of file Material.cpp.
Handle< ShaderProgram > Divide::Material::computeAndGetProgramHandle | ( | RenderStagePass | renderStagePass | ) |
Definition at line 516 of file Material.cpp.
|
noexcept |
Definition at line 1034 of file Material.cpp.
|
noexcept |
Definition at line 1010 of file Material.cpp.
void Divide::Material::getData | ( | U32 | bestProbeID, |
NodeMaterialData & | dataOut | ||
) |
< For PHONG_SPECULAR
Definition at line 1086 of file Material.cpp.
DescriptorSet & Divide::Material::getDescriptorSet | ( | const RenderStagePass & | renderStagePass | ) |
Definition at line 1127 of file Material.cpp.
|
noexcept |
Definition at line 1022 of file Material.cpp.
Definition at line 62 of file Material.inl.
Definition at line 57 of file Material.inl.
|
noexcept |
Definition at line 1053 of file Material.cpp.
|
noexcept |
Definition at line 1075 of file Material.cpp.
const RenderStateBlock & Divide::Material::getOrCreateRenderStateBlock | ( | RenderStagePass | renderStagePass | ) |
Definition at line 940 of file Material.cpp.
Handle< ShaderProgram > Divide::Material::getProgramHandle | ( | RenderStagePass | renderStagePass | ) | const |
Definition at line 539 of file Material.cpp.
|
noexcept |
Definition at line 1064 of file Material.cpp.
|
private |
Definition at line 995 of file Material.cpp.
|
noexcept |
Definition at line 1042 of file Material.cpp.
|
inline |
Definition at line 68 of file Material.inl.
|
inline |
Definition at line 117 of file Material.inl.
|
inlinenoexcept |
Definition at line 74 of file Material.inl.
|
inlinenoexcept |
Definition at line 80 of file Material.inl.
|
inlinenoexcept |
Definition at line 86 of file Material.inl.
|
overridevirtual |
Loading and unloading interface.
Reimplemented from Divide::CachedResource.
Definition at line 214 of file Material.cpp.
void Divide::Material::loadFromXML | ( | const std::string & | entryName, |
const boost::property_tree::ptree & | pt | ||
) |
Definition at line 1192 of file Material.cpp.
|
private |
Definition at line 1255 of file Material.cpp.
|
private |
Definition at line 1324 of file Material.cpp.
|
inlinenoexcept |
Definition at line 37 of file Material.inl.
|
inlinenoexcept |
Definition at line 47 of file Material.inl.
|
static |
Definition at line 126 of file Material.cpp.
|
static |
Definition at line 121 of file Material.cpp.
Divide::Material::POINTER_R_IW | ( | Material | , |
baseMaterial | , | ||
nullptr | |||
) |
Divide::Material::PROPERTY_R_IW | ( | AttributeMap | , |
shaderAttributes | |||
) |
Divide::Material::PROPERTY_R_IW | ( | DescriptorSet | , |
descriptorSetMainPass | |||
) |
Divide::Material::PROPERTY_R_IW | ( | DescriptorSet | , |
descriptorSetPrePass | |||
) |
Divide::Material::PROPERTY_R_IW | ( | DescriptorSet | , |
descriptorSetSecondaryPass | |||
) |
Divide::Material::PROPERTY_R_IW | ( | DescriptorSet | , |
descriptorSetShadow | |||
) |
Divide::Material::PROPERTY_R_IW | ( | PrimitiveTopology | , |
topology | , | ||
PrimitiveTopology::COUNT | |||
) |
Divide::Material::PROPERTY_RW | ( | bool | , |
ignoreShaderCache | , | ||
false | |||
) |
Useful for debugging.
Divide::Material::PROPERTY_RW | ( | bool | , |
ignoreXMLData | , | ||
false | |||
) |
Divide::Material::PROPERTY_RW | ( | ComputeRenderStateCBK | , |
computeRenderStateCBK | |||
) |
Divide::Material::PROPERTY_RW | ( | ComputeShaderCBK | , |
computeShaderCBK | |||
) |
Divide::Material::PROPERTY_RW | ( | Properties | , |
properties | |||
) |
Divide::Material::PROPERTY_RW | ( | RecomputeShadersCBK | , |
recomputeShadersCBK | |||
) |
Divide::Material::PROPERTY_RW | ( | ShaderData | , |
baseShaderData | |||
) |
Divide::Material::PROPERTY_RW | ( | UpdatePriority | , |
updatePriorirty | , | ||
UpdatePriority::Default | |||
) |
void Divide::Material::rebuild | ( | ) |
Definition at line 1162 of file Material.cpp.
|
static |
Definition at line 131 of file Material.cpp.
|
private |
Definition at line 488 of file Material.cpp.
|
private |
Definition at line 1211 of file Material.cpp.
|
private |
Definition at line 1287 of file Material.cpp.
void Divide::Material::saveToXML | ( | const std::string & | entryName, |
boost::property_tree::ptree & | pt | ||
) | const |
Definition at line 1183 of file Material.cpp.
void Divide::Material::setPipelineLayout | ( | PrimitiveTopology | topology, |
const AttributeMap & | shaderAttributes | ||
) |
Definition at line 331 of file Material.cpp.
void Divide::Material::setRenderStateBlock | ( | const RenderStateBlock & | renderStateBlock, |
RenderStage | stage, | ||
RenderPassType | pass, | ||
RenderStagePass::VariantType | variant = RenderStagePass::VariantType::COUNT |
||
) |
Add the specified renderStateBlock to specific RenderStagePass parameters. Use "COUNT" and/or "g_AllVariantsID" for global options e.g. a RenderPassType::COUNT will use the block in the specified stage+variant combo but for all of the passes
Definition at line 883 of file Material.cpp.
bool Divide::Material::setSampler | ( | TextureSlot | textureUsageSlot, |
SamplerDescriptor | sampler | ||
) |
Definition at line 348 of file Material.cpp.
|
private |
Definition at line 437 of file Material.cpp.
bool Divide::Material::setTexture | ( | TextureSlot | textureUsageSlot, |
const ResourceDescriptor< Texture > & | texture, | ||
SamplerDescriptor | sampler, | ||
TextureOperation | op, | ||
bool | useInGeometryPasses = false |
||
) |
Definition at line 405 of file Material.cpp.
bool Divide::Material::setTexture | ( | TextureSlot | textureUsageSlot, |
Handle< Texture > | texture, | ||
SamplerDescriptor | sampler, | ||
TextureOperation | op, | ||
bool | useInGeometryPasses = false |
||
) |
Definition at line 415 of file Material.cpp.
|
private |
Definition at line 355 of file Material.cpp.
|
private |
Definition at line 360 of file Material.cpp.
void Divide::Material::setTextureOperation | ( | TextureSlot | textureUsageSlot, |
TextureOperation | op | ||
) |
Definition at line 425 of file Material.cpp.
|
inline |
Definition at line 138 of file Material.inl.
|
inlineprivate |
Definition at line 92 of file Material.inl.
|
inlineprivate |
Definition at line 97 of file Material.inl.
|
overridevirtual |
Reimplemented from Divide::CachedResource.
Definition at line 843 of file Material.cpp.
|
inlinenoexcept |
Definition at line 42 of file Material.inl.
|
inlinenoexcept |
Definition at line 52 of file Material.inl.
|
static |
Definition at line 136 of file Material.cpp.
Returns a bit mask composed of UpdateResult flags.
Definition at line 276 of file Material.cpp.
void Divide::Material::updateCullState | ( | ) |
Definition at line 313 of file Material.cpp.
|
private |
Definition at line 906 of file Material.cpp.
|
privatenoexcept |
Definition at line 785 of file Material.cpp.
|
friend |
Definition at line 126 of file Material.h.
|
private |
Definition at line 362 of file Material.h.
|
private |
Definition at line 371 of file Material.h.
|
private |
Definition at line 373 of file Material.h.
|
mutableprivate |
Definition at line 376 of file Material.h.
Definition at line 377 of file Material.h.
|
private |
Definition at line 381 of file Material.h.
|
private |
Definition at line 370 of file Material.h.
|
mutableprivate |
Definition at line 374 of file Material.h.
|
private |
Definition at line 379 of file Material.h.
|
staticconstexpr |
Definition at line 129 of file Material.h.
|
staticprivate |
Definition at line 383 of file Material.h.