source: OGRE/trunk/ogrenew/Samples/Media/DeferredShadingMedia/DeferredShading/post/glsl/LightMaterial_vs.glsl @ 692

Revision 692, 2.6 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1/******************************************************************************
2Copyright (c) W.J. van der Laan
3
4Permission is hereby granted, free of charge, to any person obtaining a copy of
5this software  and associated documentation files (the "Software"), to deal in
6the Software without restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8Software, and to permit persons to whom the Software is furnished to do so, subject
9to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all copies
12or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE
19SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20******************************************************************************/
21/** Deferred shading framework
22        // W.J. :wumpus: van der Laan 2005 //
23       
24        Post shader: Light geometry material
25*/
26varying vec2 texCoord;
27varying vec3 projCoord;
28
29uniform float vpWidth;
30uniform float vpHeight;
31uniform mat4 invProj;
32
33void main()                   
34{
35   vec4 projPos = gl_ModelViewProjectionMatrix * gl_Vertex;
36   projPos = projPos/projPos.w;
37   
38   // projPos is now in nonhomogeneous 2d space -- this makes sure no perspective interpolation is
39   // done that could mess with our concept.
40   //gl_Position = projPos;
41   vec2 texSize = vec2(vpWidth, vpHeight);
42   vec2 tcTemp = vec2(projPos[0], projPos[1])/2.0+0.5;
43   tcTemp = (floor(tcTemp * texSize)+0.5)/texSize;
44   
45   //float3 position = mul(invProj, float4(projCoord, 0, 1))*distance;
46   // Acquire view space position via inverse projection transformation
47   // Optimisation for perspective, symmetric view frustrums
48   // These interpolate over the frustrum plane for w=1
49   
50   projCoord = vec3(projPos[0], projPos[1], 1)*vec3(
51                invProj[0][0], // X vector component from X
52                invProj[1][1], // Y vector component from Y
53                invProj[3][2]  // Z vector component from W
54   );
55   
56   //projCoord = vec3(invProj*vec4(projPos[0], projPos[1], 0, 1));
57   
58   // Texture coordinate magic, this compensates for jitter
59   texCoord = vec2(tcTemp[0], 1.0-tcTemp[1]);   
60   gl_Position = vec4((tcTemp-0.5)*2.0, 0.0, 1.0);
61}
Note: See TracBrowser for help on using the repository browser.