32 lines
1.2 KiB
Plaintext
32 lines
1.2 KiB
Plaintext
#version 450
|
|
|
|
layout(local_size_x = WIDTH, local_size_y = HEIGHT) in;
|
|
|
|
layout(binding = COLOUR_IN_BINDING) uniform sampler2D colourTexIn;
|
|
layout(binding = DEPTH_IN_BINDING) uniform sampler2D depthTexIn;
|
|
layout(binding = STENCIL_IN_BINDING) uniform usampler2D stencilTexIn;
|
|
layout(binding = BUFFER_OUT_BINDING, std430) writeonly restrict buffer OutBuffer {
|
|
uvec2[] outBuffer;
|
|
};
|
|
|
|
void main() {
|
|
uint localOutIndex = gl_LocalInvocationID.x + gl_LocalInvocationID.y*WIDTH;
|
|
uint groupOutIndex = (gl_WorkGroupID.x + gl_WorkGroupID.y*3)*(WIDTH*HEIGHT);
|
|
uint globalOutIndex = groupOutIndex+localOutIndex;
|
|
|
|
ivec2 samplePoint = ivec2(gl_GlobalInvocationID.xy);
|
|
|
|
uvec2 outPoint = uvec2(0);
|
|
|
|
uvec4 colour = clamp(uvec4(texelFetch(colourTexIn, samplePoint, 0)*255), uvec4(0), uvec4(255));//TODO: check that this actually gets to the range of 255
|
|
colour <<= uvec4(0,8,16,24);//ABGR format!!!
|
|
outPoint.x = colour.r|colour.g|colour.b|colour.a;
|
|
|
|
float depth = clamp(texelFetch(depthTexIn, samplePoint, 0).r, 0, 1);//Opengl grumble grumble
|
|
uint stencil = texelFetch(stencilTexIn, samplePoint, 0).r;
|
|
uint value = uint(depth*((1<<24)-1))<<8;
|
|
value |= stencil;
|
|
outPoint.y = value;
|
|
|
|
outBuffer[globalOutIndex] = outPoint;
|
|
} |