Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/Tutorial/Media/DeferredShadingMedia/DeferredShading/post/hlsl/vs.hlsl @ 25

Last change on this file since 25 was 25, checked in by nicolasc, 17 years ago

added Media and Config

  • Property svn:executable set to *
File size: 2.0 KB
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: Generic fullscreen quad
25*/
26struct VS_OUTPUT {
27   float4 Pos: POSITION;
28   float2 texCoord: TEXCOORD0;
29   float3 projCoord: TEXCOORD1;
30};
31float4x4 invProj;
32
33VS_OUTPUT main(float4 Pos: POSITION){
34   VS_OUTPUT Out;
35
36        // Clean up inaccuracies
37        Pos.xy = sign(Pos.xy);
38
39        Out.Pos = float4(Pos.xy, 0, 1);
40       
41        // Image-space
42        Out.texCoord.x = 0.5 * (1 + Pos.x);
43        Out.texCoord.y = 0.5 * (1 - Pos.y);
44   
45        // Projection coordinates
46        // Inverted projection matrix
47        // These interpolate over the frustrum plane for w=1
48    Out.projCoord = float3(Pos.x, Pos.y, 1) *
49                float3(
50                        invProj[0][0], // X vector component from X
51                        invProj[1][1], // Y vector component from Y
52                        invProj[2][3]  // Z vector component from W
53                );
54
55        return Out;
56}
57
58
59
Note: See TracBrowser for help on using the repository browser.