VTK  9.1.0
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=========================================================================*/
40#ifndef vtkProperty_h
41#define vtkProperty_h
42
43#include "vtkObject.h"
44#include "vtkRenderingCoreModule.h" // For export macro
45#include <map> // used for ivar
46#include <string> // used for ivar
47
48// shading models
49#define VTK_FLAT 0
50#define VTK_GOURAUD 1
51#define VTK_PHONG 2
52#define VTK_PBR 3
53
54// representation models
55#define VTK_POINTS 0
56#define VTK_WIREFRAME 1
57#define VTK_SURFACE 2
58
59class vtkActor;
60class vtkInformation;
61class vtkRenderer;
63class vtkTexture;
64class vtkWindow;
66class vtkXMLMaterial;
67
68class vtkPropertyInternals;
69
70class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
71{
72public:
73 vtkTypeMacro(vtkProperty, vtkObject);
74 void PrintSelf(ostream& os, vtkIndent indent) override;
75
82 static vtkProperty* New();
83
88
96 virtual void Render(vtkActor*, vtkRenderer*);
97
105
112
114
117 vtkGetMacro(Lighting, bool);
118 vtkSetMacro(Lighting, bool);
119 vtkBooleanMacro(Lighting, bool);
121
123
129 vtkGetMacro(RenderPointsAsSpheres, bool);
130 vtkSetMacro(RenderPointsAsSpheres, bool);
131 vtkBooleanMacro(RenderPointsAsSpheres, bool);
133
135
142 vtkGetMacro(RenderLinesAsTubes, bool);
143 vtkSetMacro(RenderLinesAsTubes, bool);
144 vtkBooleanMacro(RenderLinesAsTubes, bool);
146
148
151 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
152 vtkGetMacro(Interpolation, int);
153 void SetInterpolationToFlat() { this->SetInterpolation(VTK_FLAT); }
154 void SetInterpolationToGouraud() { this->SetInterpolation(VTK_GOURAUD); }
155 void SetInterpolationToPhong() { this->SetInterpolation(VTK_PHONG); }
156 void SetInterpolationToPBR() { this->SetInterpolation(VTK_PBR); }
157 const char* GetInterpolationAsString();
159
161
164 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
165 vtkGetMacro(Representation, int);
166 void SetRepresentationToPoints() { this->SetRepresentation(VTK_POINTS); }
167 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_WIREFRAME); }
168 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SURFACE); }
169 const char* GetRepresentationAsString();
171
173
178 virtual void SetColor(double r, double g, double b);
179 virtual void SetColor(double a[3]);
180 double* GetColor() VTK_SIZEHINT(3);
181 void GetColor(double rgb[3]);
182 void GetColor(double& r, double& g, double& b);
184
186
197 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
198 vtkGetMacro(BaseIOR, double);
200
202
208 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
209 vtkGetMacro(Metallic, double);
211
213
220 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
221 vtkGetMacro(Roughness, double);
223
225
231 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
232 vtkGetMacro(Anisotropy, double);
234
236
242 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
243 vtkGetMacro(AnisotropyRotation, double);
245
247
252 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
253 vtkGetMacro(CoatIOR, double);
255
257
263 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
264 vtkGetMacro(CoatRoughness, double);
266
268
274 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
275 vtkGetMacro(CoatStrength, double);
277
279
284 vtkSetVector3Macro(CoatColor, double);
285 vtkGetVector3Macro(CoatColor, double);
287
289
295 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
296 vtkGetMacro(CoatNormalScale, double);
298
300
305 vtkSetMacro(NormalScale, double);
306 vtkGetMacro(NormalScale, double);
308
310
316 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
317 vtkGetMacro(OcclusionStrength, double);
319
321
327 vtkSetVector3Macro(EmissiveFactor, double);
328 vtkGetVector3Macro(EmissiveFactor, double);
330
332
338 vtkSetVector3Macro(EdgeTint, double);
339 vtkGetVector3Macro(EdgeTint, double);
341
343
346 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
347 vtkGetMacro(Ambient, double);
349
351
354 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
355 vtkGetMacro(Diffuse, double);
357
359
362 vtkSetClampMacro(Specular, double, 0.0, 1.0);
363 vtkGetMacro(Specular, double);
365
367
370 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
371 vtkGetMacro(SpecularPower, double);
373
375
379 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
380 vtkGetMacro(Opacity, double);
382
384
390 vtkSetVector3Macro(AmbientColor, double);
391 vtkGetVector3Macro(AmbientColor, double);
393
395
399 vtkSetVector3Macro(DiffuseColor, double);
400 vtkGetVector3Macro(DiffuseColor, double);
402
404
407 vtkSetVector3Macro(SpecularColor, double);
408 vtkGetVector3Macro(SpecularColor, double);
410
412
417 vtkGetMacro(EdgeVisibility, vtkTypeBool);
418 vtkSetMacro(EdgeVisibility, vtkTypeBool);
419 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
421
423
426 vtkSetVector3Macro(EdgeColor, double);
427 vtkGetVector3Macro(EdgeColor, double);
429
431
436 vtkGetMacro(VertexVisibility, vtkTypeBool);
437 vtkSetMacro(VertexVisibility, vtkTypeBool);
438 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
440
442
445 vtkSetVector3Macro(VertexColor, double);
446 vtkGetVector3Macro(VertexColor, double);
448
450
454 vtkSetVector4Macro(SelectionColor, double);
455 vtkGetVector4Macro(SelectionColor, double);
457
459
463 vtkSetMacro(SelectionLineWidth, float);
464 vtkGetMacro(SelectionLineWidth, float);
466
468
472 vtkSetMacro(SelectionPointSize, float);
473 vtkGetMacro(SelectionPointSize, float);
475
477
481 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
482 vtkGetMacro(LineWidth, float);
484
486
491 vtkSetMacro(LineStipplePattern, int);
492 vtkGetMacro(LineStipplePattern, int);
494
496
501 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
502 vtkGetMacro(LineStippleRepeatFactor, int);
504
506
510 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
511 vtkGetMacro(PointSize, float);
513
515
520 vtkGetMacro(BackfaceCulling, vtkTypeBool);
521 vtkSetMacro(BackfaceCulling, vtkTypeBool);
522 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
524
526
531 vtkGetMacro(FrontfaceCulling, vtkTypeBool);
532 vtkSetMacro(FrontfaceCulling, vtkTypeBool);
533 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
535
537
540 vtkSetStringMacro(MaterialName);
541 vtkGetStringMacro(MaterialName);
543
545
549 vtkSetMacro(Shading, vtkTypeBool);
550 vtkGetMacro(Shading, vtkTypeBool);
551 vtkBooleanMacro(Shading, vtkTypeBool);
553
555
563 virtual void AddShaderVariable(const char* name, int numVars, int* x);
564 virtual void AddShaderVariable(const char* name, int numVars, float* x);
565 virtual void AddShaderVariable(const char* name, int numVars, double* x);
567
569
572 void AddShaderVariable(const char* name, int v) { this->AddShaderVariable(name, 1, &v); }
573 void AddShaderVariable(const char* name, float v) { this->AddShaderVariable(name, 1, &v); }
574 void AddShaderVariable(const char* name, double v) { this->AddShaderVariable(name, 1, &v); }
575 void AddShaderVariable(const char* name, int v1, int v2)
576 {
577 int v[2] = { v1, v2 };
578 this->AddShaderVariable(name, 2, v);
579 }
580 void AddShaderVariable(const char* name, float v1, float v2)
581 {
582 float v[2] = { v1, v2 };
583 this->AddShaderVariable(name, 2, v);
584 }
585 void AddShaderVariable(const char* name, double v1, double v2)
586 {
587 double v[2] = { v1, v2 };
588 this->AddShaderVariable(name, 2, v);
589 }
590 void AddShaderVariable(const char* name, int v1, int v2, int v3)
591 {
592 int v[3] = { v1, v2, v3 };
593 this->AddShaderVariable(name, 3, v);
594 }
595 void AddShaderVariable(const char* name, float v1, float v2, float v3)
596 {
597 float v[3] = { v1, v2, v3 };
598 this->AddShaderVariable(name, 3, v);
599 }
600 void AddShaderVariable(const char* name, double v1, double v2, double v3)
601 {
602 double v[3] = { v1, v2, v3 };
603 this->AddShaderVariable(name, 3, v);
604 }
606
608
612 vtkSetMacro(ShowTexturesOnBackface, bool);
613 vtkGetMacro(ShowTexturesOnBackface, bool);
614 vtkBooleanMacro(ShowTexturesOnBackface, bool);
616
618
631 void SetTexture(const char* name, vtkTexture* texture);
634
641 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
642
652 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
653
664 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
665
674 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
675
683 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
684
693 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
694
698 void RemoveTexture(const char* name);
699
704
709
713 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
714
721
723
726 vtkGetObjectMacro(Information, vtkInformation);
729
731
735 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
737
739
743 static double ComputeIORFromReflectance(double reflectance, double ior);
745
747
755
756protected:
758 ~vtkProperty() override;
759
763 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
764 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
765
766 double Color[3];
767 double AmbientColor[3];
768 double DiffuseColor[3];
769 double SpecularColor[3];
770 double EdgeColor[3];
771 double VertexColor[3];
772 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
773 double Ambient;
774 double Diffuse;
775 double Metallic;
776 double Roughness;
779 double BaseIOR;
780 double CoatIOR;
781 double CoatColor[3];
787 double EmissiveFactor[3];
788 double Specular;
790 double Opacity;
791 double EdgeTint[3];
794 float SelectionPointSize = 2.f;
795 float SelectionLineWidth = 2.f;
808
810
812
813 typedef std::map<std::string, vtkTexture*> MapOfTextures;
815
816 // Arbitrary extra information associated with this Property.
818
819private:
820 vtkProperty(const vtkProperty&) = delete;
821 void operator=(const vtkProperty&) = delete;
822};
823
828{
829 if (this->Interpolation == VTK_FLAT)
830 {
831 return "Flat";
832 }
833 else if (this->Interpolation == VTK_GOURAUD)
834 {
835 return "Gouraud";
836 }
837 else if (this->Interpolation == VTK_PHONG)
838 {
839 return "Phong";
840 }
841 else // if (this->Interpolation == VTK_PBR)
842 {
843 return "Physically based rendering";
844 }
845}
846
851{
852 if (this->Representation == VTK_POINTS)
853 {
854 return "Points";
855 }
856 else if (this->Representation == VTK_WIREFRAME)
857 {
858 return "Wireframe";
859 }
860 else
861 {
862 return "Surface";
863 }
864}
865
866#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:55
a simple class to control print indentation
Definition: vtkIndent.h:43
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:71
MapOfTextures Textures
Definition: vtkProperty.h:814
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:813
double CoatRoughness
Definition: vtkProperty.h:782
~vtkProperty() override
void SetRepresentationToPoints()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:166
double CoatNormalScale
Definition: vtkProperty.h:784
int LineStipplePattern
Definition: vtkProperty.h:796
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:167
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with the Property.
int LineStippleRepeatFactor
Definition: vtkProperty.h:797
double AnisotropyRotation
Definition: vtkProperty.h:778
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:786
double Diffuse
Definition: vtkProperty.h:774
void AddShaderVariable(const char *name, double v1, double v2)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:585
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition: vtkProperty.h:104
double Opacity
Definition: vtkProperty.h:790
void SetNormalTexture(vtkTexture *texture)
Set the normal texture.
Definition: vtkProperty.h:674
int Representation
Definition: vtkProperty.h:799
float LineWidth
Definition: vtkProperty.h:793
int GetNumberOfTextures()
Returns the number of textures in this property.
double CoatStrength
Definition: vtkProperty.h:783
void SetEmissiveTexture(vtkTexture *texture)
Set the emissive texture.
Definition: vtkProperty.h:683
void SetInterpolationToFlat()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:153
void RemoveAllTextures()
Remove all the textures.
void SetBaseColorTexture(vtkTexture *texture)
Set the base color texture.
Definition: vtkProperty.h:641
double Metallic
Definition: vtkProperty.h:775
void SetCoatNormalTexture(vtkTexture *texture)
Set the coat normal texture.
Definition: vtkProperty.h:693
void SetInterpolationToGouraud()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:154
vtkTypeBool BackfaceCulling
Definition: vtkProperty.h:802
void DeepCopy(vtkProperty *p)
Assign one property to another.
int Interpolation
Definition: vtkProperty.h:798
double Anisotropy
Definition: vtkProperty.h:777
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:574
void SetInterpolationToPBR()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:156
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:827
void SetRepresentationToSurface()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:168
void SetInterpolationToPhong()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:155
double Roughness
Definition: vtkProperty.h:776
double BaseIOR
Definition: vtkProperty.h:779
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:600
bool RenderPointsAsSpheres
Definition: vtkProperty.h:805
vtkTypeBool Shading
Definition: vtkProperty.h:809
float PointSize
Definition: vtkProperty.h:792
void SetORMTexture(vtkTexture *texture)
Set the ORM texture.
Definition: vtkProperty.h:652
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:590
virtual void SetColor(double r, double g, double b)
Set the color of the object.
vtkInformation * Information
Definition: vtkProperty.h:817
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:595
double Specular
Definition: vtkProperty.h:788
double NormalScale
Definition: vtkProperty.h:785
bool RenderLinesAsTubes
Definition: vtkProperty.h:806
virtual void ReleaseGraphicsResources(vtkWindow *win)
Release any graphics resources that are being consumed by this property.
vtkTypeBool EdgeVisibility
Definition: vtkProperty.h:800
vtkTypeBool VertexVisibility
Definition: vtkProperty.h:801
void AddShaderVariable(const char *name, int v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:572
double SpecularPower
Definition: vtkProperty.h:789
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:664
vtkTypeBool FrontfaceCulling
Definition: vtkProperty.h:803
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:580
bool ShowTexturesOnBackface
Definition: vtkProperty.h:807
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:773
double CoatIOR
Definition: vtkProperty.h:780
void AddShaderVariable(const char *name, int v1, int v2)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:575
std::map< std::string, vtkTexture * > & GetAllTextures()
Returns all the textures in this property and their names.
Definition: vtkProperty.h:713
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:850
void AddShaderVariable(const char *name, float v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:573
char * MaterialName
Definition: vtkProperty.h:811
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:75
window superclass for vtkRenderWindow
Definition: vtkWindow.h:45
Represents an XML element and those nested inside.
@ Color
Definition: vtkX3D.h:52
@ name
Definition: vtkX3D.h:225
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_POINTS
Definition: vtkProperty.h:55
#define VTK_WIREFRAME
Definition: vtkProperty.h:56
#define VTK_PHONG
Definition: vtkProperty.h:51
#define VTK_FLAT
Definition: vtkProperty.h:49
#define VTK_PBR
Definition: vtkProperty.h:52
#define VTK_SURFACE
Definition: vtkProperty.h:57
#define VTK_GOURAUD
Definition: vtkProperty.h:50
#define VTK_INT_MAX
Definition: vtkType.h:155
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
#define VTK_SIZEHINT(...)