-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathObject.Depth.fx
More file actions
51 lines (37 loc) · 1.03 KB
/
Copy pathObject.Depth.fx
File metadata and controls
51 lines (37 loc) · 1.03 KB
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
// TITLE: Depth mapping shader
// AUTHOR: Yve Verstrepen
// DESCRIPTION:
// Simple depth mapping shader.
///////////////////////////////////////////////////////////////////////////
/////// Variables /////////////////////////////////////////
float4x4 WVP : WORLDVIEWPROJECTION;
/////// Structures /////////////////////////////////////////
struct a2v
{
float4 Position : POSITION0;
};
struct v2p
{
float4 Position : POSITION0;
float3 Depth : TEXCOORD0;
};
/////// Programs /////////////////////////////////////////
void VSApp(in a2v IN, out v2p OUT)
{
OUT.Position = mul(IN.Position, WVP);
OUT.Depth.x = OUT.Position.z;
OUT.Depth.y = OUT.Position.w;
}
float4 PSApp(in v2p IN) : COLOR0
{
return float4(IN.Depth.x / IN.Depth.y, 0, 0, 1);
}
/////// Techniques /////////////////////////////////////////
technique DepthMap
{
pass Pass0
{
VertexShader = compile vs_3_0 VSApp();
PixelShader = compile ps_3_0 PSApp();
}
}