-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFP_FinalRender.cg
69 lines (58 loc) · 1.62 KB
/
FP_FinalRender.cg
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Guodong Rong
FP_FinalRender.cg
The fragment program for final rendering
Copyright (c) 2005-2006
School of Computing
National University of Singapore
All Rights Reserved.
*/
void main(float4 position : WPOS,
out float4 oColor :COLOR,
uniform samplerRECT processedTex : TEXUNIT0,
uniform samplerRECT colorTex : TEXUNIT2,
uniform float2 size)
{
float2 pos;
float3 coord;
int id;
float2 target_pos;
bool IsBoundary;
pos = position.xy+1;
coord = texRECT(processedTex, pos).rgb;
id = int(coord.b);
target_pos.y = floor(id/size.x);
target_pos.x = id-target_pos.y*size.x;
target_pos += 0.5;
IsBoundary = false;
coord = texRECT(processedTex, pos+float2(-1, 0)).rgb;
if (id<int(coord.b))
IsBoundary = true;
coord = texRECT(processedTex, pos+float2(1, 0)).rgb;
if (id<int(coord.b))
IsBoundary = true;
coord = texRECT(processedTex, pos+float2(0, -1)).rgb;
if (id<int(coord.b))
IsBoundary = true;
coord = texRECT(processedTex, pos+float2(0, 1)).rgb;
if (id<int(coord.b))
IsBoundary = true;
coord = texRECT(processedTex, pos+float2(-1, -1)).rgb;
if (id<int(coord.b))
IsBoundary = true;
coord = texRECT(processedTex, pos+float2(1, -1)).rgb;
if (id<int(coord.b))
IsBoundary = true;
coord = texRECT(processedTex, pos+float2(-1, 1)).rgb;
if (id<int(coord.b))
IsBoundary = true;
coord = texRECT(processedTex, pos+float2(1, 1)).rgb;
if (id<int(coord.b))
IsBoundary = true;
float alpha = 0.6;
alpha = 1;
if (IsBoundary)
oColor = float4(0, 0, 0, 1);
else
oColor = texRECT(colorTex, target_pos)*alpha+(1-alpha);
} // main