aboutsummaryrefslogtreecommitdiff
path: root/BuddhaTest/Shaders/BuddhaFragment.glsl
blob: 24edcd9a848373e6003569774d107d17487f9da1 (plain) (blame)
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
#version 430 core

in vec2 uv;

out vec3 color;

layout(std430, binding=2) restrict readonly buffer renderedDataRed
{
        restrict readonly uint counts_SSBORed[];
};
layout(std430, binding=3) restrict readonly buffer renderedDataGreen
{
        restrict readonly uint counts_SSBOGreen[];
};
layout(std430, binding=4) restrict readonly buffer renderedDataBlue
{
        restrict readonly uint counts_SSBOBlue[];
};

uniform uint width;
uniform uint height;

uvec3 getColorAt(vec2 fragCoord)
{
    uint xIndex = uint(max(0.0,(fragCoord.x+1.0)*0.5*width));
    uint yIndex = uint(max(0.0,abs(fragCoord.y)*height));
    uint firstIndex = (xIndex + yIndex * width);
    return uvec3(counts_SSBORed[firstIndex],counts_SSBOGreen[firstIndex],counts_SSBOBlue[firstIndex]);
}

void main(){
    uvec3 totalCount = getColorAt(uv);
    uvec3 brightness = getColorAt(vec2(-0.2390625,0));

    vec3 scaled = vec3(totalCount)/max(length(vec3(brightness)),1.0);
    color = scaled;
}