1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkEncodedGradientShader.h,v $
6 Date: $Date: 2002/08/22 18:39:30 $
7 Version: $Revision: 1.24 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
19 // .NAME vtkEncodedGradientShader - Compute shading tables for encoded normals.
21 // .SECTION Description
22 // vtkEncodedGradientShader computes shading tables for encoded normals
23 // that indicates the amount of diffuse and specular illumination that is
24 // received from all light sources at a surface location with that normal.
25 // For diffuse illumination this is accurate, but for specular illumination
26 // it is approximate for perspective projections since the center view
27 // direction is always used as the view direction. Since the shading table is
28 // dependent on the volume (for the transformation that must be applied to
29 // the normals to put them into world coordinates) there is a shading table
30 // per volume. This is necessary because multiple volumes can share a
33 #ifndef __vtkEncodedGradientShader_h
34 #define __vtkEncodedGradientShader_h
36 #include "vtkObject.h"
40 class vtkEncodedGradientEstimator;
42 #define VTK_MAX_SHADING_TABLES 100
44 class VTK_RENDERING_EXPORT vtkEncodedGradientShader : public vtkObject
47 static vtkEncodedGradientShader *New();
48 vtkTypeRevisionMacro(vtkEncodedGradientShader,vtkObject);
51 // Print the vtkEncodedGradientShader
52 void PrintSelf( ostream& os, vtkIndent indent );
55 // Set / Get the intensity diffuse / specular light used for the
57 vtkSetClampMacro( ZeroNormalDiffuseIntensity, float, 0.0, 1.0);
58 vtkGetMacro( ZeroNormalDiffuseIntensity, float );
59 vtkSetClampMacro( ZeroNormalSpecularIntensity, float, 0.0, 1.0);
60 vtkGetMacro( ZeroNormalSpecularIntensity, float );
63 // Cause the shading table to be updated
64 void UpdateShadingTable( vtkRenderer *ren, vtkVolume *vol,
65 vtkEncodedGradientEstimator *gradest);
68 // Get the red/green/blue shading table.
69 float *GetRedDiffuseShadingTable( vtkVolume *vol );
70 float *GetGreenDiffuseShadingTable( vtkVolume *vol );
71 float *GetBlueDiffuseShadingTable( vtkVolume *vol );
72 float *GetRedSpecularShadingTable( vtkVolume *vol );
73 float *GetGreenSpecularShadingTable( vtkVolume *vol );
74 float *GetBlueSpecularShadingTable( vtkVolume *vol );
77 vtkEncodedGradientShader();
78 ~vtkEncodedGradientShader();
81 // Build a shading table for a light with the specified direction,
82 // and color for an object of the specified material properties.
83 // material[0] = ambient, material[1] = diffuse, material[2] = specular
84 // and material[3] = specular exponent. If the ambient flag is 1,
85 // then ambient illumination is added. If not, then this means we
86 // are calculating the "other side" of two sided lighting, so no
87 // ambient intensity is added in. If the update flag is 0,
88 // the shading table is overwritten with these new shading values.
89 // If the updateFlag is 1, then the computed light contribution is
90 // added to the current shading table values. There is one shading
91 // table per volume, and the index value indicated which index table
92 // should be used. It is computed in the UpdateShadingTable method.
93 void BuildShadingTable( int index,
94 float lightDirection[3],
97 float viewDirection[3],
100 vtkEncodedGradientEstimator *gradest,
103 // The six shading tables (r diffuse ,g diffuse ,b diffuse,
104 // r specular, g specular, b specular ) - with an entry for each
105 // encoded normal plus one entry at the end for the zero normal
106 // There is one shading table per volume listed in the ShadingTableVolume
107 // array. A null entry indicates an available slot.
108 float *ShadingTable[VTK_MAX_SHADING_TABLES][6];
109 vtkVolume *ShadingTableVolume[VTK_MAX_SHADING_TABLES];
110 int ShadingTableSize[VTK_MAX_SHADING_TABLES];
112 // The intensity of light used for the zero normals, since it
113 // can not be computed from the normal angles. Defaults to 0.0.
114 float ZeroNormalDiffuseIntensity;
115 float ZeroNormalSpecularIntensity;
117 vtkEncodedGradientShader(const vtkEncodedGradientShader&); // Not implemented.
118 void operator=(const vtkEncodedGradientShader&); // Not implemented.