VTK  9.6.1
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 "vtkObject.h"
29#include "vtkRenderingCoreModule.h" // For export macro
30#include "vtkSetGet.h"
31#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
32
33#include <map> // used for ivar
34#include <string> // used for ivar
35
36// shading models
37#define VTK_FLAT 0
38#define VTK_GOURAUD 1
39#define VTK_PHONG 2
40#define VTK_PBR 3
41
42// representation models
43#define VTK_POINTS 0
44#define VTK_WIREFRAME 1
45#define VTK_SURFACE 2
46
47VTK_ABI_NAMESPACE_BEGIN
48class vtkActor;
49class vtkInformation;
50class vtkRenderer;
52class vtkTexture;
53class vtkWindow;
55class vtkXMLMaterial;
56
57class vtkPropertyInternals;
58
59class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkProperty : public vtkObject
60{
61public:
62 vtkTypeMacro(vtkProperty, vtkObject);
63 void PrintSelf(ostream& os, vtkIndent indent) override;
64
71 static vtkProperty* New();
72
77
85 virtual void Render(vtkActor*, vtkRenderer*);
86
94
101
103
106 vtkGetMacro(Lighting, bool);
107 vtkSetMacro(Lighting, bool);
108 vtkBooleanMacro(Lighting, bool);
110
112 {
113 Round,
114 Square,
115 };
116
123
125
131 vtkGetMacro(RenderPointsAsSpheres, bool);
132 vtkSetMacro(RenderPointsAsSpheres, bool);
133 vtkBooleanMacro(RenderPointsAsSpheres, bool);
135
136 enum class LineJoinType
137 {
138 RoundCapRoundJoin,
139 MiterJoin,
140 NoJoin,
141 };
142
149
151
158 vtkGetMacro(RenderLinesAsTubes, bool);
159 vtkSetMacro(RenderLinesAsTubes, bool);
160 vtkBooleanMacro(RenderLinesAsTubes, bool);
162
164
167 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
168 vtkGetMacro(Interpolation, int);
173 const char* GetInterpolationAsString();
175
177
180 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
181 vtkGetMacro(Representation, int);
185 const char* GetRepresentationAsString();
187
189
194 virtual void SetColor(double r, double g, double b);
195 virtual void SetColor(double a[3]);
196 double* GetColor() VTK_SIZEHINT(3);
197 void GetColor(double rgb[3]);
198 void GetColor(double& r, double& g, double& b);
200
202
213 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
214 vtkGetMacro(BaseIOR, double);
216
218
224 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
225 vtkGetMacro(Metallic, double);
227
229
236 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
237 vtkGetMacro(Roughness, double);
239
241
247 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
248 vtkGetMacro(Anisotropy, double);
250
252
258 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
259 vtkGetMacro(AnisotropyRotation, double);
261
263
268 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
269 vtkGetMacro(CoatIOR, double);
271
273
279 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
280 vtkGetMacro(CoatRoughness, double);
282
284
290 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
291 vtkGetMacro(CoatStrength, double);
293
295
300 vtkSetVector3Macro(CoatColor, double);
301 vtkGetVector3Macro(CoatColor, double);
303
305
311 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
312 vtkGetMacro(CoatNormalScale, double);
314
316
321 vtkSetMacro(NormalScale, double);
322 vtkGetMacro(NormalScale, double);
324
326
332 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
333 vtkGetMacro(OcclusionStrength, double);
335
337
343 vtkSetVector3Macro(EmissiveFactor, double);
344 vtkGetVector3Macro(EmissiveFactor, double);
346
348
354 vtkSetVector3Macro(EdgeTint, double);
355 vtkGetVector3Macro(EdgeTint, double);
357
359
362 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
363 vtkGetMacro(Ambient, double);
365
367
370 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
371 vtkGetMacro(Diffuse, double);
373
375
378 vtkSetClampMacro(Specular, double, 0.0, 1.0);
379 vtkGetMacro(Specular, double);
381
383
386 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
387 vtkGetMacro(SpecularPower, double);
389
391
395 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
396 vtkGetMacro(Opacity, double);
398
400
404 vtkSetClampMacro(EdgeOpacity, double, 0.0, 1.0);
405 vtkGetMacro(EdgeOpacity, double);
407
409
415 vtkSetVector3Macro(AmbientColor, double);
416 vtkGetVector3Macro(AmbientColor, double);
418
420
424 vtkSetVector3Macro(DiffuseColor, double);
425 vtkGetVector3Macro(DiffuseColor, double);
427
429
432 vtkSetVector3Macro(SpecularColor, double);
433 vtkGetVector3Macro(SpecularColor, double);
435
437
444 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
446
448
451 vtkSetVector3Macro(EdgeColor, double);
452 vtkGetVector3Macro(EdgeColor, double);
454
456
463 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
465
467
470 vtkSetVector3Macro(VertexColor, double);
471 vtkGetVector3Macro(VertexColor, double);
473
475
479 vtkSetVector4Macro(SelectionColor, double);
480 vtkGetVector4Macro(SelectionColor, double);
482
484
488 vtkSetMacro(SelectionLineWidth, float);
489 vtkGetMacro(SelectionLineWidth, float);
491
493
497 vtkSetMacro(SelectionPointSize, float);
498 vtkGetMacro(SelectionPointSize, float);
500
502
506 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
507 vtkGetMacro(LineWidth, float);
509
511
517 vtkSetClampMacro(EdgeWidth, float, 0, VTK_FLOAT_MAX);
518 vtkGetMacro(EdgeWidth, float);
520
522
529 vtkBooleanMacro(UseLineWidthForEdgeThickness, bool);
533
535
540 vtkSetMacro(LineStipplePattern, int);
541 vtkGetMacro(LineStipplePattern, int);
543
545
550 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
551 vtkGetMacro(LineStippleRepeatFactor, int);
553
555
559 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
560 vtkGetMacro(PointSize, float);
562
564
571 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
573
575
582 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
584
586
589 vtkSetStringMacro(MaterialName);
590 vtkGetStringMacro(MaterialName);
592
594
598 vtkSetMacro(Shading, vtkTypeBool);
599 vtkGetMacro(Shading, vtkTypeBool);
600 vtkBooleanMacro(Shading, vtkTypeBool);
602
604
608 vtkSetMacro(ShowTexturesOnBackface, bool);
609 vtkGetMacro(ShowTexturesOnBackface, bool);
610 vtkBooleanMacro(ShowTexturesOnBackface, bool);
612
614
627 void SetTexture(const char* name, vtkTexture* texture);
628 vtkTexture* GetTexture(const char* name);
630
637 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
638
648 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
649
660 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
661
670 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
671
679 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
680
689 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
690
694 void RemoveTexture(const char* name);
695
700
705
707
710 void SetAllTextures(std::map<std::string, vtkTexture*>& textures);
711 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
713
720
722
725 vtkGetObjectMacro(Information, vtkInformation);
728
730
734 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
736
738
742 static double ComputeIORFromReflectance(double reflectance, double ior);
744
746
754
755protected:
757 ~vtkProperty() override;
758
762 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
763 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
764
765 double Color[3];
766 double AmbientColor[3];
767 double DiffuseColor[3];
768 double SpecularColor[3];
769 double EdgeColor[3];
770 double VertexColor[3];
771 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
772 double Ambient;
773 double Diffuse;
774 double Metallic;
775 double Roughness;
778 double BaseIOR;
779 double CoatIOR;
780 double CoatColor[3];
786 double EmissiveFactor[3];
787 double Specular;
789 double Opacity;
790 double EdgeOpacity = 1.0;
791 double EdgeTint[3];
794 float EdgeWidth = 1.0;
812
814
816
817 typedef std::map<std::string, vtkTexture*> MapOfTextures;
819
820 // Arbitrary extra information associated with this Property.
822
823private:
824 vtkProperty(const vtkProperty&) = delete;
825 void operator=(const vtkProperty&) = delete;
826};
827
832{
833 if (this->Interpolation == VTK_FLAT)
834 {
835 return "Flat";
836 }
837 else if (this->Interpolation == VTK_GOURAUD)
838 {
839 return "Gouraud";
840 }
841 else if (this->Interpolation == VTK_PHONG)
842 {
843 return "Phong";
844 }
845 else // if (this->Interpolation == VTK_PBR)
846 {
847 return "Physically based rendering";
848 }
849}
850
855{
856 if (this->Representation == VTK_POINTS)
857 {
858 return "Points";
859 }
860 else if (this->Representation == VTK_WIREFRAME)
861 {
862 return "Wireframe";
863 }
864 else
865 {
866 return "Surface";
867 }
868}
869
870VTK_ABI_NAMESPACE_END
871#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...
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:93
vtkGetEnumMacro(LineJoin, LineJoinType)
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.
vtkSetEnumMacro(LineJoin, LineJoinType)
Set/Get the 2D shape of points to use when RenderPointsAsSpheres=false.
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]
LineJoinType LineJoin
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:64
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:29
Represents an XML element and those nested inside.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_POINTS
Definition vtkProperty.h:43
#define VTK_WIREFRAME
Definition vtkProperty.h:44
#define VTK_PHONG
Definition vtkProperty.h:39
#define VTK_FLAT
Definition vtkProperty.h:37
#define VTK_PBR
Definition vtkProperty.h:40
#define VTK_SURFACE
Definition vtkProperty.h:45
#define VTK_GOURAUD
Definition vtkProperty.h:38
#define VTK_INT_MAX
Definition vtkType.h:197
#define VTK_FLOAT_MAX
Definition vtkType.h:205
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO