VTK  9.2.6
vtkProperty.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkProperty.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
37#ifndef vtkProperty_h
38#define vtkProperty_h
39
40#include "vtkObject.h"
41#include "vtkRenderingCoreModule.h" // For export macro
42#include <map> // used for ivar
43#include <string> // used for ivar
44
45// shading models
46#define VTK_FLAT 0
47#define VTK_GOURAUD 1
48#define VTK_PHONG 2
49#define VTK_PBR 3
50
51// representation models
52#define VTK_POINTS 0
53#define VTK_WIREFRAME 1
54#define VTK_SURFACE 2
55
56class vtkActor;
57class vtkInformation;
58class vtkRenderer;
60class vtkTexture;
61class vtkWindow;
63class vtkXMLMaterial;
64
65class vtkPropertyInternals;
66
67class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
68{
69public:
70 vtkTypeMacro(vtkProperty, vtkObject);
71 void PrintSelf(ostream& os, vtkIndent indent) override;
72
79 static vtkProperty* New();
80
85
93 virtual void Render(vtkActor*, vtkRenderer*);
94
102
109
111
114 vtkGetMacro(Lighting, bool);
115 vtkSetMacro(Lighting, bool);
116 vtkBooleanMacro(Lighting, bool);
118
120
126 vtkGetMacro(RenderPointsAsSpheres, bool);
127 vtkSetMacro(RenderPointsAsSpheres, bool);
128 vtkBooleanMacro(RenderPointsAsSpheres, bool);
130
132
139 vtkGetMacro(RenderLinesAsTubes, bool);
140 vtkSetMacro(RenderLinesAsTubes, bool);
141 vtkBooleanMacro(RenderLinesAsTubes, bool);
143
145
148 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
149 vtkGetMacro(Interpolation, int);
150 void SetInterpolationToFlat() { this->SetInterpolation(VTK_FLAT); }
151 void SetInterpolationToGouraud() { this->SetInterpolation(VTK_GOURAUD); }
152 void SetInterpolationToPhong() { this->SetInterpolation(VTK_PHONG); }
153 void SetInterpolationToPBR() { this->SetInterpolation(VTK_PBR); }
154 const char* GetInterpolationAsString();
156
158
161 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
162 vtkGetMacro(Representation, int);
163 void SetRepresentationToPoints() { this->SetRepresentation(VTK_POINTS); }
164 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_WIREFRAME); }
165 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SURFACE); }
166 const char* GetRepresentationAsString();
168
170
175 virtual void SetColor(double r, double g, double b);
176 virtual void SetColor(double a[3]);
177 double* GetColor() VTK_SIZEHINT(3);
178 void GetColor(double rgb[3]);
179 void GetColor(double& r, double& g, double& b);
181
183
194 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
195 vtkGetMacro(BaseIOR, double);
197
199
205 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
206 vtkGetMacro(Metallic, double);
208
210
217 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
218 vtkGetMacro(Roughness, double);
220
222
228 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
229 vtkGetMacro(Anisotropy, double);
231
233
239 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
240 vtkGetMacro(AnisotropyRotation, double);
242
244
249 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
250 vtkGetMacro(CoatIOR, double);
252
254
260 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
261 vtkGetMacro(CoatRoughness, double);
263
265
271 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
272 vtkGetMacro(CoatStrength, double);
274
276
281 vtkSetVector3Macro(CoatColor, double);
282 vtkGetVector3Macro(CoatColor, double);
284
286
292 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
293 vtkGetMacro(CoatNormalScale, double);
295
297
302 vtkSetMacro(NormalScale, double);
303 vtkGetMacro(NormalScale, double);
305
307
313 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
314 vtkGetMacro(OcclusionStrength, double);
316
318
324 vtkSetVector3Macro(EmissiveFactor, double);
325 vtkGetVector3Macro(EmissiveFactor, double);
327
329
335 vtkSetVector3Macro(EdgeTint, double);
336 vtkGetVector3Macro(EdgeTint, double);
338
340
343 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
344 vtkGetMacro(Ambient, double);
346
348
351 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
352 vtkGetMacro(Diffuse, double);
354
356
359 vtkSetClampMacro(Specular, double, 0.0, 1.0);
360 vtkGetMacro(Specular, double);
362
364
367 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
368 vtkGetMacro(SpecularPower, double);
370
372
376 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
377 vtkGetMacro(Opacity, double);
379
381
387 vtkSetVector3Macro(AmbientColor, double);
388 vtkGetVector3Macro(AmbientColor, double);
390
392
396 vtkSetVector3Macro(DiffuseColor, double);
397 vtkGetVector3Macro(DiffuseColor, double);
399
401
404 vtkSetVector3Macro(SpecularColor, double);
405 vtkGetVector3Macro(SpecularColor, double);
407
409
414 vtkGetMacro(EdgeVisibility, vtkTypeBool);
415 vtkSetMacro(EdgeVisibility, vtkTypeBool);
416 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
418
420
423 vtkSetVector3Macro(EdgeColor, double);
424 vtkGetVector3Macro(EdgeColor, double);
426
428
433 vtkGetMacro(VertexVisibility, vtkTypeBool);
434 vtkSetMacro(VertexVisibility, vtkTypeBool);
435 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
437
439
442 vtkSetVector3Macro(VertexColor, double);
443 vtkGetVector3Macro(VertexColor, double);
445
447
451 vtkSetVector4Macro(SelectionColor, double);
452 vtkGetVector4Macro(SelectionColor, double);
454
456
460 vtkSetMacro(SelectionLineWidth, float);
461 vtkGetMacro(SelectionLineWidth, float);
463
465
469 vtkSetMacro(SelectionPointSize, float);
470 vtkGetMacro(SelectionPointSize, float);
472
474
478 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
479 vtkGetMacro(LineWidth, float);
481
483
488 vtkSetMacro(LineStipplePattern, int);
489 vtkGetMacro(LineStipplePattern, int);
491
493
498 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
499 vtkGetMacro(LineStippleRepeatFactor, int);
501
503
507 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
508 vtkGetMacro(PointSize, float);
510
512
517 vtkGetMacro(BackfaceCulling, vtkTypeBool);
518 vtkSetMacro(BackfaceCulling, vtkTypeBool);
519 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
521
523
528 vtkGetMacro(FrontfaceCulling, vtkTypeBool);
529 vtkSetMacro(FrontfaceCulling, vtkTypeBool);
530 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
532
534
537 vtkSetStringMacro(MaterialName);
538 vtkGetStringMacro(MaterialName);
540
542
546 vtkSetMacro(Shading, vtkTypeBool);
547 vtkGetMacro(Shading, vtkTypeBool);
548 vtkBooleanMacro(Shading, vtkTypeBool);
550
552
560 virtual void AddShaderVariable(const char* name, int numVars, int* x);
561 virtual void AddShaderVariable(const char* name, int numVars, float* x);
562 virtual void AddShaderVariable(const char* name, int numVars, double* x);
564
566
569 void AddShaderVariable(const char* name, int v) { this->AddShaderVariable(name, 1, &v); }
570 void AddShaderVariable(const char* name, float v) { this->AddShaderVariable(name, 1, &v); }
571 void AddShaderVariable(const char* name, double v) { this->AddShaderVariable(name, 1, &v); }
572 void AddShaderVariable(const char* name, int v1, int v2)
573 {
574 int v[2] = { v1, v2 };
575 this->AddShaderVariable(name, 2, v);
576 }
577 void AddShaderVariable(const char* name, float v1, float v2)
578 {
579 float v[2] = { v1, v2 };
580 this->AddShaderVariable(name, 2, v);
581 }
582 void AddShaderVariable(const char* name, double v1, double v2)
583 {
584 double v[2] = { v1, v2 };
585 this->AddShaderVariable(name, 2, v);
586 }
587 void AddShaderVariable(const char* name, int v1, int v2, int v3)
588 {
589 int v[3] = { v1, v2, v3 };
590 this->AddShaderVariable(name, 3, v);
591 }
592 void AddShaderVariable(const char* name, float v1, float v2, float v3)
593 {
594 float v[3] = { v1, v2, v3 };
595 this->AddShaderVariable(name, 3, v);
596 }
597 void AddShaderVariable(const char* name, double v1, double v2, double v3)
598 {
599 double v[3] = { v1, v2, v3 };
600 this->AddShaderVariable(name, 3, v);
601 }
603
605
609 vtkSetMacro(ShowTexturesOnBackface, bool);
610 vtkGetMacro(ShowTexturesOnBackface, bool);
611 vtkBooleanMacro(ShowTexturesOnBackface, bool);
613
615
628 void SetTexture(const char* name, vtkTexture* texture);
629 vtkTexture* GetTexture(const char* name);
631
638 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
639
649 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
650
661 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
662
671 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
672
680 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
681
690 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
691
695 void RemoveTexture(const char* name);
696
701
706
710 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
711
718
720
723 vtkGetObjectMacro(Information, vtkInformation);
726
728
732 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
734
736
740 static double ComputeIORFromReflectance(double reflectance, double ior);
742
744
752
753protected:
755 ~vtkProperty() override;
756
760 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
761 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
762
763 double Color[3];
764 double AmbientColor[3];
765 double DiffuseColor[3];
766 double SpecularColor[3];
767 double EdgeColor[3];
768 double VertexColor[3];
769 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
770 double Ambient;
771 double Diffuse;
772 double Metallic;
773 double Roughness;
776 double BaseIOR;
777 double CoatIOR;
778 double CoatColor[3];
784 double EmissiveFactor[3];
785 double Specular;
787 double Opacity;
788 double EdgeTint[3];
791 float SelectionPointSize = 2.f;
792 float SelectionLineWidth = 2.f;
805
807
809
810 typedef std::map<std::string, vtkTexture*> MapOfTextures;
812
813 // Arbitrary extra information associated with this Property.
815
816private:
817 vtkProperty(const vtkProperty&) = delete;
818 void operator=(const vtkProperty&) = delete;
819};
820
825{
826 if (this->Interpolation == VTK_FLAT)
827 {
828 return "Flat";
829 }
830 else if (this->Interpolation == VTK_GOURAUD)
831 {
832 return "Gouraud";
833 }
834 else if (this->Interpolation == VTK_PHONG)
835 {
836 return "Phong";
837 }
838 else // if (this->Interpolation == VTK_PBR)
839 {
840 return "Physically based rendering";
841 }
842}
843
848{
849 if (this->Representation == VTK_POINTS)
850 {
851 return "Points";
852 }
853 else if (this->Representation == VTK_WIREFRAME)
854 {
855 return "Wireframe";
856 }
857 else
858 {
859 return "Surface";
860 }
861}
862
863#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
a simple class to control print indentation
Definition: vtkIndent.h:40
Store vtkAlgorithm input/output information.
abstract base class for most VTK objects
Definition: vtkObject.h:63
represent surface properties of a geometric object
Definition: vtkProperty.h:68
MapOfTextures Textures
Definition: vtkProperty.h:811
static vtkProperty * New()
Construct object with object color, ambient color, diffuse color, specular color, and edge color whit...
double ComputeReflectanceOfBaseLayer()
For PBR, calculate the reflectance of the base layer depending on the presence of a coat layer.
std::map< std::string, vtkTexture * > MapOfTextures
Definition: vtkProperty.h:810
double CoatRoughness
Definition: vtkProperty.h:779
~vtkProperty() override
void SetRepresentationToPoints()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:163
double CoatNormalScale
Definition: vtkProperty.h:781
int LineStipplePattern
Definition: vtkProperty.h:793
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.
Definition: vtkProperty.h:164
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with the Property.
int LineStippleRepeatFactor
Definition: vtkProperty.h:794
double AnisotropyRotation
Definition: vtkProperty.h:775
double * GetColor()
Set the color of the object.
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
Definition: vtkProperty.h:783
double Diffuse
Definition: vtkProperty.h:771
void AddShaderVariable(const char *name, double v1, double v2)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:582
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition: vtkProperty.h:101
double Opacity
Definition: vtkProperty.h:787
void SetNormalTexture(vtkTexture *texture)
Set the normal texture.
Definition: vtkProperty.h:671
int Representation
Definition: vtkProperty.h:796
float LineWidth
Definition: vtkProperty.h:790
int GetNumberOfTextures()
Returns the number of textures in this property.
double CoatStrength
Definition: vtkProperty.h:780
void SetEmissiveTexture(vtkTexture *texture)
Set the emissive texture.
Definition: vtkProperty.h:680
void SetInterpolationToFlat()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:150
void RemoveAllTextures()
Remove all the textures.
void SetBaseColorTexture(vtkTexture *texture)
Set the base color texture.
Definition: vtkProperty.h:638
double Metallic
Definition: vtkProperty.h:772
void SetCoatNormalTexture(vtkTexture *texture)
Set the coat normal texture.
Definition: vtkProperty.h:690
void SetInterpolationToGouraud()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:151
vtkTypeBool BackfaceCulling
Definition: vtkProperty.h:799
void DeepCopy(vtkProperty *p)
Assign one property to another.
int Interpolation
Definition: vtkProperty.h:795
double Anisotropy
Definition: vtkProperty.h:774
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.
Definition: vtkProperty.h:571
void SetInterpolationToPBR()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:153
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.
Definition: vtkProperty.h:824
void SetRepresentationToSurface()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:165
void SetInterpolationToPhong()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:152
double Roughness
Definition: vtkProperty.h:773
double BaseIOR
Definition: vtkProperty.h:776
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:597
bool RenderPointsAsSpheres
Definition: vtkProperty.h:802
vtkTypeBool Shading
Definition: vtkProperty.h:806
float PointSize
Definition: vtkProperty.h:789
void SetORMTexture(vtkTexture *texture)
Set the ORM texture.
Definition: vtkProperty.h:649
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:587
virtual void SetColor(double r, double g, double b)
Set the color of the object.
vtkInformation * Information
Definition: vtkProperty.h:814
static double ComputeReflectanceFromIOR(double IORTo, double IORFrom)
For PBR, calculate the reflectance from the refractive index of ingoing and outgoing interfaces.
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:592
double Specular
Definition: vtkProperty.h:785
double NormalScale
Definition: vtkProperty.h:782
bool RenderLinesAsTubes
Definition: vtkProperty.h:803
virtual void ReleaseGraphicsResources(vtkWindow *win)
Release any graphics resources that are being consumed by this property.
vtkTypeBool EdgeVisibility
Definition: vtkProperty.h:797
vtkTypeBool VertexVisibility
Definition: vtkProperty.h:798
void AddShaderVariable(const char *name, int v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:569
double SpecularPower
Definition: vtkProperty.h:786
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.
Definition: vtkProperty.h:661
vtkTypeBool FrontfaceCulling
Definition: vtkProperty.h:800
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.
Definition: vtkProperty.h:577
bool ShowTexturesOnBackface
Definition: vtkProperty.h:804
static double ComputeIORFromReflectance(double reflectance, double ior)
For PBR, calculate the refractive index from the reflectance of the interface and the refractive inde...
virtual void PostRender(vtkActor *, vtkRenderer *)
This method is called after the actor has been rendered.
double Ambient
Definition: vtkProperty.h:770
double CoatIOR
Definition: vtkProperty.h:777
void AddShaderVariable(const char *name, int v1, int v2)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:572
std::map< std::string, vtkTexture * > & GetAllTextures()
Returns all the textures in this property and their names.
Definition: vtkProperty.h:710
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:847
void AddShaderVariable(const char *name, float v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:570
char * MaterialName
Definition: vtkProperty.h:808
abstract specification for renderers
Definition: vtkRenderer.h:73
The ShaderProgram uses one or more Shader objects.
handles properties associated with a texture map
Definition: vtkTexture.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
Represents an XML element and those nested inside.
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_POINTS
Definition: vtkProperty.h:52
#define VTK_WIREFRAME
Definition: vtkProperty.h:53
#define VTK_PHONG
Definition: vtkProperty.h:48
#define VTK_FLAT
Definition: vtkProperty.h:46
#define VTK_PBR
Definition: vtkProperty.h:49
#define VTK_SURFACE
Definition: vtkProperty.h:54
#define VTK_GOURAUD
Definition: vtkProperty.h:47
#define VTK_INT_MAX
Definition: vtkType.h:155
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
#define VTK_SIZEHINT(...)