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;
107 { myVertexOverrides = ovr; }
109 {
return myVertexOverrides; }
113 MaterialType
type = SIMPLE_SURFACE);
119 struct SimpleMaterialBlock
144 int32 AlphaMode = ALPHA_BLEND;
150 int32 CoatSpecModel = 2;
151 int32 UseGeoColor = 1;
152 int32 UsePackedColor = 1;
153 int32 HasTextures = 0;
171 { mySimpleBlock.udim_area = udim; myBlockDirtyFlag =
true; }
176 bool &created)
override;
183 MaterialType
type = MATCAP_SURFACE);
194 bool myTexDirtyFlag =
true;
204 #define TEX_PARM(TYPE, NAME) \
205 TYPE get##NAME() const { return myTextureBlock.NAME; } \
206 void set##NAME(const TYPE &v) \
207 { if(myTextureBlock.NAME != v) \
208 { myTextureBlock.NAME=v; myTexBlockDirtyFlag=true; } \
326 bool &created)
override;
382 int32 HasDiffuse =
false;
383 int32 HasSpecular =
false;
384 int32 HasOpacity =
false;
385 int32 HasEmission =
false;
386 int32 HasNormal =
false;
387 int32 HasRough =
false;
388 int32 HasDisplace =
false;
389 int32 HasOcclusion =
false;
390 int32 HasMetallic =
false;
391 int32 HasCoatInt =
false;
392 int32 HasCoatRough =
false;
393 int32 HasReflectInt =
false;
395 int32 HasDiffuseUV =
false;
396 int32 HasSpecularUV =
false;
397 int32 HasOpacityUV =
false;
398 int32 HasEmissionUV =
false;
399 int32 HasNormalUV =
false;
400 int32 HasRoughUV =
false;
401 int32 HasDisplaceUV =
false;
402 int32 HasOcclusionUV =
false;
403 int32 HasMetallicUV =
false;
404 int32 HasCoatIntUV =
false;
405 int32 HasCoatRoughUV =
false;
406 int32 HasReflectIntUV =
false;
408 int32 NormalMapType = 0;
410 int32 DisplaceSpace = 0;
414 int32 DisplaceYUp =
true;
416 int32 InvertOpacity =
false;
417 int32 InvertRough =
false;
418 int32 ReflectAsIOR =
false;
421 bool myTexDirtyFlag =
true;
422 bool myTexBlockDirtyFlag =
true;
438 #define HAIR_PARM(TYPE, NAME) \
439 TYPE get##NAME() const { return myHairBlock.NAME; } \
440 void set##NAME(const TYPE &v) \
441 { if(myHairBlock.NAME != v) { myHairBlock.NAME=v; myBlockDirtyFlag=true; } } \
450 static constexpr
int32 DiffUseBaseMap = 0;
451 static constexpr
int32 DiffUseBlendRamp = 0;
457 static constexpr
int32 SpecUseBaseMap = 0;
458 static constexpr
int32 SpecUseBlendRamp = 0;
460 static constexpr
int32 AlphaUseRamp = 0;
461 static constexpr
int32 RandomDiffHue = 0;
463 static constexpr
int32 RandomDiffSat = 0;
465 static constexpr
int32 RandomDiffInt = 0;
467 static constexpr
int32 RandomSpecInt = 0;
501 TEXMAP_PARM(DiffRootTipBlendMap, DiffRootTipBlendID);
502 TEXMAP_PARM(SpecRootTipBlendMap, SpecRootTipBlendID);
503 TEXMAP_PARM(AlphaRootTipBlendMap, AlphaRootTipBlendID);
527 bool &created)
override;
554 Defaults::RandomDiffHueRange;
556 Defaults::RandomDiffSatRange;
558 Defaults::RandomDiffIntRange;
560 Defaults::RandomSpecIntRange;
564 fpreal32 DiffIntensity = Defaults::DiffIntensity;
566 fpreal32 SpecIntensity = Defaults::SpecIntensity;
567 fpreal32 SpecAngle = Defaults::SpecAngle;
568 fpreal32 SpecShift = Defaults::SpecShift;
570 fpreal32 HairAlpha = Defaults::HairAlpha;
572 int32 RandomDiffHue = Defaults::RandomDiffHue;
573 int32 RandomDiffSat = Defaults::RandomDiffSat;
574 int32 RandomDiffInt = Defaults::RandomDiffInt;
575 int32 RandomSpecInt = Defaults::RandomSpecInt;
578 int32 HasDiffRootTipBlend =
false;
579 int32 HasSpecRootTipBlend =
false;
580 int32 HasAlphaRootTipBlend =
false;
581 int32 HasDiffuse =
false;
582 int32 HasSpecular =
false;
585 int32 HasDiffuseUV =
false;
586 int32 HasSpecularUV =
false;
589 bool myTexDirtyFlag =
true;
619 {
if (
id != mySurfShaderID) { resetResources(); }
623 {
if (
id != myCurveShaderID) { resetResources(); }
624 myCurveShaderID =
id; }
626 {
if (
id != myDisplaceShaderID) { resetResources(); }
627 myDisplaceShaderID =
id;
630 { mySurfShaderID=myCurveShaderID=myDisplaceShaderID = 0;
643 bool &created)
override;
648 { myCachedName = std::move(name); }
655 if (myCachedName.isEmpty())
657 name.
format(
"{}?{}", myCachedName,
id());
661 if (myCachedName.isEmpty())
663 name.
format(
"{}?{}&curve", myCachedName,
id());
687 { myShaderCompileKey = std::move(key); }
704 void resetResources();
708 bool myShaderDirty =
true;
709 bool myTexturesDirty =
true;
710 bool myBadShader =
false;
711 bool myShaderCompiled =
true;
712 bool mySurfShaderAssigned =
false;
713 bool myCurveShaderAssigned =
false;
714 bool myDisplaceShaderAssigned =
false;
715 exint myMatXVersion = 0;
719 bool is_color =
true;
741 exint mySurfShaderID=0;
742 exint myCurveShaderID=0;
743 exint myDisplaceShaderID=0;
747 #define LAYER_INST(NAME, TYPE) \
748 TYPE get##NAME(int idx) const { return myLayer.layer[idx].NAME; } \
749 void set##NAME(int idx, const TYPE &v) \
750 { if(myLayer.layer[idx].NAME != v) { myLayer.layer[idx].NAME=v; myLayerDirtyFlag=true; } } \
754 #define LAYER_PARM(NAME, TYPE) \
755 TYPE get##NAME() const { return myLayer.NAME; } \
756 void set##NAME(const TYPE &v) \
757 { if(myLayer.NAME != v) { myLayer.NAME=v; myLayerDirtyFlag=true; } } \
815 bool &created)
override;
836 int32 UseTint =
true;
837 int32 HasMap =
false;
838 int32 UseTriplanar =
false;
851 int32 UseBlendMap =
false;
852 int32 HasTriplanar =
false;
857 bool myTexDirtyFlag =
true;
858 bool myLayerDirtyFlag =
true;
859 int64 myDisplaceVersion = 0;
860 int64 myNormalVersion = 0;
861 int64 myColorVersion = 0;
862 int64 myBlendVersion = 0;
863 bool myClampToEdge[10];
874 #undef TEXMAP_PARM_VK
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
bool isDisplaceShaderAssigned() const
#define LAYER_INST(NAME, TYPE)
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
#define LAYER_PARM(NAME, TYPE)
#define TEX_PARM(TYPE, NAME)
void dirtyTextures() override
const UT_StringHolder & shaderCompileKey()
virtual void update(const GR_MaterialParms &options)=0
int64 getMatXNodeVersion() const
GLsizei const GLfloat * value
UT_NON_COPYABLE(GR_Material)
virtual bool bindForCompute(RV_Render *r, RV_ShaderProgramBase *shader, const GR_DisplayOption &opts)
virtual bool initMaterialSetForRender(RV_Render *r, RV_ShaderProgramBase *shader, bool &created)=0
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)
GLint GLint GLsizei GLint GLenum GLenum type
void setDisplaceShaderAssigned(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)
constexpr auto set(type rhs) -> int
virtual RV_ShaderCompute * getDisplaceShader() const
void setShaderCompileKey(UT_StringHolder &key)
void setVertexOverrides(const UT_StringMap< UT_StringHolder > &ovr)
const UT_StringMap< UT_StringHolder > & vertexOverrides() const
GLuint const GLchar * name
virtual bool initBlocks(RV_Render *r, const GR_DisplayOption *opts)=0
const UT_StringHolder & cachedName() const
#define MATPARM(TYPE, NAME)
bool initMaterialSetForRender(RV_Render *r, RV_ShaderProgramBase *shader, bool &created) override
GT_API const UT_StringHolder version
size_t format(const char *fmt, const Args &...args)
More of a builtin material for the MatCap display mode.
GLenum GLsizei GLsizei GLint * values
void makeUniqueCachedName(UT_WorkBuffer &name) const
bool isSurfShaderAssigned() const
virtual RV_ShaderProgram * getCurveShader() const
void setSurfShaderAssigned(bool comp)
UT_StringMap< GR_Material::InputType > & inputs()
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.
void makeCachedCurveName(UT_WorkBuffer &name) const
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 setFreeCB(UT_Functor1< void, GR_MatXMaterial * > cb)
void dirtyTextures() override
void setDisplaceShader(exint id)