VTK  9.5.2
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
24
25#ifndef vtkProperty_h
26#define vtkProperty_h
27
28#include "vtkDeprecation.h" // For deprecation
29#include "vtkObject.h"
30#include "vtkRenderingCoreModule.h" // For export macro
31#include "vtkSetGet.h"
32#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
33
34#include <map> // used for ivar
35#include <string> // used for ivar
36
37// shading models
38#define VTK_FLAT 0
39#define VTK_GOURAUD 1
40#define VTK_PHONG 2
41#define VTK_PBR 3
42
43// representation models
44#define VTK_POINTS 0
45#define VTK_WIREFRAME 1
46#define VTK_SURFACE 2
47
48VTK_ABI_NAMESPACE_BEGIN
49class vtkActor;
50class vtkInformation;
51class vtkRenderer;
53class vtkTexture;
54class vtkWindow;
56class vtkXMLMaterial;
57
58class vtkPropertyInternals;
59
60class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkProperty : public vtkObject
61{
62public:
63 vtkTypeMacro(vtkProperty, vtkObject);
64 void PrintSelf(ostream& os, vtkIndent indent) override;
65
72 static vtkProperty* New();
73
78
86 virtual void Render(vtkActor*, vtkRenderer*);
87
95
102
104
107 vtkGetMacro(Lighting, bool);
108 vtkSetMacro(Lighting, bool);
109 vtkBooleanMacro(Lighting, bool);
111
113 {
114 Round,
115 Square,
116 };
117
124
126
132 vtkGetMacro(RenderPointsAsSpheres, bool);
133 vtkSetMacro(RenderPointsAsSpheres, bool);
134 vtkBooleanMacro(RenderPointsAsSpheres, bool);
136
138
145 vtkGetMacro(RenderLinesAsTubes, bool);
146 vtkSetMacro(RenderLinesAsTubes, bool);
147 vtkBooleanMacro(RenderLinesAsTubes, bool);
149
151
154 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
155 vtkGetMacro(Interpolation, int);
160 const char* GetInterpolationAsString();
162
164
167 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
168 vtkGetMacro(Representation, int);
172 const char* GetRepresentationAsString();
174
176
181 virtual void SetColor(double r, double g, double b);
182 virtual void SetColor(double a[3]);
183 double* GetColor() VTK_SIZEHINT(3);
184 void GetColor(double rgb[3]);
185 void GetColor(double& r, double& g, double& b);
187
189
200 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
201 vtkGetMacro(BaseIOR, double);
203
205
211 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
212 vtkGetMacro(Metallic, double);
214
216
223 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
224 vtkGetMacro(Roughness, double);
226
228
234 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
235 vtkGetMacro(Anisotropy, double);
237
239
245 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
246 vtkGetMacro(AnisotropyRotation, double);
248
250
255 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
256 vtkGetMacro(CoatIOR, double);
258
260
266 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
267 vtkGetMacro(CoatRoughness, double);
269
271
277 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
278 vtkGetMacro(CoatStrength, double);
280
282
287 vtkSetVector3Macro(CoatColor, double);
288 vtkGetVector3Macro(CoatColor, double);
290
292
298 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
299 vtkGetMacro(CoatNormalScale, double);
301
303
308 vtkSetMacro(NormalScale, double);
309 vtkGetMacro(NormalScale, double);
311
313
319 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
320 vtkGetMacro(OcclusionStrength, double);
322
324
330 vtkSetVector3Macro(EmissiveFactor, double);
331 vtkGetVector3Macro(EmissiveFactor, double);
333
335
341 vtkSetVector3Macro(EdgeTint, double);
342 vtkGetVector3Macro(EdgeTint, double);
344
346
349 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
350 vtkGetMacro(Ambient, double);
352
354
357 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
358 vtkGetMacro(Diffuse, double);
360
362
365 vtkSetClampMacro(Specular, double, 0.0, 1.0);
366 vtkGetMacro(Specular, double);
368
370
373 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
374 vtkGetMacro(SpecularPower, double);
376
378
382 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
383 vtkGetMacro(Opacity, double);
385
387
391 vtkSetClampMacro(EdgeOpacity, double, 0.0, 1.0);
392 vtkGetMacro(EdgeOpacity, double);
394
396
402 vtkSetVector3Macro(AmbientColor, double);
403 vtkGetVector3Macro(AmbientColor, double);
405
407
411 vtkSetVector3Macro(DiffuseColor, double);
412 vtkGetVector3Macro(DiffuseColor, double);
414
416
419 vtkSetVector3Macro(SpecularColor, double);
420 vtkGetVector3Macro(SpecularColor, double);
422
424
431 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
433
435
438 vtkSetVector3Macro(EdgeColor, double);
439 vtkGetVector3Macro(EdgeColor, double);
441
443
450 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
452
454
457 vtkSetVector3Macro(VertexColor, double);
458 vtkGetVector3Macro(VertexColor, double);
460
462
466 vtkSetVector4Macro(SelectionColor, double);
467 vtkGetVector4Macro(SelectionColor, double);
469
471
475 vtkSetMacro(SelectionLineWidth, float);
476 vtkGetMacro(SelectionLineWidth, float);
478
480
484 vtkSetMacro(SelectionPointSize, float);
485 vtkGetMacro(SelectionPointSize, float);
487
489
493 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
494 vtkGetMacro(LineWidth, float);
496
498
504 vtkSetClampMacro(EdgeWidth, float, 0, VTK_FLOAT_MAX);
505 vtkGetMacro(EdgeWidth, float);
507
509
516 vtkBooleanMacro(UseLineWidthForEdgeThickness, bool);
520
522
527 vtkSetMacro(LineStipplePattern, int);
528 vtkGetMacro(LineStipplePattern, int);
530
532
537 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
538 vtkGetMacro(LineStippleRepeatFactor, int);
540
542
546 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
547 vtkGetMacro(PointSize, float);
549
551
558 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
560
562
569 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
571
573
576 vtkSetStringMacro(MaterialName);
577 vtkGetStringMacro(MaterialName);
579
581
585 vtkSetMacro(Shading, vtkTypeBool);
586 vtkGetMacro(Shading, vtkTypeBool);
587 vtkBooleanMacro(Shading, vtkTypeBool);
589
591
599 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
600 virtual void AddShaderVariable(const char*, int, int*)
601 { /* noop */
602 }
603 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
604 virtual void AddShaderVariable(const char*, int, float*)
605 { /* noop */
606 }
607 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
608 virtual void AddShaderVariable(const char*, int, double*)
609 { /* noop */
610 }
611
612
614
617 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
618 void AddShaderVariable(const char*, int)
619 { /* noop */
620 }
621 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
622 void AddShaderVariable(const char*, float)
623 { /* noop */
624 }
625 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
626 void AddShaderVariable(const char*, double)
627 { /* noop */
628 }
629 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
630 void AddShaderVariable(const char*, int, int)
631 { /* noop */
632 }
633 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
634 void AddShaderVariable(const char*, float, float)
635 { /* noop */
636 }
637 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
638 void AddShaderVariable(const char*, double, double)
639 { /* noop */
640 }
641 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
642 void AddShaderVariable(const char*, int, int, int)
643 { /* noop */
644 }
645 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
646 void AddShaderVariable(const char*, float, float, float)
647 { /* noop */
648 }
649 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
650 void AddShaderVariable(const char*, double, double, double)
651 { /* noop */
652 }
653
654
656
660 vtkSetMacro(ShowTexturesOnBackface, bool);
661 vtkGetMacro(ShowTexturesOnBackface, bool);
662 vtkBooleanMacro(ShowTexturesOnBackface, bool);
664
666
679 void SetTexture(const char* name, vtkTexture* texture);
680 vtkTexture* GetTexture(const char* name);
682
689 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
690
700 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
701
712 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
713
722 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
723
731 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
732
741 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
742
746 void RemoveTexture(const char* name);
747
752
757
759
762 void SetAllTextures(std::map<std::string, vtkTexture*>& textures);
763 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
765
772
774
777 vtkGetObjectMacro(Information, vtkInformation);
780
782
786 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
788
790
794 static double ComputeIORFromReflectance(double reflectance, double ior);
796
798
806
807protected:
809 ~vtkProperty() override;
810
814 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
815 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
816
817 double Color[3];
818 double AmbientColor[3];
819 double DiffuseColor[3];
820 double SpecularColor[3];
821 double EdgeColor[3];
822 double VertexColor[3];
823 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
824 double Ambient;
825 double Diffuse;
826 double Metallic;
827 double Roughness;
830 double BaseIOR;
831 double CoatIOR;
832 double CoatColor[3];
838 double EmissiveFactor[3];
839 double Specular;
841 double Opacity;
842 double EdgeOpacity = 1.0;
843 double EdgeTint[3];
846 float EdgeWidth = 1.0;
863
865
867
868 typedef std::map<std::string, vtkTexture*> MapOfTextures;
870
871 // Arbitrary extra information associated with this Property.
873
874private:
875 vtkProperty(const vtkProperty&) = delete;
876 void operator=(const vtkProperty&) = delete;
877};
878
883{
884 if (this->Interpolation == VTK_FLAT)
885 {
886 return "Flat";
887 }
888 else if (this->Interpolation == VTK_GOURAUD)
889 {
890 return "Gouraud";
891 }
892 else if (this->Interpolation == VTK_PHONG)
893 {
894 return "Phong";
895 }
896 else // if (this->Interpolation == VTK_PBR)
897 {
898 return "Physically based rendering";
899 }
900}
901
906{
907 if (this->Representation == VTK_POINTS)
908 {
909 return "Points";
910 }
911 else if (this->Representation == VTK_WIREFRAME)
912 {
913 return "Wireframe";
914 }
915 else
916 {
917 return "Surface";
918 }
919}
920
921VTK_ABI_NAMESPACE_END
922#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:42
a simple class to control print indentation
Definition vtkIndent.h:29
Store vtkAlgorithm input/output information.
MapOfTextures Textures
static vtkProperty * New()
Construct object with object color, ambient color, diffuse color, specular color, and edge color whit...
virtual void AddShaderVariable(const char *, int, int *)
Provide values to initialize shader variables.
void SetAllTextures(std::map< std::string, vtkTexture * > &textures)
Set/get all the textures in this property and their names.
double ComputeReflectanceOfBaseLayer()
For PBR, calculate the reflectance of the base layer depending on the presence of a coat layer.
vtkGetEnumMacro(Point2DShape, Point2DShapeType)
std::map< std::string, vtkTexture * > MapOfTextures
double CoatRoughness
~vtkProperty() override
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.
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with the Property.
int LineStippleRepeatFactor
float SelectionPointSize
double EdgeColor[3]
double AnisotropyRotation
double * GetColor()
Set the color of the object.
double Color[3]
static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3], double diffuse, const double diffuse_color[3], double specular, const double specular_color[3])
Computes composite color.
virtual void SetColor(double a[3])
Set the color of the object.
double OcclusionStrength
double Diffuse
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition vtkProperty.h:94
double Opacity
void SetNormalTexture(vtkTexture *texture)
Set the normal texture.
bool UseLineWidthForEdgeThickness
double VertexColor[3]
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.
double AmbientColor[3]
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.
vtkSetEnumMacro(Point2DShape, Point2DShapeType)
Set/Get the 2D shape of points to use when RenderPointsAsSpheres=false.
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 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
bool RenderPointsAsSpheres
Point2DShapeType Point2DShape
vtkTypeBool Shading
float PointSize
void SetORMTexture(vtkTexture *texture)
Set the ORM texture.
double SelectionColor[4]
virtual void SetColor(double r, double g, double b)
Set the color of the object.
vtkInformation * Information
static double ComputeReflectanceFromIOR(double IORTo, double IORFrom)
For PBR, calculate the reflectance from the refractive index of ingoing and outgoing interfaces.
virtual void SetRepresentation(int)
Control the surface geometry representation for the object.
double EdgeTint[3]
double EdgeOpacity
double Specular
float EdgeWidth
double NormalScale
bool RenderLinesAsTubes
virtual void ReleaseGraphicsResources(vtkWindow *win)
Release any graphics resources that are being consumed by this property.
vtkTypeBool EdgeVisibility
vtkTypeBool VertexVisibility
double SpecularColor[3]
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.
bool ShowTexturesOnBackface
double CoatColor[3]
static double ComputeIORFromReflectance(double reflectance, double ior)
For PBR, calculate the refractive index from the reflectance of the interface and the refractive inde...
double EmissiveFactor[3]
virtual void PostRender(vtkActor *, vtkRenderer *)
This method is called after the actor has been rendered.
double Ambient
double CoatIOR
double DiffuseColor[3]
std::map< std::string, vtkTexture * > & GetAllTextures()
Set/get all the textures in this property and their names.
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
char * MaterialName
virtual void SetInterpolation(int)
Set the shading interpolation method for an object.
float SelectionLineWidth
abstract specification for renderers
Definition vtkRenderer.h:60
The ShaderProgram uses one or more Shader objects.
handles properties associated with a texture map
Definition vtkTexture.h:59
window superclass for vtkRenderWindow
Definition vtkWindow.h:26
Represents an XML element and those nested inside.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_4_0(reason)
#define VTK_POINTS
Definition vtkProperty.h:44
#define VTK_WIREFRAME
Definition vtkProperty.h:45
#define VTK_PHONG
Definition vtkProperty.h:40
#define VTK_FLAT
Definition vtkProperty.h:38
#define VTK_PBR
Definition vtkProperty.h:41
#define VTK_SURFACE
Definition vtkProperty.h:46
#define VTK_GOURAUD
Definition vtkProperty.h:39
#define VTK_INT_MAX
Definition vtkType.h:161
#define VTK_FLOAT_MAX
Definition vtkType.h:169
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO