VTK  9.4.20251007
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 "vtkDeprecation.h" // For deprecation
29#include "vtkObject.h"
30#include "vtkRenderingCoreModule.h" // For export macro
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
118 vtkGetMacro(RenderPointsAsSpheres, bool);
119 vtkSetMacro(RenderPointsAsSpheres, bool);
120 vtkBooleanMacro(RenderPointsAsSpheres, bool);
122
124
131 vtkGetMacro(RenderLinesAsTubes, bool);
132 vtkSetMacro(RenderLinesAsTubes, bool);
133 vtkBooleanMacro(RenderLinesAsTubes, bool);
135
137
140 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
141 vtkGetMacro(Interpolation, int);
146 const char* GetInterpolationAsString();
148
150
153 vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
154 vtkGetMacro(Representation, int);
158 const char* GetRepresentationAsString();
160
162
167 virtual void SetColor(double r, double g, double b);
168 virtual void SetColor(double a[3]);
169 double* GetColor() VTK_SIZEHINT(3);
170 void GetColor(double rgb[3]);
171 void GetColor(double& r, double& g, double& b);
173
175
186 vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
187 vtkGetMacro(BaseIOR, double);
189
191
197 vtkSetClampMacro(Metallic, double, 0.0, 1.0);
198 vtkGetMacro(Metallic, double);
200
202
209 vtkSetClampMacro(Roughness, double, 0.0, 1.0);
210 vtkGetMacro(Roughness, double);
212
214
220 vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
221 vtkGetMacro(Anisotropy, double);
223
225
231 vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
232 vtkGetMacro(AnisotropyRotation, double);
234
236
241 vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
242 vtkGetMacro(CoatIOR, double);
244
246
252 vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
253 vtkGetMacro(CoatRoughness, double);
255
257
263 vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
264 vtkGetMacro(CoatStrength, double);
266
268
273 vtkSetVector3Macro(CoatColor, double);
274 vtkGetVector3Macro(CoatColor, double);
276
278
284 vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
285 vtkGetMacro(CoatNormalScale, double);
287
289
294 vtkSetMacro(NormalScale, double);
295 vtkGetMacro(NormalScale, double);
297
299
305 vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
306 vtkGetMacro(OcclusionStrength, double);
308
310
316 vtkSetVector3Macro(EmissiveFactor, double);
317 vtkGetVector3Macro(EmissiveFactor, double);
319
321
327 vtkSetVector3Macro(EdgeTint, double);
328 vtkGetVector3Macro(EdgeTint, double);
330
332
335 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
336 vtkGetMacro(Ambient, double);
338
340
343 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
344 vtkGetMacro(Diffuse, double);
346
348
351 vtkSetClampMacro(Specular, double, 0.0, 1.0);
352 vtkGetMacro(Specular, double);
354
356
359 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
360 vtkGetMacro(SpecularPower, double);
362
364
368 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
369 vtkGetMacro(Opacity, double);
371
373
377 vtkSetClampMacro(EdgeOpacity, double, 0.0, 1.0);
378 vtkGetMacro(EdgeOpacity, double);
380
382
388 vtkSetVector3Macro(AmbientColor, double);
389 vtkGetVector3Macro(AmbientColor, double);
391
393
397 vtkSetVector3Macro(DiffuseColor, double);
398 vtkGetVector3Macro(DiffuseColor, double);
400
402
405 vtkSetVector3Macro(SpecularColor, double);
406 vtkGetVector3Macro(SpecularColor, double);
408
410
417 vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
419
421
424 vtkSetVector3Macro(EdgeColor, double);
425 vtkGetVector3Macro(EdgeColor, double);
427
429
436 vtkBooleanMacro(VertexVisibility, vtkTypeBool);
438
440
443 vtkSetVector3Macro(VertexColor, double);
444 vtkGetVector3Macro(VertexColor, double);
446
448
452 vtkSetVector4Macro(SelectionColor, double);
453 vtkGetVector4Macro(SelectionColor, double);
455
457
461 vtkSetMacro(SelectionLineWidth, float);
462 vtkGetMacro(SelectionLineWidth, float);
464
466
470 vtkSetMacro(SelectionPointSize, float);
471 vtkGetMacro(SelectionPointSize, float);
473
475
479 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
480 vtkGetMacro(LineWidth, float);
482
484
489 vtkSetMacro(LineStipplePattern, int);
490 vtkGetMacro(LineStipplePattern, int);
492
494
499 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
500 vtkGetMacro(LineStippleRepeatFactor, int);
502
504
508 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
509 vtkGetMacro(PointSize, float);
511
513
520 vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
522
524
531 vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
533
535
538 vtkSetStringMacro(MaterialName);
539 vtkGetStringMacro(MaterialName);
541
543
547 vtkSetMacro(Shading, vtkTypeBool);
548 vtkGetMacro(Shading, vtkTypeBool);
549 vtkBooleanMacro(Shading, vtkTypeBool);
551
553
561 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
562 virtual void AddShaderVariable(const char*, int, int*)
563 { /* noop */
564 }
565 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
566 virtual void AddShaderVariable(const char*, int, float*)
567 { /* noop */
568 }
569 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
570 virtual void AddShaderVariable(const char*, int, double*)
571 { /* noop */
572 }
573
574
576
579 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
580 void AddShaderVariable(const char*, int)
581 { /* noop */
582 }
583 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
584 void AddShaderVariable(const char*, float)
585 { /* noop */
586 }
587 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
588 void AddShaderVariable(const char*, double)
589 { /* noop */
590 }
591 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
592 void AddShaderVariable(const char*, int, int)
593 { /* noop */
594 }
595 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
596 void AddShaderVariable(const char*, float, float)
597 { /* noop */
598 }
599 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
600 void AddShaderVariable(const char*, double, double)
601 { /* noop */
602 }
603 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
604 void AddShaderVariable(const char*, int, int, int)
605 { /* noop */
606 }
607 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
608 void AddShaderVariable(const char*, float, float, float)
609 { /* noop */
610 }
611 VTK_DEPRECATED_IN_9_4_0("AddShaderVariable is a no-op and will be removed")
612 void AddShaderVariable(const char*, double, double, double)
613 { /* noop */
614 }
615
616
618
622 vtkSetMacro(ShowTexturesOnBackface, bool);
623 vtkGetMacro(ShowTexturesOnBackface, bool);
624 vtkBooleanMacro(ShowTexturesOnBackface, bool);
626
628
641 void SetTexture(const char* name, vtkTexture* texture);
642 vtkTexture* GetTexture(const char* name);
644
651 void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
652
662 void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
663
674 void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
675
684 void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
685
693 void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
694
703 void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
704
708 void RemoveTexture(const char* name);
709
714
719
723 std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
724
731
733
737 vtkGetObjectMacro(Information, vtkInformation);
741
743
747 static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
749
751
755 static double ComputeIORFromReflectance(double reflectance, double ior);
757
759
767
768protected:
770 ~vtkProperty() override;
771
775 static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
776 double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
777
778 double Color[3];
779 double AmbientColor[3];
780 double DiffuseColor[3];
781 double SpecularColor[3];
782 double EdgeColor[3];
783 double VertexColor[3];
784 double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
785 double Ambient;
786 double Diffuse;
787 double Metallic;
788 double Roughness;
791 double BaseIOR;
792 double CoatIOR;
793 double CoatColor[3];
799 double EmissiveFactor[3];
800 double Specular;
802 double Opacity;
803 double EdgeOpacity = 1.0;
804 double EdgeTint[3];
821
823
825
826 typedef std::map<std::string, vtkTexture*> MapOfTextures;
828
829 // Arbitrary extra information associated with this Property.
831
832private:
833 vtkProperty(const vtkProperty&) = delete;
834 void operator=(const vtkProperty&) = delete;
835};
836
841{
842 if (this->Interpolation == VTK_FLAT)
843 {
844 return "Flat";
845 }
846 else if (this->Interpolation == VTK_GOURAUD)
847 {
848 return "Gouraud";
849 }
850 else if (this->Interpolation == VTK_PHONG)
851 {
852 return "Phong";
853 }
854 else // if (this->Interpolation == VTK_PBR)
855 {
856 return "Physically based rendering";
857 }
858}
859
864{
865 if (this->Representation == VTK_POINTS)
866 {
867 return "Points";
868 }
869 else if (this->Representation == VTK_WIREFRAME)
870 {
871 return "Wireframe";
872 }
873 else
874 {
875 return "Surface";
876 }
877}
878
879VTK_ABI_NAMESPACE_END
880#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...
virtual void AddShaderVariable(const char *, int, int *)
Provide values to initialize shader variables.
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
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
double Opacity
void SetNormalTexture(vtkTexture *texture)
Set the normal texture.
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.
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.
double SelectionColor[4]
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
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()
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
virtual void SetInterpolation(int)
Set the shading interpolation method for an object.
float SelectionLineWidth
abstract specification for renderers
Definition vtkRenderer.h:63
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_DEPRECATED_IN_9_4_0(reason)
#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: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)