Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL150/DepthShadowObjectVp.glsl @ 12373

Last change on this file since 12373 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 3.0 KB
RevLine 
[12115]1#version 150
2/* Copyright Torus Knot Software Ltd 2000-2014
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE SOFTWARE.
21*/
22
23#define BIAS 0
24
25in vec4 position;
26in vec3 normal;
27in vec4 uv0;
28
29uniform mat4 worldViewProj;
30uniform vec4 lightPosition;
31uniform vec3 lightDiffuse;
32#if FOG
33uniform vec2 fogParams;         // x = fog start, y = fog distance
34#endif
35
36#if DEPTH_SHADOWCASTER
37uniform vec4 depthRange; // x = min, y = max, z = range, w = 1/range
38out float depth;
39#endif
40
41#if DEPTH_SHADOWRECEIVER
42uniform vec4 depthRange0; // x = min, y = max, z = range, w = 1/range
43uniform vec4 depthRange1; // x = min, y = max, z = range, w = 1/range
44uniform vec4 depthRange2; // x = min, y = max, z = range, w = 1/range
45uniform mat4 texWorldViewProjMatrix0;
46uniform mat4 texWorldViewProjMatrix1;
47uniform mat4 texWorldViewProjMatrix2;
48out vec4 lightSpacePos0;
49out vec4 lightSpacePos1;
50out vec4 lightSpacePos2;
51#endif
52
53#if !SHADOWCASTER
54out vec3 col;
55#endif
56
57out vec3 diffuseUV;
58
59void main()
60{
61    // project position to the screen
62    gl_Position = worldViewProj * position;
63
64#if !SHADOWCASTER
65        // Get object space light direction
66        vec3 lightDir = normalize(lightPosition.xyz - (position.xyz * lightPosition.w).xyz);
67        col = lightDiffuse.xyz * max(dot(lightDir, normal.xyz), 0.0);
68#  if FOG
69    diffuseUV.z = linearFog(gl_Position.z, fogParams.x, fogParams.y);
70#  endif
71
72#endif
73
74    // pass through other texcoords exactly as they were received
75    diffuseUV.xy = uv0.xy;
76
77#if DEPTH_SHADOWCASTER
78        depth = (BIAS + gl_Position.z - depthRange.x) * depthRange.w;
79#endif
80
81#if DEPTH_SHADOWRECEIVER
82        // Calculate the position of vertex in light space
83        lightSpacePos0 = texWorldViewProjMatrix0 * position;
84        lightSpacePos1 = texWorldViewProjMatrix1 * position;
85        lightSpacePos2 = texWorldViewProjMatrix2 * position;
86
87        // make linear
88        lightSpacePos0.z = (lightSpacePos0.z - depthRange0.x) * depthRange0.w;
89        lightSpacePos1.z = (lightSpacePos1.z - depthRange1.x) * depthRange1.w;
90        lightSpacePos2.z = (lightSpacePos2.z - depthRange2.x) * depthRange2.w;
91
92        // pass cam depth
93        diffuseUV.z = gl_Position.z;
94#endif
95}
Note: See TracBrowser for help on using the repository browser.