10 #ifndef GR_MaterialTypes_h
11 #define GR_MaterialTypes_h
38 #define PARMKEY(NAME) static exint NAME();
40 #define MATPARM(TYPE, NAME) \
41 TYPE get##NAME() const { return mySimpleBlock.NAME; } \
42 void set##NAME(const TYPE &v) \
43 { if(mySimpleBlock.NAME != v) { mySimpleBlock.NAME=v; myBlockDirtyFlag=true; } } \
47 #define TEXMAP_PARM(NAME, MAP) \
48 UT_StringHolder get##NAME() const { return my##NAME; } \
49 void set##NAME(const UT_StringHolder &v) \
50 { if(my##NAME != v) { my##NAME=v; my##MAP.reset(); myTexDirtyFlag=true; } } \
51 void set##NAME##Fallback(const UT_Vector4F &f) \
52 { if(my##NAME##Fallback!=f) { my##NAME##Fallback=f; myTexDirtyFlag=true; }} \
54 UT_StringHolder my##NAME; \
55 UT_Vector4F my##NAME##Fallback; \
59 #define TEXMAP_PARM(NAME, MAP) \
60 UT_StringHolder get##NAME() const { return my##NAME; } \
61 void set##NAME(const UT_StringHolder &v) \
62 { if(my##NAME != v) { my##NAME=v; myTexDirtyFlag=true; } } \
63 void set##NAME##Fallback(const UT_Vector4F &f) \
64 { if(my##NAME##Fallback!=f) { my##NAME##Fallback=f; myTexDirtyFlag=true; }} \
66 UT_Vector4F my##NAME##Fallback; \
67 UT_StringHolder my##NAME
103 bool &created)
override;
114 struct SimpleMaterialBlock
139 int32 AlphaMode = ALPHA_BLEND;
145 int32 CoatSpecModel = 2;
146 int32 UseGeoColor = 1;
147 int32 UsePackedColor = 1;
148 int32 HasTextures = 0;
165 { mySimpleBlock.udim_area = udim; myBlockDirtyFlag =
true; }
170 bool &created)
override;
177 MaterialType
type = MATCAP_SURFACE);
188 bool myTexDirtyFlag =
true;
198 #define TEX_PARM(TYPE, NAME) \
199 TYPE get##NAME() const { return myTextureBlock.NAME; } \
200 void set##NAME(const TYPE &v) \
201 { if(myTextureBlock.NAME != v) \
202 { myTextureBlock.NAME=v; myTexBlockDirtyFlag=true; } \
318 bool &created)
override;
370 int32 HasDiffuse =
false;
371 int32 HasSpecular =
false;
372 int32 HasOpacity =
false;
373 int32 HasEmission =
false;
374 int32 HasNormal =
false;
375 int32 HasRough =
false;
376 int32 HasDisplace =
false;
377 int32 HasOcclusion =
false;
378 int32 HasMetallic =
false;
379 int32 HasCoatInt =
false;
380 int32 HasCoatRough =
false;
381 int32 HasReflectInt =
false;
383 int32 HasDiffuseUV =
false;
384 int32 HasSpecularUV =
false;
385 int32 HasOpacityUV =
false;
386 int32 HasEmissionUV =
false;
387 int32 HasNormalUV =
false;
388 int32 HasRoughUV =
false;
389 int32 HasDisplaceUV =
false;
390 int32 HasOcclusionUV =
false;
391 int32 HasMetallicUV =
false;
392 int32 HasCoatIntUV =
false;
393 int32 HasCoatRoughUV =
false;
394 int32 HasReflectIntUV =
false;
396 int32 NormalMapType = 0;
398 int32 DisplaceSpace = 0;
402 int32 DisplaceYUp =
true;
404 int32 InvertOpacity =
false;
405 int32 InvertRough =
false;
406 int32 ReflectAsIOR =
false;
409 bool myTexDirtyFlag =
true;
410 bool myTexBlockDirtyFlag =
true;
424 #define HAIR_PARM(TYPE, NAME) \
425 TYPE get##NAME() const { return myHairBlock.NAME; } \
426 void set##NAME(const TYPE &v) \
427 { if(myHairBlock.NAME != v) { myHairBlock.NAME=v; myBlockDirtyFlag=true; } } \
436 static constexpr
int32 DiffUseBaseMap = 0;
437 static constexpr
int32 DiffUseBlendRamp = 0;
443 static constexpr
int32 SpecUseBaseMap = 0;
444 static constexpr
int32 SpecUseBlendRamp = 0;
446 static constexpr
int32 AlphaUseRamp = 0;
447 static constexpr
int32 RandomDiffHue = 0;
449 static constexpr
int32 RandomDiffSat = 0;
451 static constexpr
int32 RandomDiffInt = 0;
453 static constexpr
int32 RandomSpecInt = 0;
487 TEXMAP_PARM(DiffRootTipBlendMap, DiffRootTipBlendID);
488 TEXMAP_PARM(SpecRootTipBlendMap, SpecRootTipBlendID);
489 TEXMAP_PARM(AlphaRootTipBlendMap, AlphaRootTipBlendID);
513 bool &created)
override;
540 Defaults::RandomDiffHueRange;
542 Defaults::RandomDiffSatRange;
544 Defaults::RandomDiffIntRange;
546 Defaults::RandomSpecIntRange;
550 fpreal32 DiffIntensity = Defaults::DiffIntensity;
552 fpreal32 SpecIntensity = Defaults::SpecIntensity;
553 fpreal32 SpecAngle = Defaults::SpecAngle;
554 fpreal32 SpecShift = Defaults::SpecShift;
556 fpreal32 HairAlpha = Defaults::HairAlpha;
558 int32 RandomDiffHue = Defaults::RandomDiffHue;
559 int32 RandomDiffSat = Defaults::RandomDiffSat;
560 int32 RandomDiffInt = Defaults::RandomDiffInt;
561 int32 RandomSpecInt = Defaults::RandomSpecInt;
564 int32 HasDiffRootTipBlend =
false;
565 int32 HasSpecRootTipBlend =
false;
566 int32 HasAlphaRootTipBlend =
false;
567 int32 HasDiffuse =
false;
568 int32 HasSpecular =
false;
571 int32 HasDiffuseUV =
false;
572 int32 HasSpecularUV =
false;
575 bool myTexDirtyFlag =
true;
605 if(enable != myEnableLighting)
607 myEnableLighting = enable;
608 myBlockDirtyFlag =
true;
614 if (
id != mySurfShaderID) { resetResources(); }
619 {
if (
id != mySurfShaderID) { resetResources(); }
620 myCurveShaderID =
id; }
630 bool &created)
override;
634 { myCachedName = std::move(name); }
639 if (myCachedName.isEmpty())
641 name.
format(
"{}?curve", myCachedName);
669 void resetResources();
673 bool myShaderDirty =
true;
674 bool myTexturesDirty =
true;
675 bool myEnableLighting =
true;
676 bool myBadShader =
false;
677 bool myShaderCompiled =
true;
678 bool mySurfShaderAssigned =
false;
679 bool myCurveShaderAssigned =
false;
680 exint myMatXVersion = 0;
684 bool is_color =
true;
703 exint mySurfShaderID=0;
704 exint myCurveShaderID=0;
707 #define LAYER_INST(NAME, TYPE) \
708 TYPE get##NAME(int idx) const { return myLayer.layer[idx].NAME; } \
709 void set##NAME(int idx, const TYPE &v) \
710 { if(myLayer.layer[idx].NAME != v) { myLayer.layer[idx].NAME=v; myLayerDirtyFlag=true; } } \
714 #define LAYER_PARM(NAME, TYPE) \
715 TYPE get##NAME() const { return myLayer.NAME; } \
716 void set##NAME(const TYPE &v) \
717 { if(myLayer.NAME != v) { myLayer.NAME=v; myLayerDirtyFlag=true; } } \
775 bool &created)
override;
794 int32 UseTint =
true;
795 int32 HasMap =
false;
796 int32 UseTriplanar =
false;
809 int32 UseBlendMap =
false;
810 int32 HasTriplanar =
false;
815 bool myTexDirtyFlag =
true;
816 bool myLayerDirtyFlag =
true;
817 int64 myDisplaceVersion = 0;
818 int64 myNormalVersion = 0;
819 int64 myColorVersion = 0;
820 int64 myBlendVersion = 0;
821 bool myClampToEdge[10];
832 #undef TEXMAP_PARM_VK
void enableLighting(bool enable)
A collection of Vulkan UBO, SSBO, and Image shader bindings (descriptor set)
void dirty(bool dirty=true)
const UT_StringHolder & getUVSet() const
virtual RV_ShaderProgram * getSurfaceShader() const
GT_API const UT_StringHolder filename
bool isShaderCompiled() const
void dirtyTextures() override
#define LAYER_INST(NAME, TYPE)
#define LAYER_PARM(NAME, TYPE)
#define TEX_PARM(TYPE, NAME)
void dirtyTextures() override
virtual void update(const GR_MaterialParms &options)=0
int64 getMatXNodeVersion() const
bool initMaterialSetForRender(RV_Render *r, RV_ShaderProgram *shader, bool &created) override
UT_NON_COPYABLE(GR_Material)
void makeCachedCurveName(UT_WorkBuffer name) const
void setUVSet(const UT_StringRef &set)
void update(const GR_MaterialParms &options) override
void setMatXNodeVersion(int64 version)
#define TEXMAP_PARM(NAME, MAP)
GLenum GLuint GLint GLint layer
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
UT_NON_COPYABLE(GR_SimpleMaterial)
void dirtyTextures() override
vint4 blend(const vint4 &a, const vint4 &b, const vbool4 &mask)
void setCurveShaderAssigned(bool comp)
void setShaderDirty(bool dirty)
Abstract data class for an array of float, int or string data.
bool isCurveShaderAssigned() const
void setCachedName(UT_StringHolder &name)
void setUDIM(const UT_Vector4i &udim)
GLuint const GLchar * name
virtual bool initBlocks(RV_Render *r, const GR_DisplayOption *opts)=0
const UT_StringHolder & cachedName() const
#define MATPARM(TYPE, NAME)
GT_API const UT_StringHolder version
virtual bool initMaterialSetForRender(RV_Render *r, RV_ShaderProgram *shader, bool &created)=0
size_t format(const char *fmt, const Args &...args)
More of a builtin material for the MatCap display mode.
GLenum GLsizei GLsizei GLint * values
bool isSurfShaderAssigned() const
virtual RV_ShaderProgram * getCurveShader() const
void setSurfShaderAssigned(bool comp)
void setSurfaceShader(exint id)
#define HAIR_PARM(TYPE, NAME)
bool isShaderDirty() const
This is a fast, non-string access and cut-down version of UT_Options.
GA_API const UT_StringHolder Alpha
bool initBlocks(RV_Render *r, const GR_DisplayOption *opts) override
void setShaderCompiled(bool comp)
void setCurveShader(exint id)
void dirtyTextures() override