source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg @ 2813

Revision 2813, 1.3 KB checked in by mattausch, 16 years ago (diff)

ssao working ok

Line 
1// input
2struct vtxin
3{
4  float4 position: POSITION;
5  float3 normal: NORMAL;
6  float4 color: COLOR0;
7  float4 texCoord: TEXCOORD0;
8};
9
10// vtx output
11struct vtxout
12{
13  float4 position: POSITION; // eye space
14  float4 texCoord: TEXCOORD0;   
15
16  float4 color: COLOR0; 
17  float4 worldPos: TEXCOORD1; // world position
18  float3 normal: TEXCOORD2;
19};
20
21
22// fragment input
23struct fragin
24{
25  float4 position: POSITION; // eye space
26  float4 texCoord: TEXCOORD0;   
27
28  float4 projPos: WPOS;
29  float4 color: COLOR0; 
30  float4 worldPos: TEXCOORD1; // world position
31  float3 normal: TEXCOORD2;
32};
33
34
35struct pixel
36{
37  float4 col: COLOR0;
38  float4 pos: COLOR1;
39  float3 norm: COLOR2;
40};
41
42
43vtxout vtx(vtxin IN, uniform float4x4 ModelViewProj)
44{
45   vtxout OUT;
46 
47   // transform the vertex position into eye space
48   OUT.position = mul(ModelViewProj, IN.position);
49
50   OUT.color = IN.color;
51
52   OUT.texCoord = IN.texCoord;
53   OUT.worldPos = IN.position;
54   // eye pos with linear depth
55   //OUT.worldPos = OUT.position;
56   OUT.normal = IN.normal;
57
58   return OUT;
59}
60
61
62pixel frag(fragin IN, uniform sampler2D tex, uniform float maxDepth)
63{
64  pixel pix;
65     
66  pix.col = tex2D(tex, IN.texCoord.xy);
67  pix.pos = IN.worldPos * maxDepth;
68  pix.pos.w = IN.projPos.w;
69  pix.norm = IN.normal;
70
71  return pix;
72}
Note: See TracBrowser for help on using the repository browser.