VTK  9.5.20251121
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
133
134#ifndef vtkProperty_h
135#define vtkProperty_h
136
137#include "vtkObject.h"
138#include "vtkRenderingCoreModule.h" // For export macro
139#include "vtkSetGet.h"
140#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
141
142#include <map> // used for ivar
143#include <string> // used for ivar
144
145// shading models
146#define VTK_FLAT 0
147#define VTK_GOURAUD 1
148#define VTK_PHONG 2
149#define VTK_PBR 3
150
151// representation models
152#define VTK_POINTS 0
153#define VTK_WIREFRAME 1
154#define VTK_SURFACE 2
155
156VTK_ABI_NAMESPACE_BEGIN
157class vtkActor;
158class vtkInformation;
159class vtkRenderer;
160class vtkShaderProgram;
161class vtkTexture;
162class vtkWindow;
164class vtkXMLMaterial;
165
166class vtkPropertyInternals;
167
168class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkProperty : public vtkObject
169{
170public:
171 vtkTypeMacro(vtkProperty, vtkObject);
172 void PrintSelf(ostream& os, vtkIndent indent) override;
173
180 static vtkProperty* New();
181
186
194 virtual void Render(vtkActor*, vtkRenderer*);
195
203
210
212
215 vtkGetMacro(Lighting, bool);
216 vtkSetMacro(Lighting, bool);
217 vtkBooleanMacro(Lighting, bool);
219
221 {
224 };
225
232
234
240 vtkGetMacro(RenderPointsAsSpheres, bool);
241 vtkSetMacro(RenderPointsAsSpheres, bool);
242 vtkBooleanMacro(RenderPointsAsSpheres, bool);
244
251
258
260
267 vtkGetMacro(RenderLinesAsTubes, bool);
268 vtkSetMacro(RenderLinesAsTubes, bool);
269 vtkBooleanMacro(RenderLinesAsTubes, bool);
271
273
276 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
277 vtkGetMacro(Interpolation, int);
282 const char* GetInterpolationAsString();
284
286
289 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
290 vtkGetMacro(Representation, int);
294 const char* GetRepresentationAsString();
296
298
303 virtual void SetColor(double r, double g, double b);
304 virtual void SetColor(double a[3]);
305 double* GetColor() VTK_SIZEHINT(3);
306 void GetColor(double rgb[3]);
307 void GetColor(double& r, double& g, double& b);
309
311
322 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
323 vtkGetMacro(BaseIOR, double);
325
327
333 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
334 vtkGetMacro(Metallic, double);
336
338
345 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
346 vtkGetMacro(Roughness, double);
348
350
356 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
357 vtkGetMacro(Anisotropy, double);
359
361
367 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
368 vtkGetMacro(AnisotropyRotation, double);
370
372
377 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
378 vtkGetMacro(CoatIOR, double);
380
382
388 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
389 vtkGetMacro(CoatRoughness, double);
391
393
399 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
400 vtkGetMacro(CoatStrength, double);
402
404
409 vtkSetVector3Macro(CoatColor, double);
410 vtkGetVector3Macro(CoatColor, double);
412
414
420 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
421 vtkGetMacro(CoatNormalScale, double);
423
425
430 vtkSetMacro(NormalScale, double);
431 vtkGetMacro(NormalScale, double);
433
435
441 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
442 vtkGetMacro(OcclusionStrength, double);
444
446
452 vtkSetVector3Macro(EmissiveFactor, double);
453 vtkGetVector3Macro(EmissiveFactor, double);
455
457
463 vtkSetVector3Macro(EdgeTint, double);
464 vtkGetVector3Macro(EdgeTint, double);
466
468
471 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
472 vtkGetMacro(Ambient, double);
474
476
479 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
480 vtkGetMacro(Diffuse, double);
482
484
487 vtkSetClampMacro(Specular, double, 0.0, 1.0);
488 vtkGetMacro(Specular, double);
490
492
495 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
496 vtkGetMacro(SpecularPower, double);
498
500
504 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
505 vtkGetMacro(Opacity, double);
507
509
513 vtkSetClampMacro(EdgeOpacity, double, 0.0, 1.0);
514 vtkGetMacro(EdgeOpacity, double);
516
518
524 vtkSetVector3Macro(AmbientColor, double);
525 vtkGetVector3Macro(AmbientColor, double);
527
529
533 vtkSetVector3Macro(DiffuseColor, double);
534 vtkGetVector3Macro(DiffuseColor, double);
536
538
541 vtkSetVector3Macro(SpecularColor, double);
542 vtkGetVector3Macro(SpecularColor, double);
544
546
553 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
555
557
560 vtkSetVector3Macro(EdgeColor, double);
561 vtkGetVector3Macro(EdgeColor, double);
563
565
572 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
574
576
579 vtkSetVector3Macro(VertexColor, double);
580 vtkGetVector3Macro(VertexColor, double);
582
584
588 vtkSetVector4Macro(SelectionColor, double);
589 vtkGetVector4Macro(SelectionColor, double);
591
593
597 vtkSetMacro(SelectionLineWidth, float);
598 vtkGetMacro(SelectionLineWidth, float);
600
602
606 vtkSetMacro(SelectionPointSize, float);
607 vtkGetMacro(SelectionPointSize, float);
609
611
615 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
616 vtkGetMacro(LineWidth, float);
618
620
626 vtkSetClampMacro(EdgeWidth, float, 0, VTK_FLOAT_MAX);
627 vtkGetMacro(EdgeWidth, float);
629
631
638 vtkBooleanMacro(UseLineWidthForEdgeThickness, bool);
642
644
649 vtkSetMacro(LineStipplePattern, int);
650 vtkGetMacro(LineStipplePattern, int);
652
654
659 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
660 vtkGetMacro(LineStippleRepeatFactor, int);
662
664
668 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
669 vtkGetMacro(PointSize, float);
671
673
680 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
682
684
691 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
693
695
698 vtkSetStringMacro(MaterialName);
699 vtkGetStringMacro(MaterialName);
701
703
707 vtkSetMacro(Shading, vtkTypeBool);
708 vtkGetMacro(Shading, vtkTypeBool);
709 vtkBooleanMacro(Shading, vtkTypeBool);
711
713
717 vtkSetMacro(ShowTexturesOnBackface, bool);
718 vtkGetMacro(ShowTexturesOnBackface, bool);
719 vtkBooleanMacro(ShowTexturesOnBackface, bool);
721
723
736 void SetTexture(const char* name, vtkTexture* texture);
737 vtkTexture* GetTexture(const char* name);
739
746 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
747
757 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
758
769 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
770
779 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
780
788 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
789
798 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
799
803 void RemoveTexture(const char* name);
804
809
814
816
819 void SetAllTextures(std::map<std::string, vtkTexture*>& textures);
820 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
822
829
831
834 vtkGetObjectMacro(Information, vtkInformation);
837
839
843 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
845
847
851 static double ComputeIORFromReflectance(double reflectance, double ior);
853
855
863
864protected:
866 ~vtkProperty() override;
867
871 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
872 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
873
874 double Color[3];
875 double AmbientColor[3];
876 double DiffuseColor[3];
877 double SpecularColor[3];
878 double EdgeColor[3];
879 double VertexColor[3];
880 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
881 double Ambient;
882 double Diffuse;
883 double Metallic;
884 double Roughness;
887 double BaseIOR;
888 double CoatIOR;
889 double CoatColor[3];
895 double EmissiveFactor[3];
896 double Specular;
898 double Opacity;
899 double EdgeOpacity = 1.0;
900 double EdgeTint[3];
903 float EdgeWidth = 1.0;
921
923
925
926 typedef std::map<std::string, vtkTexture*> MapOfTextures;
928
929 // Arbitrary extra information associated with this Property.
931
932private:
933 vtkProperty(const vtkProperty&) = delete;
934 void operator=(const vtkProperty&) = delete;
935};
936
941{
942 if (this->Interpolation == VTK_FLAT)
943 {
944 return "Flat";
945 }
946 else if (this->Interpolation == VTK_GOURAUD)
947 {
948 return "Gouraud";
949 }
950 else if (this->Interpolation == VTK_PHONG)
951 {
952 return "Phong";
953 }
954 else // if (this->Interpolation == VTK_PBR)
955 {
956 return "Physically based rendering";
957 }
958}
959
964{
965 if (this->Representation == VTK_POINTS)
966 {
967 return "Points";
968 }
969 else if (this->Representation == VTK_WIREFRAME)
970 {
971 return "Wireframe";
972 }
973 else
974 {
975 return "Surface";
976 }
977}
978
979VTK_ABI_NAMESPACE_END
980#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.
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.
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
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_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:196
#define VTK_FLOAT_MAX
Definition vtkType.h:204
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO