1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
// ============================================================================
//
// Program: Visualization Toolkit
// Module: vtkShadowMapPassShader_vs.glsl
//
// Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// All rights reserved.
// See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// ============================================================================
// Vertex shader used by the shadow mapping render pass.
#version 110
// NOTE: this shader is concatened on the fly by vtkShadowMapPass.cxx by adding
// a line at the beginning like:
// #define VTK_LIGHTING_NUMBER_OF_LIGHTS equal to the number of shadowing
// lights.
void propFuncVS();
// defined in vtkLighting_s.glsl
void lightSeparateSpecularColor(gl_LightSourceParameters lightSource,
gl_MaterialParameters m,
vec3 surfacePosEyeCoords,
vec3 n,
bool twoSided,
inout vec4 cpri,
inout vec4 csec);
void initBlackColors(out vec4 cpri,
out vec4 csec);
// input are
// uniform gl_TextureMatrix[VTK_LIGHTING_NUMBER_OF_LIGHTS];
varying vec4 shadowCoord[VTK_LIGHTING_NUMBER_OF_LIGHTS];
varying vec4 frontColors[VTK_LIGHTING_NUMBER_OF_LIGHTS];
void main(void)
{
vec4 heyeCoords=gl_ModelViewMatrix*gl_Vertex;
vec3 eyeCoords=heyeCoords.xyz/heyeCoords.w;
vec3 n=gl_NormalMatrix*gl_Normal;
n=normalize(n);
int i=0;
while(i<VTK_LIGHTING_NUMBER_OF_LIGHTS)
{
vec4 cpri;
vec4 csec;
initBlackColors(cpri,csec); // because ambient in previous pass.
lightSeparateSpecularColor(gl_LightSource[i],gl_FrontMaterial,eyeCoords,n,
false,cpri,csec);
// frontColors[i]=vec4(0.5,0.5,0.5,1.0); // cpri+csec;
// frontColors[i]=gl_FrontMaterial.diffuse*gl_LightSource[i].diffuse;
frontColors[i]=cpri; //+csec;
// we could have everything in just gl_TextureMatrix[i] but this would
// require to add code vtkOpenGLActor. Also the value of the uniform
// gl_TextureMatrix[i] would have to be changed on each actor.
// gl_TextureMatrix[i] would be:
// scale_bias*projection_light[i]*view_light[i]*model
// and we would have just texCoord=gl_TextureMatrix[i]*gl_Vertex;
//
// gl_TextureMatrix[i] is actually:
// scale_bias*projection_light[i]*view_light[i]*view_camera_inv
vec4 texCoord=gl_TextureMatrix[i]*heyeCoords;
shadowCoord[i]=texCoord/texCoord.w;
++i;
}
// we have to use the fixed-pipeline transform to avoid mismatching with
// other passes.
gl_Position=ftransform();
// propFuncVS(); // opportunity for the prop to execute its vertex shader.
// we don't initialize gl_FrontColor because we have an array of colors
// in frontColors[].
}
|