10#include <unordered_map>
145 using ParameterValue = std::variant<float, int32_t, uint32_t, bool, Color, Vector2, Vector3, Vector4, Matrix4, Texture*>;
151 const std::string&
name()
const {
return _name; }
160 const std::shared_ptr<Shader>&
shaderOverride()
const {
return _shaderOverride; }
163 const std::shared_ptr<BlendState>&
blendState()
const {
return _blendState; }
166 const std::shared_ptr<DepthState>&
depthState()
const {
return _depthState; }
254 const std::unordered_map<std::string, ParameterValue>&
parameters()
const {
return _parameters; }
291 bool _transparent =
false;
292 uint64_t _shaderVariantKey = 0;
295 std::shared_ptr<Shader> _shaderOverride;
298 std::shared_ptr<BlendState> _blendState;
299 std::shared_ptr<DepthState> _depthState;
303 Color _baseColorFactor =
Color(1.0f, 1.0f, 1.0f, 1.0f);
304 Texture* _baseColorTexture =
nullptr;
305 bool _hasBaseColorTexture =
false;
306 int _baseColorUvSet = 0;
307 Texture* _normalTexture =
nullptr;
308 bool _hasNormalTexture =
false;
309 int _normalUvSet = 0;
310 float _normalScale = 1.0f;
311 float _metallicFactor = 0.0f;
312 float _roughnessFactor = 1.0f;
313 Texture* _metallicRoughnessTexture =
nullptr;
314 bool _hasMetallicRoughnessTexture =
false;
315 int _metallicRoughnessUvSet = 0;
316 Texture* _occlusionTexture =
nullptr;
317 bool _hasOcclusionTexture =
false;
318 int _occlusionUvSet = 0;
319 float _occlusionStrength = 1.0f;
320 bool _occludeDirect =
false;
322 float _occludeSpecularIntensity = 1.0f;
323 Color _emissiveFactor =
Color(0.0f, 0.0f, 0.0f, 1.0f);
324 Texture* _emissiveTexture =
nullptr;
325 bool _hasEmissiveTexture =
false;
326 int _emissiveUvSet = 0;
328 float _alphaCutoff = 0.5f;
329 bool _isSkybox =
false;
338 std::unordered_map<std::string, ParameterValue> _parameters;
342 void setDefaultMaterial(
const std::shared_ptr<GraphicsDevice>& device,
const std::shared_ptr<Material>& material);
343 std::shared_ptr<Material>
getDefaultMaterial(
const std::shared_ptr<GraphicsDevice>& device);
void setShaderOverride(const std::shared_ptr< Shader > &shader)
void setNormalScale(const float value)
CullMode cullMode() const
const TextureTransform & emissiveTransform() const
void setIsSkybox(const bool value)
void setOcclusionTransform(const TextureTransform &t)
void setHasEmissiveTexture(const bool value)
void setNormalUvSet(const int uvSet)
void setMetallicRoughnessTexture(Texture *texture)
float normalScale() const
const std::shared_ptr< Shader > & shaderOverride() const
void setBaseColorFactor(const Color &value)
void setMetallicRoughnessUvSet(const int uvSet)
virtual void getTextureSlots(std::vector< TextureSlot > &slots) const
std::variant< float, int32_t, uint32_t, bool, Color, Vector2, Vector3, Vector4, Matrix4, Texture * > ParameterValue
float metallicFactor() const
float roughnessFactor() const
uint64_t shaderVariantKey() const
virtual ~Material()=default
void setRoughnessFactor(const float value)
void setHasNormalTexture(const bool value)
Texture * emissiveTexture() const
void setBaseColorTexture(Texture *texture)
void setDepthState(const std::shared_ptr< DepthState > &depthState)
Texture * baseColorTexture() const
void setOccludeDirect(const bool value)
void setAlphaCutoff(const float value)
int metallicRoughnessUvSet() const
const std::shared_ptr< DepthState > & depthState() const
const Color & baseColorFactor() const
virtual void updateUniforms(MaterialUniforms &uniforms) const
float alphaCutoff() const
void setEmissiveTexture(Texture *texture)
const std::shared_ptr< BlendState > & blendState() const
Texture * normalTexture() const
const std::unordered_map< std::string, ParameterValue > & parameters() const
const TextureTransform & baseColorTransform() const
void setEmissiveTransform(const TextureTransform &t)
float occlusionStrength() const
void setOcclusionTexture(Texture *texture)
void setHasOcclusionTexture(const bool value)
bool hasOcclusionTexture() const
const Color & emissiveFactor() const
void setOccludeSpecular(const uint32_t value)
void setHasBaseColorTexture(const bool value)
void setBaseColorTransform(const TextureTransform &t)
void setCullMode(const CullMode mode)
void setMetallicFactor(const float value)
void setEmissiveUvSet(const int uvSet)
void setBlendState(const std::shared_ptr< BlendState > &blendState)
void setName(const std::string &name)
virtual const void * customUniformData(size_t &outSize) const
bool hasNormalTexture() const
void setOccludeSpecularIntensity(const float value)
const TextureTransform & occlusionTransform() const
Texture * occlusionTexture() const
const TextureTransform & metalRoughTransform() const
const TextureTransform & normalTransform() const
void setTransparent(const bool value)
bool hasMetallicRoughnessTexture() const
void setNormalTransform(const TextureTransform &t)
void setNormalTexture(Texture *texture)
void setOcclusionUvSet(const int uvSet)
void setBaseColorUvSet(const int uvSet)
int baseColorUvSet() const
float occludeSpecularIntensity() const
int emissiveUvSet() const
bool removeParameter(const std::string &name)
void setAlphaMode(const AlphaMode mode)
int occlusionUvSet() const
const std::string & name() const
uint32_t occludeSpecular() const
void setParameter(const std::string &name, const ParameterValue &value)
void setHasMetallicRoughnessTexture(const bool value)
bool occludeDirect() const
void setOcclusionStrength(const float value)
bool hasBaseColorTexture() const
AlphaMode alphaMode() const
void setEmissiveFactor(const Color &value)
void setMetalRoughTransform(const TextureTransform &t)
const ParameterValue * parameter(const std::string &name) const
void setShaderVariantKey(const uint64_t value)
bool hasEmissiveTexture() const
Texture * metallicRoughnessTexture() const
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.
std::shared_ptr< Material > getDefaultMaterial(const std::shared_ptr< GraphicsDevice > &device)
constexpr uint32_t SPECOCC_AO
void setDefaultMaterial(const std::shared_ptr< GraphicsDevice > &device, const std::shared_ptr< Material > &material)
RGBA color with floating-point components in [0, 1].
2D vector for UV coordinates, screen positions, and 2D math.