VTK  9.4.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 "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
227 vtkGetMacro(RenderPointsAsSpheres, bool);
228 vtkSetMacro(RenderPointsAsSpheres, bool);
229 vtkBooleanMacro(RenderPointsAsSpheres, bool);
231
233
240 vtkGetMacro(RenderLinesAsTubes, bool);
241 vtkSetMacro(RenderLinesAsTubes, bool);
242 vtkBooleanMacro(RenderLinesAsTubes, bool);
244
246
249 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
250 vtkGetMacro(Interpolation, int);
251 void SetInterpolationToFlat() { this->SetInterpolation(VTK_FLAT); }
252 void SetInterpolationToGouraud() { this->SetInterpolation(VTK_GOURAUD); }
253 void SetInterpolationToPhong() { this->SetInterpolation(VTK_PHONG); }
254 void SetInterpolationToPBR() { this->SetInterpolation(VTK_PBR); }
255 const char* GetInterpolationAsString();
257
259
262 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
263 vtkGetMacro(Representation, int);
264 void SetRepresentationToPoints() { this->SetRepresentation(VTK_POINTS); }
265 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_WIREFRAME); }
266 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SURFACE); }
267 const char* GetRepresentationAsString();
269
271
276 virtual void SetColor(double r, double g, double b);
277 virtual void SetColor(double a[3]);
278 double* GetColor() VTK_SIZEHINT(3);
279 void GetColor(double rgb[3]);
280 void GetColor(double& r, double& g, double& b);
282
284
295 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
296 vtkGetMacro(BaseIOR, double);
298
300
306 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
307 vtkGetMacro(Metallic, double);
309
311
318 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
319 vtkGetMacro(Roughness, double);
321
323
329 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
330 vtkGetMacro(Anisotropy, double);
332
334
340 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
341 vtkGetMacro(AnisotropyRotation, double);
343
345
350 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
351 vtkGetMacro(CoatIOR, double);
353
355
361 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
362 vtkGetMacro(CoatRoughness, double);
364
366
372 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
373 vtkGetMacro(CoatStrength, double);
375
377
382 vtkSetVector3Macro(CoatColor, double);
383 vtkGetVector3Macro(CoatColor, double);
385
387
393 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
394 vtkGetMacro(CoatNormalScale, double);
396
398
403 vtkSetMacro(NormalScale, double);
404 vtkGetMacro(NormalScale, double);
406
408
414 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
415 vtkGetMacro(OcclusionStrength, double);
417
419
425 vtkSetVector3Macro(EmissiveFactor, double);
426 vtkGetVector3Macro(EmissiveFactor, double);
428
430
436 vtkSetVector3Macro(EdgeTint, double);
437 vtkGetVector3Macro(EdgeTint, double);
439
441
444 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
445 vtkGetMacro(Ambient, double);
447
449
452 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
453 vtkGetMacro(Diffuse, double);
455
457
460 vtkSetClampMacro(Specular, double, 0.0, 1.0);
461 vtkGetMacro(Specular, double);
463
465
468 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
469 vtkGetMacro(SpecularPower, double);
471
473
477 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
478 vtkGetMacro(Opacity, double);
480
482
486 vtkSetClampMacro(EdgeOpacity, double, 0.0, 1.0);
487 vtkGetMacro(EdgeOpacity, double);
489
491
497 vtkSetVector3Macro(AmbientColor, double);
498 vtkGetVector3Macro(AmbientColor, double);
500
502
506 vtkSetVector3Macro(DiffuseColor, double);
507 vtkGetVector3Macro(DiffuseColor, double);
509
511
514 vtkSetVector3Macro(SpecularColor, double);
515 vtkGetVector3Macro(SpecularColor, double);
517
519
524 vtkGetMacro(EdgeVisibility, vtkTypeBool);
525 vtkSetMacro(EdgeVisibility, vtkTypeBool);
526 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
528
530
533 vtkSetVector3Macro(EdgeColor, double);
534 vtkGetVector3Macro(EdgeColor, double);
536
538
543 vtkGetMacro(VertexVisibility, vtkTypeBool);
544 vtkSetMacro(VertexVisibility, vtkTypeBool);
545 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
547
549
552 vtkSetVector3Macro(VertexColor, double);
553 vtkGetVector3Macro(VertexColor, double);
555
557
561 vtkSetVector4Macro(SelectionColor, double);
562 vtkGetVector4Macro(SelectionColor, double);
564
566
570 vtkSetMacro(SelectionLineWidth, float);
571 vtkGetMacro(SelectionLineWidth, float);
573
575
579 vtkSetMacro(SelectionPointSize, float);
580 vtkGetMacro(SelectionPointSize, float);
582
584
588 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
589 vtkGetMacro(LineWidth, float);
591
593
598 vtkSetMacro(LineStipplePattern, int);
599 vtkGetMacro(LineStipplePattern, int);
601
603
608 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
609 vtkGetMacro(LineStippleRepeatFactor, int);
611
613
617 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
618 vtkGetMacro(PointSize, float);
620
622
627 vtkGetMacro(BackfaceCulling, vtkTypeBool);
628 vtkSetMacro(BackfaceCulling, vtkTypeBool);
629 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
631
633
638 vtkGetMacro(FrontfaceCulling, vtkTypeBool);
639 vtkSetMacro(FrontfaceCulling, vtkTypeBool);
640 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
642
644
647 vtkSetStringMacro(MaterialName);
648 vtkGetStringMacro(MaterialName);
650
652
656 vtkSetMacro(Shading, vtkTypeBool);
657 vtkGetMacro(Shading, vtkTypeBool);
658 vtkBooleanMacro(Shading, vtkTypeBool);
660
662
670 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
671 virtual void AddShaderVariable(const char*, int, int*)
672 { /* noop */
673 }
674 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
675 virtual void AddShaderVariable(const char*, int, float*)
676 { /* noop */
677 }
678 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
679 virtual void AddShaderVariable(const char*, int, double*)
680 { /* noop */
681 }
683
685
688 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
689 void AddShaderVariable(const char*, int)
690 { /* noop */
691 }
692 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
693 void AddShaderVariable(const char*, float)
694 { /* noop */
695 }
696 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
697 void AddShaderVariable(const char*, double)
698 { /* noop */
699 }
700 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
701 void AddShaderVariable(const char*, int, int)
702 { /* noop */
703 }
704 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
705 void AddShaderVariable(const char*, float, float)
706 { /* noop */
707 }
708 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
709 void AddShaderVariable(const char*, double, double)
710 { /* noop */
711 }
712 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
713 void AddShaderVariable(const char*, int, int, int)
714 { /* noop */
715 }
716 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
717 void AddShaderVariable(const char*, float, float, float)
718 { /* noop */
719 }
720 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
721 void AddShaderVariable(const char*, double, double, double)
722 { /* noop */
723 }
725
727
731 vtkSetMacro(ShowTexturesOnBackface, bool);
732 vtkGetMacro(ShowTexturesOnBackface, bool);
733 vtkBooleanMacro(ShowTexturesOnBackface, bool);
735
737
750 void SetTexture(const char* name, vtkTexture* texture);
751 vtkTexture* GetTexture(const char* name);
753
760 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
761
771 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
772
783 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
784
793 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
794
802 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
803
812 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
813
817 void RemoveTexture(const char* name);
818
823
828
832 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
833
840
842
846 vtkGetObjectMacro(Information, vtkInformation);
848 virtual void SetInformation(vtkInformation*);
850
852
856 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
858
860
864 static double ComputeIORFromReflectance(double reflectance, double ior);
866
868
874 double ComputeReflectanceOfBaseLayer();
876
877protected:
879 ~vtkProperty() override;
880
884 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
885 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
886
887 double Color[3];
888 double AmbientColor[3];
889 double DiffuseColor[3];
890 double SpecularColor[3];
891 double EdgeColor[3];
892 double VertexColor[3];
893 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
894 double Ambient;
895 double Diffuse;
896 double Metallic;
897 double Roughness;
900 double BaseIOR;
901 double CoatIOR;
902 double CoatColor[3];
908 double EmissiveFactor[3];
909 double Specular;
911 double Opacity;
912 double EdgeOpacity = 1.0;
913 double EdgeTint[3];
916 float SelectionPointSize = 2.f;
917 float SelectionLineWidth = 2.f;
930
932
934
935 typedef std::map<std::string, vtkTexture*> MapOfTextures;
937
938 // Arbitrary extra information associated with this Property.
940
941private:
942 vtkProperty(const vtkProperty&) = delete;
943 void operator=(const vtkProperty&) = delete;
944};
945
950{
951 if (this->Interpolation == VTK_FLAT)
952 {
953 return "Flat";
954 }
955 else if (this->Interpolation == VTK_GOURAUD)
956 {
957 return "Gouraud";
958 }
959 else if (this->Interpolation == VTK_PHONG)
960 {
961 return "Phong";
962 }
963 else // if (this->Interpolation == VTK_PBR)
964 {
965 return "Physically based rendering";
966 }
967}
968
973{
974 if (this->Representation == VTK_POINTS)
975 {
976 return "Points";
977 }
978 else if (this->Representation == VTK_WIREFRAME)
979 {
980 return "Wireframe";
981 }
982 else
983 {
984 return "Surface";
985 }
986}
987
988VTK_ABI_NAMESPACE_END
989#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...
std::map< std::string, vtkTexture * > MapOfTextures
double CoatRoughness
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.
int LineStippleRepeatFactor
double AnisotropyRotation
double * GetColor()
Set the color of the object.
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.
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
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
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()
Returns 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:144
#define VTK_FLOAT_MAX
Definition vtkType.h:152
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_NOT_SUPPORTED
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)