-namespace {
-
-const char vertex_shader[] =
- "varying vec2 texcoord;\n"
- "void main()\n"
- "{\n"
- " gl_Position = gl_Vertex;\n"
- " texcoord = gl_Vertex.xy*0.5+0.5;\n"
- "}\n";
-
-const char occlude_fs[] =
- "uniform sampler2D depth;\n"
- "uniform sampler2D rotate;\n"
- "uniform vec2 screen_size;\n"
- "uniform vec2 depth_ratio;\n"
- "uniform float darkness;\n"
- "varying vec2 texcoord;\n"
- "void main()\n"
- "{\n"
- " mat2 transform = mat2(texture2D(rotate, texcoord*screen_size/4.0)*2.0-1.0)\n"
- " *mat2(screen_size.y/screen_size.x, 0.0, 0.0, 1.0)*0.02;\n"
- " float depth_avg = 0.0;\n"
- " for(int i=0; i<=3; ++i)\n"
- " for(int j=0; j<=3; ++j)\n"
- " {\n"
- " vec2 offs = transform*vec2(float(i)-1.5, float(j)-1.5);\n"
- " depth_avg += depth_ratio.x/(texture2D(depth, texcoord+offs).r-depth_ratio.y);\n"
- " }\n"
- " depth_avg /= 16;\n"
- " float sample = depth_ratio.x/(texture2D(depth, texcoord).r-depth_ratio.y);\n"
- " float diff = sample-depth_avg;\n"
- " float shade = min(diff*darkness, 0.0)+1.0;\n"
- " gl_FragColor = vec4(shade, 0.0, 0.0, 1.0);\n"
- "}\n";
-
-const char combine_fs[] =
- "uniform sampler2D color;\n"
- "uniform sampler2D depth;\n"
- "uniform sampler2D occlusion;\n"
- "uniform vec2 screen_size;\n"
- "uniform vec2 depth_ratio;\n"
- "uniform float edge_threshold;\n"
- "varying vec2 texcoord;\n"
- "void main()\n"
- "{\n"
- " float sample = depth_ratio.x/(texture2D(depth, texcoord).r-depth_ratio.y);\n"
- " float sum = 1.0;\n"
- " float count = 1.0;\n"
- " for(int i=0; i<=3; ++i)\n"
- " for(int j=0; j<=3; ++j)\n"
- " {\n"
- " vec2 offs = vec2(float(i)-1.5, float(j)-1.5)/screen_size;\n"
- " float depth = depth_ratio.x/(texture2D(depth, texcoord+offs).r-depth_ratio.y);\n"
- " if(abs(depth-sample)<edge_threshold)\n"
- " {\n"
- " sum += texture2D(occlusion, texcoord+offs).r;\n"
- " count += 1.0;\n"
- " }\n"
- " }\n"
- " gl_FragColor = texture2D(color, texcoord)*sum/count;\n"
- "}\n";
-
-}