source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/common.h @ 3170

Revision 3170, 852 bytes checked in by mattausch, 16 years ago (diff)
Line 
1inline float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr)
2{
3        float3 x1 = lerp(bl, tl, w.y);
4        float3 x2 = lerp(br, tr, w.y);
5        float3 v = lerp(x1, x2, w.x);
6
7        return v;
8}
9
10
11// reconstruct world space position
12inline float3 ReconstructSamplePos(uniform sampler2D tex,
13                                                                   float2 texcoord,
14                                                                   float3 bl, float3 br, float3 tl, float3 tr)
15{
16        const float eyeSpaceDepth = tex2Dlod(tex, float4(texcoord, 0, 0)).w;
17       
18        float3 viewVec = Interpol(texcoord, bl, br, tl, tr);
19        float3 samplePos = -viewVec * eyeSpaceDepth;
20
21        return samplePos;
22}
23
24
25inline float SqrLen(float3 v)
26{
27        return v.x * v.x + v.y * v.y + v.z * v.z;
28}
29
30
31inline float2 myreflect(float2 pt, float2 n)
32{
33        // distance to plane
34        float d = dot(n, pt);
35        // reflect around plane
36        float2 rpt = pt - d * 2.0f * n;
37
38        return rpt;
39}
Note: See TracBrowser for help on using the repository browser.