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=========================================================================*/
31#ifndef vtkProperty_h
32#define vtkProperty_h
33
34#include "vtkObject.h"
35#include "vtkRenderingCoreModule.h" // For export macro
36#include <map> // used for ivar
37#include <string> // used for ivar
38
39// shading models
40#define VTK_FLAT 0
41#define VTK_GOURAUD 1
42#define VTK_PHONG 2
43#define VTK_PBR 3
44
45// representation models
46#define VTK_POINTS 0
47#define VTK_WIREFRAME 1
48#define VTK_SURFACE 2
49
50class vtkActor;
51class vtkInformation;
52class vtkRenderer;
54class vtkTexture;
55class vtkWindow;
57class vtkXMLMaterial;
58
59class vtkPropertyInternals;
60
61class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
62{
63public:
64 vtkTypeMacro(vtkProperty, vtkObject);
65 void PrintSelf(ostream& os, vtkIndent indent) override;
66
73 static vtkProperty* New();
74
79
87 virtual void Render(vtkActor*, vtkRenderer*);
88
96
103
105
108 vtkGetMacro(Lighting, bool);
109 vtkSetMacro(Lighting, bool);
110 vtkBooleanMacro(Lighting, bool);
112
114
120 vtkGetMacro(RenderPointsAsSpheres, bool);
121 vtkSetMacro(RenderPointsAsSpheres, bool);
122 vtkBooleanMacro(RenderPointsAsSpheres, bool);
124
126
133 vtkGetMacro(RenderLinesAsTubes, bool);
134 vtkSetMacro(RenderLinesAsTubes, bool);
135 vtkBooleanMacro(RenderLinesAsTubes, bool);
137
139
142 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
143 vtkGetMacro(Interpolation, int);
144 void SetInterpolationToFlat() { this->SetInterpolation(VTK_FLAT); }
145 void SetInterpolationToGouraud() { this->SetInterpolation(VTK_GOURAUD); }
146 void SetInterpolationToPhong() { this->SetInterpolation(VTK_PHONG); }
147 void SetInterpolationToPBR() { this->SetInterpolation(VTK_PBR); }
148 const char* GetInterpolationAsString();
150
152
155 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
156 vtkGetMacro(Representation, int);
157 void SetRepresentationToPoints() { this->SetRepresentation(VTK_POINTS); }
158 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_WIREFRAME); }
159 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SURFACE); }
160 const char* GetRepresentationAsString();
162
164
169 virtual void SetColor(double r, double g, double b);
170 virtual void SetColor(double a[3]);
171 double* GetColor() VTK_SIZEHINT(3);
172 void GetColor(double rgb[3]);
173 void GetColor(double& r, double& g, double& b);
175
177
188 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
189 vtkGetMacro(BaseIOR, double);
191
193
199 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
200 vtkGetMacro(Metallic, double);
202
204
211 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
212 vtkGetMacro(Roughness, double);
214
216
222 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
223 vtkGetMacro(Anisotropy, double);
225
227
233 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
234 vtkGetMacro(AnisotropyRotation, double);
236
238
243 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
244 vtkGetMacro(CoatIOR, double);
246
248
254 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
255 vtkGetMacro(CoatRoughness, double);
257
259
265 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
266 vtkGetMacro(CoatStrength, double);
268
270
275 vtkSetVector3Macro(CoatColor, double);
276 vtkGetVector3Macro(CoatColor, double);
278
280
286 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
287 vtkGetMacro(CoatNormalScale, double);
289
291
296 vtkSetMacro(NormalScale, double);
297 vtkGetMacro(NormalScale, double);
299
301
307 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
308 vtkGetMacro(OcclusionStrength, double);
310
312
318 vtkSetVector3Macro(EmissiveFactor, double);
319 vtkGetVector3Macro(EmissiveFactor, double);
321
323
329 vtkSetVector3Macro(EdgeTint, double);
330 vtkGetVector3Macro(EdgeTint, double);
332
334
337 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
338 vtkGetMacro(Ambient, double);
340
342
345 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
346 vtkGetMacro(Diffuse, double);
348
350
353 vtkSetClampMacro(Specular, double, 0.0, 1.0);
354 vtkGetMacro(Specular, double);
356
358
361 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
362 vtkGetMacro(SpecularPower, double);
364
366
370 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
371 vtkGetMacro(Opacity, double);
373
375
381 vtkSetVector3Macro(AmbientColor, double);
382 vtkGetVector3Macro(AmbientColor, double);
384
386
390 vtkSetVector3Macro(DiffuseColor, double);
391 vtkGetVector3Macro(DiffuseColor, double);
393
395
398 vtkSetVector3Macro(SpecularColor, double);
399 vtkGetVector3Macro(SpecularColor, double);
401
403
408 vtkGetMacro(EdgeVisibility, vtkTypeBool);
409 vtkSetMacro(EdgeVisibility, vtkTypeBool);
410 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
412
414
417 vtkSetVector3Macro(EdgeColor, double);
418 vtkGetVector3Macro(EdgeColor, double);
420
422
427 vtkGetMacro(VertexVisibility, vtkTypeBool);
428 vtkSetMacro(VertexVisibility, vtkTypeBool);
429 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
431
433
436 vtkSetVector3Macro(VertexColor, double);
437 vtkGetVector3Macro(VertexColor, double);
439
441
445 vtkSetVector4Macro(SelectionColor, double);
446 vtkGetVector4Macro(SelectionColor, double);
448
450
454 vtkSetMacro(SelectionLineWidth, float);
455 vtkGetMacro(SelectionLineWidth, float);
457
459
463 vtkSetMacro(SelectionPointSize, float);
464 vtkGetMacro(SelectionPointSize, float);
466
468
472 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
473 vtkGetMacro(LineWidth, float);
475
477
482 vtkSetMacro(LineStipplePattern, int);
483 vtkGetMacro(LineStipplePattern, int);
485
487
492 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
493 vtkGetMacro(LineStippleRepeatFactor, int);
495
497
501 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
502 vtkGetMacro(PointSize, float);
504
506
511 vtkGetMacro(BackfaceCulling, vtkTypeBool);
512 vtkSetMacro(BackfaceCulling, vtkTypeBool);
513 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
515
517
522 vtkGetMacro(FrontfaceCulling, vtkTypeBool);
523 vtkSetMacro(FrontfaceCulling, vtkTypeBool);
524 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
526
528
531 vtkSetStringMacro(MaterialName);
532 vtkGetStringMacro(MaterialName);
534
536
540 vtkSetMacro(Shading, vtkTypeBool);
541 vtkGetMacro(Shading, vtkTypeBool);
542 vtkBooleanMacro(Shading, vtkTypeBool);
544
546
554 virtual void AddShaderVariable(const char* name, int numVars, int* x);
555 virtual void AddShaderVariable(const char* name, int numVars, float* x);
556 virtual void AddShaderVariable(const char* name, int numVars, double* x);
558
560
563 void AddShaderVariable(const char* name, int v) { this->AddShaderVariable(name, 1, &v); }
564 void AddShaderVariable(const char* name, float v) { this->AddShaderVariable(name, 1, &v); }
565 void AddShaderVariable(const char* name, double v) { this->AddShaderVariable(name, 1, &v); }
566 void AddShaderVariable(const char* name, int v1, int v2)
567 {
568 int v[2] = { v1, v2 };
569 this->AddShaderVariable(name, 2, v);
570 }
571 void AddShaderVariable(const char* name, float v1, float v2)
572 {
573 float v[2] = { v1, v2 };
574 this->AddShaderVariable(name, 2, v);
575 }
576 void AddShaderVariable(const char* name, double v1, double v2)
577 {
578 double v[2] = { v1, v2 };
579 this->AddShaderVariable(name, 2, v);
580 }
581 void AddShaderVariable(const char* name, int v1, int v2, int v3)
582 {
583 int v[3] = { v1, v2, v3 };
584 this->AddShaderVariable(name, 3, v);
585 }
586 void AddShaderVariable(const char* name, float v1, float v2, float v3)
587 {
588 float v[3] = { v1, v2, v3 };
589 this->AddShaderVariable(name, 3, v);
590 }
591 void AddShaderVariable(const char* name, double v1, double v2, double v3)
592 {
593 double v[3] = { v1, v2, v3 };
594 this->AddShaderVariable(name, 3, v);
595 }
597
599
603 vtkSetMacro(ShowTexturesOnBackface, bool);
604 vtkGetMacro(ShowTexturesOnBackface, bool);
605 vtkBooleanMacro(ShowTexturesOnBackface, bool);
607
609
622 void SetTexture(const char* name, vtkTexture* texture);
623 vtkTexture* GetTexture(const char* name);
625
632 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
633
643 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
644
655 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
656
665 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
666
674 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
675
684 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
685
689 void RemoveTexture(const char* name);
690
695
700
704 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
705
712
714
717 vtkGetObjectMacro(Information, vtkInformation);
720
722
726 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
728
730
734 static double ComputeIORFromReflectance(double reflectance, double ior);
736
738
746
747protected:
749 ~vtkProperty() override;
750
754 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
755 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
756
757 double Color[3];
758 double AmbientColor[3];
759 double DiffuseColor[3];
760 double SpecularColor[3];
761 double EdgeColor[3];
762 double VertexColor[3];
763 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
764 double Ambient;
765 double Diffuse;
766 double Metallic;
767 double Roughness;
770 double BaseIOR;
771 double CoatIOR;
772 double CoatColor[3];
778 double EmissiveFactor[3];
779 double Specular;
781 double Opacity;
782 double EdgeTint[3];
785 float SelectionPointSize = 2.f;
786 float SelectionLineWidth = 2.f;
799
801
803
804 typedef std::map<std::string, vtkTexture*> MapOfTextures;
806
807 // Arbitrary extra information associated with this Property.
809
810private:
811 vtkProperty(const vtkProperty&) = delete;
812 void operator=(const vtkProperty&) = delete;
813};
814
819{
820 if (this->Interpolation == VTK_FLAT)
821 {
822 return "Flat";
823 }
824 else if (this->Interpolation == VTK_GOURAUD)
825 {
826 return "Gouraud";
827 }
828 else if (this->Interpolation == VTK_PHONG)
829 {
830 return "Phong";
831 }
832 else // if (this->Interpolation == VTK_PBR)
833 {
834 return "Physically based rendering";
835 }
836}
837
842{
843 if (this->Representation == VTK_POINTS)
844 {
845 return "Points";
846 }
847 else if (this->Representation == VTK_WIREFRAME)
848 {
849 return "Wireframe";
850 }
851 else
852 {
853 return "Surface";
854 }
855}
856
857#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:46
a simple class to control print indentation
Definition vtkIndent.h:34
Store vtkAlgorithm input/output information.
abstract base class for most VTK objects
Definition vtkObject.h:57
represent surface properties of a geometric object
Definition vtkProperty.h:62
MapOfTextures Textures
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
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
double AnisotropyRotation
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
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.
Definition vtkProperty.h:95
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
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.
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
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
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
Definition vtkRenderer.h:67
The ShaderProgram uses one or more Shader objects.
handles properties associated with a texture map
Definition vtkTexture.h:66
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:46
#define VTK_WIREFRAME
Definition vtkProperty.h:47
#define VTK_PHONG
Definition vtkProperty.h:42
#define VTK_FLAT
Definition vtkProperty.h:40
#define VTK_PBR
Definition vtkProperty.h:43
#define VTK_SURFACE
Definition vtkProperty.h:48
#define VTK_GOURAUD
Definition vtkProperty.h:41
#define VTK_INT_MAX
Definition vtkType.h:155
#define VTK_FLOAT_MAX
Definition vtkType.h:163
#define VTK_SIZEHINT(...)