-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2vboundary.fs
124 lines (121 loc) · 4.21 KB
/
2vboundary.fs
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#version 460 core
in vec2 TexCoords;
uniform sampler2D uv1;
layout(location=1) out vec3 boundarycolor;
// this shader is to maintain the boundary condition of the
// velocity field,after the advect wat applied, we take the advect velocity uv1
// as input (GL_TEXTURE0) ,and store the output back to uv0,the color attachment1 of dyefb
void main()
{
//this fs shader will also set the initial pressure
//for the jacob iteration in the z conponent
vec3 uv=vec3(vec2(texture(uv1,TexCoords)),0.0);
vec3 temp=vec3(1.0,1.0,1.0);
boundarycolor=uv;
vec3 oldpos=vec3(gl_FragCoord.x+1.0,gl_FragCoord.y,gl_FragCoord.z);
if(gl_FragCoord.x==0.5)
{
vec2 oldtexcoord=vec2((oldpos.x-0.5)/799.0,(oldpos.y-0.5)/599.0);
//float sa,sb,sc;
//float s=800*600/2.0;
oldpos=vec3(gl_FragCoord.x+1.0,gl_FragCoord.y,gl_FragCoord.z);
//if(oldpos.y/oldpos.x<0.75)
//{
//sa=((800-oldpos.x)*600/2.0)/s;
//sb=(oldpos.y*800.0/2.0)/s;
//sc=1.0-sa-sb;
//oldtexcoord=vec2(0.0*sa+1.0*sc+1.0*sb,0.0*sa+0.0*sc+1.0*sb);
//}
//else{
//sa=((600-oldpos.y)*800/2.0)/s;
//sb=(oldpos.x*600.0/2.0)/s;
//sc=1.0-sa-sb;
//oldtexcoord=vec2(0.0*sa+0.0*sc+1.0*sb,0.0*sa+1.0*sc+1.0*sb);
//}
//boundarycolor=vec3(1.0,1.0,1.0)-vec3(texture(uv1,oldtexcoord));//zuo
oldtexcoord=vec2(oldpos.x/800.0,oldpos.y/600.0);
temp=vec3(texture(uv1,oldtexcoord));
boundarycolor=vec3(-temp.x,uv.y,uv.z);
//boundarycolor=-1.0*vec3(texture(uv1,oldtexcoord));
//boundarycolor=vec3(1.0,1.0,1.0);
}
else if(gl_FragCoord.x==799.5)
{
vec2 oldtexcoord=vec2((oldpos.x-0.5)/799.0,(oldpos.y-0.5)/599.0);
//float sa,sb,sc;
//float s=800*600/2.0;
oldpos=vec3(gl_FragCoord.x-1.0,gl_FragCoord.y,gl_FragCoord.z);
//if(oldpos.y/oldpos.x<0.75)
//{/
//sa=((800-oldpos.x)*600/2.0)/s;
//sb=(oldpos.y*800.0/2.0)/s;
//sc=1.0-sa-sb;
//oldtexcoord=vec2(0.0*sa+1.0*sc+1.0*sb,0.0*sa+0.0*sc+1.0*sb);
//}
//else{
//sa=((600-oldpos.y)*800/2.0)/s;
//sb=(oldpos.x*600.0/2.0)/s;
//sc=1.0-sa-sb;
//oldtexcoord=vec2(0.0*sa+0.0*sc+1.0*sb,0.0*sa+1.0*sc+1.0*sb);
//}
//boundarycolor=vec3(1.0,1.0,1.0)-vec3(texture(uv1,oldtexcoord));//you
//boundarycolor=-1.0*vec3(texture(uv1,oldtexcoord));
oldtexcoord=vec2(oldpos.x/800.0,oldpos.y/600.0);
temp=vec3(texture(uv1,oldtexcoord));
boundarycolor=vec3(-temp.x,uv.y,uv.z);
//boundarycolor=vec3(0.0,1.0,0.0);
}
else if(gl_FragCoord.y==0.5)//xia mian
{
vec2 oldtexcoord=vec2((oldpos.x-0.5)/799.0,(oldpos.y-0.5)/599.0);
//float sa,sb,sc;
//float s=800*600/2.0;
oldpos=vec3(gl_FragCoord.x,gl_FragCoord.y+1.0,gl_FragCoord.z);
//if(oldpos.y/oldpos.x<0.75)
//{
//sa=((800-oldpos.x)*600/2.0)/s;
//sb=(oldpos.y*800.0/2.0)/s;
//sc=1.0-sa-sb;
//oldtexcoord=vec2(0.0*sa+1.0*sc+1.0*sb,0.0*sa+0.0*sc+1.0*sb);
//}
//else{
//sa=((600-oldpos.y)*800/2.0)/s;
//sb=(oldpos.x*600.0/2.0)/s;
//sc=1.0-sa-sb;
//oldtexcoord=vec2(0.0*sa+0.0*sc+1.0*sb,0.0*sa+1.0*sc+1.0*sb);
//}
//boundarycolor=vec3(1.0,1.0,1.0)-vec3(texture(uv1,oldtexcoord));//xia
//boundarycolor=-1.0*vec3(texture(uv1,oldtexcoord));
oldtexcoord=vec2(oldpos.x/800.0,oldpos.y/600.0);
temp=vec3(texture(uv1,oldtexcoord));
boundarycolor=vec3(uv.x,-temp.y,uv.z);
//boundarycolor=vec3(0.0,0.0,1.0);
}
else if(gl_FragCoord.y==599.5)
{
vec2 oldtexcoord=vec2((oldpos.x-0.5)/799.0,(oldpos.y-0.5)/599.0);
//float sa,sb,sc;
//float s=800*600/2.0;
oldpos=vec3(gl_FragCoord.x,gl_FragCoord.y-1.0,gl_FragCoord.z);
//if(oldpos.y/oldpos.x<0.75)
//{
//sa=((800-oldpos.x)*600/2.0)/s;
//sb=(oldpos.y*800.0/2.0)/s;
//sc=1.0-sa-sb;
//oldtexcoord=vec2(0.0*sa+1.0*sc+1.0*sb,0.0*sa+0.0*sc+1.0*sb);
//}
//else{
//sa=((600-oldpos.y)*800/2.0)/s;
//sb=(oldpos.x*600.0/2.0)/s;
//sc=1.0-sa-sb;
//oldtexcoord=vec2(0.0*sa+0.0*sc+1.0*sb,0.0*sa+1.0*sc+1.0*sb);
//}
//boundarycolor=vec3(1.0,1.0,1.0)-vec3(texture(uv1,oldtexcoord));//shang
//boundarycolor=-1.0*vec3(texture(uv1,oldtexcoord));
oldtexcoord=vec2(oldpos.x/800.0,oldpos.y/600.0);
temp=vec3(texture(uv1,oldtexcoord));
boundarycolor=vec3(uv.x,-temp.y,uv.z);
//boundarycolor=vec3(1.0,1.0,0.0);
}
//boundarycolor=vec3(texture(uv1,TexCoords));
}