1 |
|
---|
2 | // gametools
|
---|
3 | #include \
|
---|
4 | <levelutil/shader/prog/d3d9_hlsl/include_stddef_d3d9_hlsl.s3d_shadercode_run>
|
---|
5 |
|
---|
6 |
|
---|
7 | struct VS_INPUT
|
---|
8 | {
|
---|
9 | float2 texCoord : TEXCOORD0;
|
---|
10 | float4 posObj: POSITION;
|
---|
11 | };
|
---|
12 |
|
---|
13 | struct VS_OUTPUT
|
---|
14 | {
|
---|
15 | float4 posScr: POSITION;
|
---|
16 | float4 color :TEXCOORD0;
|
---|
17 |
|
---|
18 | };
|
---|
19 |
|
---|
20 |
|
---|
21 | ///////////////////////////////////////////////////////////////////////////////
|
---|
22 | // Vertexshader
|
---|
23 | // Profile: 3x0
|
---|
24 | const float4x4 projMat;
|
---|
25 | const float4x4 matView;
|
---|
26 | const float4x4 matViewInv;
|
---|
27 | sampler tex0: register(s0);
|
---|
28 |
|
---|
29 | VS_OUTPUT main(VS_INPUT input)
|
---|
30 | {
|
---|
31 |
|
---|
32 | VS_OUTPUT output = (VS_OUTPUT)0;
|
---|
33 |
|
---|
34 | float4 pos = tex2Dlod(tex0, float4(input.posObj.x, input.posObj.y,0,0));
|
---|
35 |
|
---|
36 | output.color = float4(1,0,1,1);
|
---|
37 | if(pos.w == 0)
|
---|
38 | {
|
---|
39 | output.color = float4(0,0,0,0);
|
---|
40 | output.posScr = float4(0, 0, -1000000, 1);
|
---|
41 | }
|
---|
42 | else
|
---|
43 | {
|
---|
44 | float4 mPosition = float4(normalize(pos.xyz),1);
|
---|
45 | float4 cPosition = mul(mPosition, matView);
|
---|
46 | float4 hPosition = mul(cPosition, projMat);
|
---|
47 |
|
---|
48 | float intensity = 0.25;
|
---|
49 |
|
---|
50 | //read four neighbours
|
---|
51 | float pixel = 1.0 / 32.0;
|
---|
52 | float sumdist = 0;
|
---|
53 | float dist;
|
---|
54 | float valids = 0;
|
---|
55 | float4 pos1 = tex2Dlod(tex0, float4(input.posObj.xy + float2(pixel, pixel),0,0));
|
---|
56 | if(pos1.a != 0)
|
---|
57 | {
|
---|
58 | dist = length(pos1.xyz - pos.xyz);
|
---|
59 | sumdist += dist;
|
---|
60 | valids++;
|
---|
61 | }
|
---|
62 |
|
---|
63 | float4 pos2 = tex2Dlod(tex0, float4(input.posObj.xy + float2(-pixel, pixel),0,0));
|
---|
64 | if(pos2.a != 0)
|
---|
65 | {
|
---|
66 | dist = length(pos2.xyz - pos.xyz);
|
---|
67 | sumdist += dist;
|
---|
68 | valids++;
|
---|
69 | }
|
---|
70 |
|
---|
71 | float4 pos3 = tex2Dlod(tex0, float4(input.posObj.xy + float2(pixel, -pixel),0,0));
|
---|
72 | if(pos3.a != 0)
|
---|
73 | {
|
---|
74 | dist = length(pos3.xyz - pos.xyz);
|
---|
75 | sumdist += dist;
|
---|
76 | valids++;
|
---|
77 | }
|
---|
78 |
|
---|
79 | float4 pos4 = tex2Dlod(tex0, float4(input.posObj.xy + float2(-pixel, -pixel),0,0));
|
---|
80 | if(pos4.a != 0)
|
---|
81 | {
|
---|
82 | dist = length(pos4.xyz - pos.xyz);
|
---|
83 | sumdist += dist;
|
---|
84 | valids++;
|
---|
85 | }
|
---|
86 |
|
---|
87 | float avrdist = sumdist / valids;
|
---|
88 | intensity = 0.5 / (avrdist * avrdist * 3.14);
|
---|
89 |
|
---|
90 | output.color = intensity;
|
---|
91 | output.posScr = hPosition;
|
---|
92 | }
|
---|
93 |
|
---|
94 | return output;
|
---|
95 | }
|
---|
96 |
|
---|
97 | ///////////////////////////////////////////////////////////////////////////////
|
---|