summaryrefslogtreecommitdiff
path: root/servers/visual/rasterizer/shaders/canvas_occlusion_fix.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'servers/visual/rasterizer/shaders/canvas_occlusion_fix.glsl')
-rw-r--r--servers/visual/rasterizer/shaders/canvas_occlusion_fix.glsl53
1 files changed, 48 insertions, 5 deletions
diff --git a/servers/visual/rasterizer/shaders/canvas_occlusion_fix.glsl b/servers/visual/rasterizer/shaders/canvas_occlusion_fix.glsl
index 48757bb68a..7c9651201e 100644
--- a/servers/visual/rasterizer/shaders/canvas_occlusion_fix.glsl
+++ b/servers/visual/rasterizer/shaders/canvas_occlusion_fix.glsl
@@ -35,22 +35,65 @@ layout(set=0, binding=0) uniform sampler2D textures[4];
layout(location = 0) in highp float u;
layout(location = 0) out highp float distance;
+layout(push_constant, binding = 0, std430) uniform Constants {
+ mat4 projection;
+ float far;
+ float pad[3];
+} constants;
+
void main() {
//0-1 in the texture we are writing to represents a circle, 0-2PI)
//obtain the quarter circle from the source textures
- highp float sub_angle = ((mod(u,0.25)/0.25)*2.0-1.0)*(PI/4.0);
- highp float x=tan(sub_angle)*0.5+0.5;
+ float angle=fract(u+1.0-0.125);
float depth;
- if (u<0.25) {
+#if 0
+ if (angle<0.25) {
+ highp float sub_angle = ((angle/0.25)*2.0-1.0)*(PI/4.0);
+ highp float x=tan(sub_angle)*0.5+0.5;
depth=texture(textures[0],vec2(x,0.0)).x;
- } else if (u<0.50) {
+ } else if (angle<0.50) {
+ highp float sub_angle = (((angle-0.25)/0.25)*2.0-1.0)*(PI/4.0);
+ highp float x=tan(sub_angle)*0.5+0.5;
depth=texture(textures[1],vec2(x,0.0)).x;
- } else if (u<0.75) {
+ } else if (angle<0.75) {
+ highp float sub_angle = (((angle-0.5)/0.25)*2.0-1.0)*(PI/4.0);
+ highp float x=tan(sub_angle)*0.5+0.5;
depth=texture(textures[2],vec2(x,0.0)).x;
} else {
+ highp float sub_angle = (((angle-0.75)/0.25)*2.0-1.0)*(PI/4.0);
+ highp float x=tan(sub_angle)*0.5+0.5;
depth=texture(textures[3],vec2(x,0.0)).x;
}
+#else
+ if (angle<0.25) {
+ highp float sub_angle = ((angle/0.25)*2.0-1.0)*(PI/4.0);
+ vec2 pos = vec2(cos(sub_angle),sin(sub_angle))*constants.far;
+ vec4 proj = constants.projection * vec4(pos,0.0,1.0);
+ float coord = (proj.x/proj.w)*0.5+0.5;
+ depth=texture(textures[0],vec2(coord,0.0)).x;
+ } else if (angle<0.50) {
+ highp float sub_angle = (((angle-0.25)/0.25)*2.0-1.0)*(PI/4.0);
+ vec2 pos = vec2(cos(sub_angle),sin(sub_angle))*constants.far;
+ vec4 proj = constants.projection * vec4(pos,0.0,1.0);
+ float coord = (proj.x/proj.w)*0.5+0.5;
+ depth=texture(textures[1],vec2(coord,0.0)).x;
+ } else if (angle<0.75) {
+ highp float sub_angle = (((angle-0.5)/0.25)*2.0-1.0)*(PI/4.0);
+ vec2 pos = vec2(cos(sub_angle),sin(sub_angle))*constants.far;
+ vec4 proj = constants.projection * vec4(pos,0.0,1.0);
+ float coord = (proj.x/proj.w)*0.5+0.5;
+ depth=texture(textures[2],vec2(coord,0.0)).x;
+ } else {
+ highp float sub_angle = (((angle-0.75)/0.25)*2.0-1.0)*(PI/4.0);
+ vec2 pos = vec2(cos(sub_angle),sin(sub_angle))*constants.far;
+ vec4 proj = constants.projection * vec4(pos,0.0,1.0);
+ float coord = (proj.x/proj.w)*0.5+0.5;
+ depth=texture(textures[3],vec2(coord,0.0)).x;
+ }
+
+
+#endif
distance=depth;
}