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
134#ifndef vtkProperty_h
135#define vtkProperty_h
136
137#include "vtkDeprecation.h" // For deprecation
138#include "vtkObject.h"
139#include "vtkRenderingCoreModule.h" // For export macro
140#include "vtkSetGet.h"
141#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
142
143#include <map> // used for ivar
144#include <string> // used for ivar
145
146// shading models
147#define VTK_FLAT 0
148#define VTK_GOURAUD 1
149#define VTK_PHONG 2
150#define VTK_PBR 3
151
152// representation models
153#define VTK_POINTS 0
154#define VTK_WIREFRAME 1
155#define VTK_SURFACE 2
156
157VTK_ABI_NAMESPACE_BEGIN
158class vtkActor;
159class vtkInformation;
160class vtkRenderer;
161class vtkShaderProgram;
162class vtkTexture;
163class vtkWindow;
165class vtkXMLMaterial;
166
167class vtkPropertyInternals;
168
169class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkProperty : public vtkObject
170{
171public:
172 vtkTypeMacro(vtkProperty, vtkObject);
173 void PrintSelf(ostream& os, vtkIndent indent) override;
174
181 static vtkProperty* New();
182
187
195 virtual void Render(vtkActor*, vtkRenderer*);
196
204
211
213
216 vtkGetMacro(Lighting, bool);
217 vtkSetMacro(Lighting, bool);
218 vtkBooleanMacro(Lighting, bool);
220
222 {
223 Round,
224 Square,
225 };
226
233
235
241 vtkGetMacro(RenderPointsAsSpheres, bool);
242 vtkSetMacro(RenderPointsAsSpheres, bool);
243 vtkBooleanMacro(RenderPointsAsSpheres, bool);
245
247
254 vtkGetMacro(RenderLinesAsTubes, bool);
255 vtkSetMacro(RenderLinesAsTubes, bool);
256 vtkBooleanMacro(RenderLinesAsTubes, bool);
258
260
263 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
264 vtkGetMacro(Interpolation, int);
265 void SetInterpolationToFlat() { this->SetInterpolation(VTK_FLAT); }
266 void SetInterpolationToGouraud() { this->SetInterpolation(VTK_GOURAUD); }
267 void SetInterpolationToPhong() { this->SetInterpolation(VTK_PHONG); }
268 void SetInterpolationToPBR() { this->SetInterpolation(VTK_PBR); }
269 const char* GetInterpolationAsString();
271
273
276 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
277 vtkGetMacro(Representation, int);
278 void SetRepresentationToPoints() { this->SetRepresentation(VTK_POINTS); }
279 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_WIREFRAME); }
280 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SURFACE); }
281 const char* GetRepresentationAsString();
283
285
290 virtual void SetColor(double r, double g, double b);
291 virtual void SetColor(double a[3]);
292 double* GetColor() VTK_SIZEHINT(3);
293 void GetColor(double rgb[3]);
294 void GetColor(double& r, double& g, double& b);
296
298
309 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
310 vtkGetMacro(BaseIOR, double);
312
314
320 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
321 vtkGetMacro(Metallic, double);
323
325
332 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
333 vtkGetMacro(Roughness, double);
335
337
343 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
344 vtkGetMacro(Anisotropy, double);
346
348
354 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
355 vtkGetMacro(AnisotropyRotation, double);
357
359
364 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
365 vtkGetMacro(CoatIOR, double);
367
369
375 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
376 vtkGetMacro(CoatRoughness, double);
378
380
386 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
387 vtkGetMacro(CoatStrength, double);
389
391
396 vtkSetVector3Macro(CoatColor, double);
397 vtkGetVector3Macro(CoatColor, double);
399
401
407 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
408 vtkGetMacro(CoatNormalScale, double);
410
412
417 vtkSetMacro(NormalScale, double);
418 vtkGetMacro(NormalScale, double);
420
422
428 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
429 vtkGetMacro(OcclusionStrength, double);
431
433
439 vtkSetVector3Macro(EmissiveFactor, double);
440 vtkGetVector3Macro(EmissiveFactor, double);
442
444
450 vtkSetVector3Macro(EdgeTint, double);
451 vtkGetVector3Macro(EdgeTint, double);
453
455
458 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
459 vtkGetMacro(Ambient, double);
461
463
466 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
467 vtkGetMacro(Diffuse, double);
469
471
474 vtkSetClampMacro(Specular, double, 0.0, 1.0);
475 vtkGetMacro(Specular, double);
477
479
482 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
483 vtkGetMacro(SpecularPower, double);
485
487
491 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
492 vtkGetMacro(Opacity, double);
494
496
500 vtkSetClampMacro(EdgeOpacity, double, 0.0, 1.0);
501 vtkGetMacro(EdgeOpacity, double);
503
505
511 vtkSetVector3Macro(AmbientColor, double);
512 vtkGetVector3Macro(AmbientColor, double);
514
516
520 vtkSetVector3Macro(DiffuseColor, double);
521 vtkGetVector3Macro(DiffuseColor, double);
523
525
528 vtkSetVector3Macro(SpecularColor, double);
529 vtkGetVector3Macro(SpecularColor, double);
531
533
538 vtkGetMacro(EdgeVisibility, vtkTypeBool);
539 vtkSetMacro(EdgeVisibility, vtkTypeBool);
540 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
542
544
547 vtkSetVector3Macro(EdgeColor, double);
548 vtkGetVector3Macro(EdgeColor, double);
550
552
557 vtkGetMacro(VertexVisibility, vtkTypeBool);
558 vtkSetMacro(VertexVisibility, vtkTypeBool);
559 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
561
563
566 vtkSetVector3Macro(VertexColor, double);
567 vtkGetVector3Macro(VertexColor, double);
569
571
575 vtkSetVector4Macro(SelectionColor, double);
576 vtkGetVector4Macro(SelectionColor, double);
578
580
584 vtkSetMacro(SelectionLineWidth, float);
585 vtkGetMacro(SelectionLineWidth, float);
587
589
593 vtkSetMacro(SelectionPointSize, float);
594 vtkGetMacro(SelectionPointSize, float);
596
598
602 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
603 vtkGetMacro(LineWidth, float);
605
607
613 vtkSetClampMacro(EdgeWidth, float, 0, VTK_FLOAT_MAX);
614 vtkGetMacro(EdgeWidth, float);
616
618
625 vtkBooleanMacro(UseLineWidthForEdgeThickness, bool);
626 vtkSetMacro(UseLineWidthForEdgeThickness, bool);
627 vtkGetMacro(UseLineWidthForEdgeThickness, bool);
629
631
636 vtkSetMacro(LineStipplePattern, int);
637 vtkGetMacro(LineStipplePattern, int);
639
641
646 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
647 vtkGetMacro(LineStippleRepeatFactor, int);
649
651
655 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
656 vtkGetMacro(PointSize, float);
658
660
665 vtkGetMacro(BackfaceCulling, vtkTypeBool);
666 vtkSetMacro(BackfaceCulling, vtkTypeBool);
667 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
669
671
676 vtkGetMacro(FrontfaceCulling, vtkTypeBool);
677 vtkSetMacro(FrontfaceCulling, vtkTypeBool);
678 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
680
682
685 vtkSetStringMacro(MaterialName);
686 vtkGetStringMacro(MaterialName);
688
690
694 vtkSetMacro(Shading, vtkTypeBool);
695 vtkGetMacro(Shading, vtkTypeBool);
696 vtkBooleanMacro(Shading, vtkTypeBool);
698
700
708 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
709 virtual void AddShaderVariable(const char*, int, int*)
710 { /* noop */
711 }
712 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
713 virtual void AddShaderVariable(const char*, int, float*)
714 { /* noop */
715 }
716 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
717 virtual void AddShaderVariable(const char*, int, double*)
718 { /* noop */
719 }
721
723
726 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
727 void AddShaderVariable(const char*, int)
728 { /* noop */
729 }
730 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
731 void AddShaderVariable(const char*, float)
732 { /* noop */
733 }
734 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
735 void AddShaderVariable(const char*, double)
736 { /* noop */
737 }
738 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
739 void AddShaderVariable(const char*, int, int)
740 { /* noop */
741 }
742 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
743 void AddShaderVariable(const char*, float, float)
744 { /* noop */
745 }
746 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
747 void AddShaderVariable(const char*, double, double)
748 { /* noop */
749 }
750 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
751 void AddShaderVariable(const char*, int, int, int)
752 { /* noop */
753 }
754 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
755 void AddShaderVariable(const char*, float, float, float)
756 { /* noop */
757 }
758 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
759 void AddShaderVariable(const char*, double, double, double)
760 { /* noop */
761 }
763
765
769 vtkSetMacro(ShowTexturesOnBackface, bool);
770 vtkGetMacro(ShowTexturesOnBackface, bool);
771 vtkBooleanMacro(ShowTexturesOnBackface, bool);
773
775
788 void SetTexture(const char* name, vtkTexture* texture);
789 vtkTexture* GetTexture(const char* name);
791
798 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
799
809 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
810
821 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
822
831 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
832
840 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
841
850 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
851
855 void RemoveTexture(const char* name);
856
861
866
868
871 void SetAllTextures(std::map<std::string, vtkTexture*>& textures);
872 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
874
881
883
886 vtkGetObjectMacro(Information, vtkInformation);
889
891
895 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
897
899
903 static double ComputeIORFromReflectance(double reflectance, double ior);
905
907
915
916protected:
918 ~vtkProperty() override;
919
923 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
924 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
925
926 double Color[3];
927 double AmbientColor[3];
928 double DiffuseColor[3];
929 double SpecularColor[3];
930 double EdgeColor[3];
931 double VertexColor[3];
932 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
933 double Ambient;
934 double Diffuse;
935 double Metallic;
936 double Roughness;
939 double BaseIOR;
940 double CoatIOR;
941 double CoatColor[3];
947 double EmissiveFactor[3];
948 double Specular;
950 double Opacity;
951 double EdgeOpacity = 1.0;
952 double EdgeTint[3];
955 float EdgeWidth = 1.0;
956 float SelectionPointSize = 2.f;
957 float SelectionLineWidth = 2.f;
958 bool UseLineWidthForEdgeThickness = true;
968 Point2DShapeType Point2DShape = Point2DShapeType::Square;
972
974
976
977 typedef std::map<std::string, vtkTexture*> MapOfTextures;
979
980 // Arbitrary extra information associated with this Property.
982
983private:
984 vtkProperty(const vtkProperty&) = delete;
985 void operator=(const vtkProperty&) = delete;
986};
987
992{
993 if (this->Interpolation == VTK_FLAT)
994 {
995 return "Flat";
996 }
997 else if (this->Interpolation == VTK_GOURAUD)
998 {
999 return "Gouraud";
1000 }
1001 else if (this->Interpolation == VTK_PHONG)
1002 {
1003 return "Phong";
1004 }
1005 else // if (this->Interpolation == VTK_PBR)
1006 {
1007 return "Physically based rendering";
1008 }
1009}
1010
1015{
1016 if (this->Representation == VTK_POINTS)
1017 {
1018 return "Points";
1019 }
1020 else if (this->Representation == VTK_WIREFRAME)
1021 {
1022 return "Wireframe";
1023 }
1024 else
1025 {
1026 return "Surface";
1027 }
1028}
1029
1030VTK_ABI_NAMESPACE_END
1031#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
a simple class to control print indentation
Definition vtkIndent.h:108
Store vtkAlgorithm input/output information.
abstract base class for most VTK objects
Definition vtkObject.h:162
represent surface properties of a geometric object
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
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
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
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.
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
vtkTypeBool Shading
float PointSize
void SetORMTexture(vtkTexture *texture)
Set the ORM texture.
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.
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
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
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
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
abstract specification for renderers
The ShaderProgram uses one or more Shader objects.
handles properties associated with a texture map
Definition vtkTexture.h:168
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
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
#define VTK_WIREFRAME
#define VTK_PHONG
#define VTK_FLAT
#define VTK_PBR
#define VTK_SURFACE
#define VTK_GOURAUD
#define VTK_INT_MAX
Definition vtkType.h:161
#define VTK_FLOAT_MAX
Definition vtkType.h:169
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO