Compute-based pixel counting and basic ui
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// based on:
|
||||
// - https://www.youtube.com/watch?v=5CKvGYqagyI
|
||||
// - https://pastebin.com/pbGGjrE8
|
||||
|
||||
#[compute]
|
||||
#version 450
|
||||
|
||||
// Invocations in the (x, y, z) dimension
|
||||
layout(local_size_x = 4, local_size_y = 4, local_size_z = 1) in;
|
||||
|
||||
// A binding to the buffer we create in our script
|
||||
layout(set = 0, binding = 0, std430) buffer MyDataBuffer {
|
||||
int data[];
|
||||
}
|
||||
my_data_buffer;
|
||||
|
||||
layout(set = 0, binding = 1) uniform sampler2D tex;
|
||||
|
||||
void main() {
|
||||
if (texture(tex, vec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y)).r > 0.0) {
|
||||
atomicAdd(my_data_buffer.data[0], 1);
|
||||
}
|
||||
|
||||
if (texture(tex, vec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y)).b > 0.0) {
|
||||
atomicAdd(my_data_buffer.data[1], 1);
|
||||
}
|
||||
|
||||
if (texture(tex, vec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y)).rgb == vec3(1.0, 0, 1.0)) {
|
||||
atomicAdd(my_data_buffer.data[2], 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://daaysa2a1u6b7"
|
||||
path="res://.godot/imported/PixelCountCompute.glsl-abe5c29fd9b584b640dd1cca2cbbc009.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://materials/shader/PixelCountCompute.glsl"
|
||||
dest_files=["res://.godot/imported/PixelCountCompute.glsl-abe5c29fd9b584b640dd1cca2cbbc009.res"]
|
||||
|
||||
[params]
|
||||
|
||||
@@ -16,8 +16,7 @@ void fragment() {
|
||||
|
||||
vec3 desaturatedColor = vec3(dot(currentColor.rgb, colorToLuminance) * 0.4) + 0.1 * currentColor.rgb;
|
||||
|
||||
ALBEDO = desaturatedColor * (1.0 - playerColorationColor.a) + currentColor.rgb * playerColorationColor.a;
|
||||
|
||||
//ALBEDO = desaturatedColor * (1.0 - playerColorationColor.a) + currentColor.rgb * playerColorationColor.a;
|
||||
ALBEDO = desaturatedColor * (1.0 - playerColorationColor.a) + (playerColorationColor.rgb * 0.3 + currentColor.rgb * 0.7) * playerColorationColor.a;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user