VTK  9.3.20240423
vtkProperty.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
134#ifndef vtkProperty_h
135#define vtkProperty_h
136
137#include "vtkObject.h"
138#include "vtkRenderingCoreModule.h" // For export macro
139#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
140#include <map> // used for ivar
141#include <string> // used for ivar
142
143// shading models
144#define VTK_FLAT 0
145#define VTK_GOURAUD 1
146#define VTK_PHONG 2
147#define VTK_PBR 3
148
149// representation models
150#define VTK_POINTS 0
151#define VTK_WIREFRAME 1
152#define VTK_SURFACE 2
153
154VTK_ABI_NAMESPACE_BEGIN
155class vtkActor;
156class vtkInformation;
157class vtkRenderer;
158class vtkShaderProgram;
159class vtkTexture;
160class vtkWindow;
162class vtkXMLMaterial;
163
164class vtkPropertyInternals;
165
166class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkProperty : public vtkObject
167{
168public:
169 vtkTypeMacro(vtkProperty, vtkObject);
170 void PrintSelf(ostream& os, vtkIndent indent) override;
171
178 static vtkProperty* New();
179
184
192 virtual void Render(vtkActor*, vtkRenderer*);
193
201
208
210
213 vtkGetMacro(Lighting, bool);
214 vtkSetMacro(Lighting, bool);
215 vtkBooleanMacro(Lighting, bool);
217
219
225 vtkGetMacro(RenderPointsAsSpheres, bool);
226 vtkSetMacro(RenderPointsAsSpheres, bool);
227 vtkBooleanMacro(RenderPointsAsSpheres, bool);
229
231
238 vtkGetMacro(RenderLinesAsTubes, bool);
239 vtkSetMacro(RenderLinesAsTubes, bool);
240 vtkBooleanMacro(RenderLinesAsTubes, bool);
242
244
247 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
248 vtkGetMacro(Interpolation, int);
249 void SetInterpolationToFlat() { this->SetInterpolation(VTK_FLAT); }
250 void SetInterpolationToGouraud() { this->SetInterpolation(VTK_GOURAUD); }
251 void SetInterpolationToPhong() { this->SetInterpolation(VTK_PHONG); }
252 void SetInterpolationToPBR() { this->SetInterpolation(VTK_PBR); }
253 const char* GetInterpolationAsString();
255
257
260 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
261 vtkGetMacro(Representation, int);
262 void SetRepresentationToPoints() { this->SetRepresentation(VTK_POINTS); }
263 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_WIREFRAME); }
264 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SURFACE); }
265 const char* GetRepresentationAsString();
267
269
274 virtual void SetColor(double r, double g, double b);
275 virtual void SetColor(double a[3]);
276 double* GetColor() VTK_SIZEHINT(3);
277 void GetColor(double rgb[3]);
278 void GetColor(double& r, double& g, double& b);
280
282
293 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
294 vtkGetMacro(BaseIOR, double);
296
298
304 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
305 vtkGetMacro(Metallic, double);
307
309
316 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
317 vtkGetMacro(Roughness, double);
319
321
327 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
328 vtkGetMacro(Anisotropy, double);
330
332
338 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
339 vtkGetMacro(AnisotropyRotation, double);
341
343
348 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
349 vtkGetMacro(CoatIOR, double);
351
353
359 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
360 vtkGetMacro(CoatRoughness, double);
362
364
370 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
371 vtkGetMacro(CoatStrength, double);
373
375
380 vtkSetVector3Macro(CoatColor, double);
381 vtkGetVector3Macro(CoatColor, double);
383
385
391 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
392 vtkGetMacro(CoatNormalScale, double);
394
396
401 vtkSetMacro(NormalScale, double);
402 vtkGetMacro(NormalScale, double);
404
406
412 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
413 vtkGetMacro(OcclusionStrength, double);
415
417
423 vtkSetVector3Macro(EmissiveFactor, double);
424 vtkGetVector3Macro(EmissiveFactor, double);
426
428
434 vtkSetVector3Macro(EdgeTint, double);
435 vtkGetVector3Macro(EdgeTint, double);
437
439
442 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
443 vtkGetMacro(Ambient, double);
445
447
450 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
451 vtkGetMacro(Diffuse, double);
453
455
458 vtkSetClampMacro(Specular, double, 0.0, 1.0);
459 vtkGetMacro(Specular, double);
461
463
466 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
467 vtkGetMacro(SpecularPower, double);
469
471
475 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
476 vtkGetMacro(Opacity, double);
478
480
484 vtkSetClampMacro(EdgeOpacity, double, 0.0, 1.0);
485 vtkGetMacro(EdgeOpacity, double);
487
489
495 vtkSetVector3Macro(AmbientColor, double);
496 vtkGetVector3Macro(AmbientColor, double);
498
500
504 vtkSetVector3Macro(DiffuseColor, double);
505 vtkGetVector3Macro(DiffuseColor, double);
507
509
512 vtkSetVector3Macro(SpecularColor, double);
513 vtkGetVector3Macro(SpecularColor, double);
515
517
522 vtkGetMacro(EdgeVisibility, vtkTypeBool);
523 vtkSetMacro(EdgeVisibility, vtkTypeBool);
524 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
526
528
531 vtkSetVector3Macro(EdgeColor, double);
532 vtkGetVector3Macro(EdgeColor, double);
534
536
541 vtkGetMacro(VertexVisibility, vtkTypeBool);
542 vtkSetMacro(VertexVisibility, vtkTypeBool);
543 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
545
547
550 vtkSetVector3Macro(VertexColor, double);
551 vtkGetVector3Macro(VertexColor, double);
553
555
559 vtkSetVector4Macro(SelectionColor, double);
560 vtkGetVector4Macro(SelectionColor, double);
562
564
568 vtkSetMacro(SelectionLineWidth, float);
569 vtkGetMacro(SelectionLineWidth, float);
571
573
577 vtkSetMacro(SelectionPointSize, float);
578 vtkGetMacro(SelectionPointSize, float);
580
582
586 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
587 vtkGetMacro(LineWidth, float);
589
591
596 vtkSetMacro(LineStipplePattern, int);
597 vtkGetMacro(LineStipplePattern, int);
599
601
606 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
607 vtkGetMacro(LineStippleRepeatFactor, int);
609
611
615 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
616 vtkGetMacro(PointSize, float);
618
620
625 vtkGetMacro(BackfaceCulling, vtkTypeBool);
626 vtkSetMacro(BackfaceCulling, vtkTypeBool);
627 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
629
631
636 vtkGetMacro(FrontfaceCulling, vtkTypeBool);
637 vtkSetMacro(FrontfaceCulling, vtkTypeBool);
638 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
640
642
645 vtkSetStringMacro(MaterialName);
646 vtkGetStringMacro(MaterialName);
648
650
654 vtkSetMacro(Shading, vtkTypeBool);
655 vtkGetMacro(Shading, vtkTypeBool);
656 vtkBooleanMacro(Shading, vtkTypeBool);
658
660
668 virtual void AddShaderVariable(const char* name, int numVars, int* x);
669 virtual void AddShaderVariable(const char* name, int numVars, float* x);
670 virtual void AddShaderVariable(const char* name, int numVars, double* x);
672
674
677 void AddShaderVariable(const char* name, int v) { this->AddShaderVariable(name, 1, &v); }
678 void AddShaderVariable(const char* name, float v) { this->AddShaderVariable(name, 1, &v); }
679 void AddShaderVariable(const char* name, double v) { this->AddShaderVariable(name, 1, &v); }
680 void AddShaderVariable(const char* name, int v1, int v2)
681 {
682 int v[2] = { v1, v2 };
683 this->AddShaderVariable(name, 2, v);
684 }
685 void AddShaderVariable(const char* name, float v1, float v2)
686 {
687 float v[2] = { v1, v2 };
688 this->AddShaderVariable(name, 2, v);
689 }
690 void AddShaderVariable(const char* name, double v1, double v2)
691 {
692 double v[2] = { v1, v2 };
693 this->AddShaderVariable(name, 2, v);
694 }
695 void AddShaderVariable(const char* name, int v1, int v2, int v3)
696 {
697 int v[3] = { v1, v2, v3 };
698 this->AddShaderVariable(name, 3, v);
699 }
700 void AddShaderVariable(const char* name, float v1, float v2, float v3)
701 {
702 float v[3] = { v1, v2, v3 };
703 this->AddShaderVariable(name, 3, v);
704 }
705 void AddShaderVariable(const char* name, double v1, double v2, double v3)
706 {
707 double v[3] = { v1, v2, v3 };
708 this->AddShaderVariable(name, 3, v);
709 }
711
713
717 vtkSetMacro(ShowTexturesOnBackface, bool);
718 vtkGetMacro(ShowTexturesOnBackface, bool);
719 vtkBooleanMacro(ShowTexturesOnBackface, bool);
721
723
736 void SetTexture(const char* name, vtkTexture* texture);
737 vtkTexture* GetTexture(const char* name);
739
746 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
747
757 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
758
769 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
770
779 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
780
788 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
789
798 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
799
803 void RemoveTexture(const char* name);
804
809
814
818 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
819
826
828
832 vtkGetObjectMacro(Information, vtkInformation);
834 virtual void SetInformation(vtkInformation*);
836
838
842 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
844
846
850 static double ComputeIORFromReflectance(double reflectance, double ior);
852
854
860 double ComputeReflectanceOfBaseLayer();
862
863protected:
865 ~vtkProperty() override;
866
870 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
871 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
872
873 double Color[3];
874 double AmbientColor[3];
875 double DiffuseColor[3];
876 double SpecularColor[3];
877 double EdgeColor[3];
878 double VertexColor[3];
879 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
880 double Ambient;
881 double Diffuse;
882 double Metallic;
883 double Roughness;
886 double BaseIOR;
887 double CoatIOR;
888 double CoatColor[3];
894 double EmissiveFactor[3];
895 double Specular;
897 double Opacity;
898 double EdgeOpacity = 1.0;
899 double EdgeTint[3];
902 float SelectionPointSize = 2.f;
903 float SelectionLineWidth = 2.f;
916
918
920
921 typedef std::map<std::string, vtkTexture*> MapOfTextures;
923
924 // Arbitrary extra information associated with this Property.
926
927private:
928 vtkProperty(const vtkProperty&) = delete;
929 void operator=(const vtkProperty&) = delete;
930};
931
936{
937 if (this->Interpolation == VTK_FLAT)
938 {
939 return "Flat";
940 }
941 else if (this->Interpolation == VTK_GOURAUD)
942 {
943 return "Gouraud";
944 }
945 else if (this->Interpolation == VTK_PHONG)
946 {
947 return "Phong";
948 }
949 else // if (this->Interpolation == VTK_PBR)
950 {
951 return "Physically based rendering";
952 }
953}
954
959{
960 if (this->Representation == VTK_POINTS)
961 {
962 return "Points";
963 }
964 else if (this->Representation == VTK_WIREFRAME)
965 {
966 return "Wireframe";
967 }
968 else
969 {
970 return "Surface";
971 }
972}
973
974VTK_ABI_NAMESPACE_END
975#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
a simple class to control print indentation
Definition vtkIndent.h:108
Store vtkAlgorithm input/output information.
abstract base class for most VTK objects
Definition vtkObject.h:162
represent surface properties of a geometric object
MapOfTextures Textures
static vtkProperty * New()
Construct object with object color, ambient color, diffuse color, specular color, and edge color whit...
std::map< std::string, vtkTexture * > MapOfTextures
double CoatRoughness
void SetRepresentationToPoints()
Control the surface geometry representation for the object.
double CoatNormalScale
int LineStipplePattern
void SetTexture(const char *name, vtkTexture *texture)
Set/Get the texture object to control rendering texture maps.
void SetRepresentationToWireframe()
Control the surface geometry representation for the object.
int LineStippleRepeatFactor
double AnisotropyRotation
double * GetColor()
Set the color of the object.
virtual void SetColor(double a[3])
Set the color of the object.
double OcclusionStrength
double Diffuse
void AddShaderVariable(const char *name, double v1, double v2)
Methods to provide to add shader variables from wrappers.
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
double Opacity
void SetNormalTexture(vtkTexture *texture)
Set the normal texture.
float LineWidth
int GetNumberOfTextures()
Returns the number of textures in this property.
double CoatStrength
void SetEmissiveTexture(vtkTexture *texture)
Set the emissive texture.
void SetInterpolationToFlat()
Set the shading interpolation method for an object.
void RemoveAllTextures()
Remove all the textures.
void SetBaseColorTexture(vtkTexture *texture)
Set the base color texture.
double Metallic
void SetCoatNormalTexture(vtkTexture *texture)
Set the coat normal texture.
void SetInterpolationToGouraud()
Set the shading interpolation method for an object.
vtkTypeBool BackfaceCulling
void DeepCopy(vtkProperty *p)
Assign one property to another.
double Anisotropy
vtkTexture * GetTexture(const char *name)
Set/Get the texture object to control rendering texture maps.
void AddShaderVariable(const char *name, double v)
Methods to provide to add shader variables from wrappers.
void SetInterpolationToPBR()
Set the shading interpolation method for an object.
virtual void Render(vtkActor *, vtkRenderer *)
This method causes the property to set up whatever is required for its instance variables.
const char * GetInterpolationAsString()
Return the method of shading as a descriptive character string.
void SetRepresentationToSurface()
Control the surface geometry representation for the object.
void SetInterpolationToPhong()
Set the shading interpolation method for an object.
double Roughness
double BaseIOR
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Methods to provide to add shader variables from wrappers.
bool RenderPointsAsSpheres
vtkTypeBool Shading
float PointSize
void SetORMTexture(vtkTexture *texture)
Set the ORM texture.
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Methods to provide to add shader variables from wrappers.
virtual void SetColor(double r, double g, double b)
Set the color of the object.
vtkInformation * Information
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Methods to provide to add shader variables from wrappers.
double Specular
double NormalScale
bool RenderLinesAsTubes
virtual void ReleaseGraphicsResources(vtkWindow *win)
Release any graphics resources that are being consumed by this property.
vtkTypeBool EdgeVisibility
vtkTypeBool VertexVisibility
void AddShaderVariable(const char *name, int v)
Methods to provide to add shader variables from wrappers.
double SpecularPower
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetAnisotropyTexture(vtkTexture *texture)
Set the anisotropy texture.
vtkTypeBool FrontfaceCulling
void RemoveTexture(const char *name)
Remove a texture from the collection.
void AddShaderVariable(const char *name, float v1, float v2)
Methods to provide to add shader variables from wrappers.
bool ShowTexturesOnBackface
virtual void PostRender(vtkActor *, vtkRenderer *)
This method is called after the actor has been rendered.
double Ambient
double CoatIOR
void AddShaderVariable(const char *name, int v1, int v2)
Methods to provide to add shader variables from wrappers.
std::map< std::string, vtkTexture * > & GetAllTextures()
Returns all the textures in this property and their names.
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
void AddShaderVariable(const char *name, float v)
Methods to provide to add shader variables from wrappers.
char * MaterialName
abstract specification for renderers
The ShaderProgram uses one or more Shader objects.
handles properties associated with a texture map
Definition vtkTexture.h:167
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
Represents an XML element and those nested inside.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_POINTS
#define VTK_WIREFRAME
#define VTK_PHONG
#define VTK_FLAT
#define VTK_PBR
#define VTK_SURFACE
#define VTK_GOURAUD
#define VTK_INT_MAX
Definition vtkType.h:144
#define VTK_FLOAT_MAX
Definition vtkType.h:152
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_NOT_SUPPORTED
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)