aboutsummaryrefslogtreecommitdiff
path: root/BuddhaTest/Shaders/BuddhaFragment.glsl
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2018-03-09 21:36:10 +0100
committerAndreas Grois <andi@grois.info>2018-03-09 21:36:10 +0100
commit3b734f0d6b9e28c1f2c4ae54e3f46e573e02f4a5 (patch)
tree444542870666e41594e7b493f625ade81d64f885 /BuddhaTest/Shaders/BuddhaFragment.glsl
Initial Commit
Diffstat (limited to 'BuddhaTest/Shaders/BuddhaFragment.glsl')
-rw-r--r--BuddhaTest/Shaders/BuddhaFragment.glsl28
1 files changed, 28 insertions, 0 deletions
diff --git a/BuddhaTest/Shaders/BuddhaFragment.glsl b/BuddhaTest/Shaders/BuddhaFragment.glsl
new file mode 100644
index 0000000..4978765
--- /dev/null
+++ b/BuddhaTest/Shaders/BuddhaFragment.glsl
@@ -0,0 +1,28 @@
+#version 430 core
+
+in vec2 uv;
+
+out vec3 color;
+
+layout(std430, binding=2) buffer renderedData
+{
+ uint width;
+ uint height;
+ uint counts_SSBO[];
+};
+
+uvec3 getColorAt(vec2 fragCoord)
+{
+ uint xIndex = uint(max(0.0,(fragCoord.x+1.0)*0.5*width));
+ uint yIndex = uint(max(0.0,(fragCoord.y+1.0)*0.5*height));
+ uint firstIndex = 3*(xIndex + yIndex * width);
+ return uvec3(counts_SSBO[firstIndex],counts_SSBO[firstIndex+1],counts_SSBO[firstIndex+2]);
+}
+
+void main(){
+ uvec3 totalCount = getColorAt(uv) + getColorAt(vec2(uv.x, -uv.y));
+ uvec3 brightness = getColorAt(vec2(-0.2390625,0));
+
+ vec3 scaled = vec3(totalCount)/max(length(vec3(brightness)),1.0);
+ color = scaled;
+}