good progress, but no other compute pass yet
This commit is contained in:
36
shaders/agents_cs.glsl
Normal file
36
shaders/agents_cs.glsl
Normal file
@@ -0,0 +1,36 @@
|
||||
#[compute]
|
||||
#version 450
|
||||
|
||||
// Invocations in the (x, y, z) dimension
|
||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
layout(r32f, set = 0, binding = 0) uniform restrict readonly image2D current_trail;
|
||||
layout(r32f, set = 1, binding = 0) uniform restrict writeonly image2D output_trail;
|
||||
layout(set = 2, binding = 1) restrict buffer AgentBuffer {
|
||||
vec2 positions[];
|
||||
} agent_buffer;
|
||||
|
||||
layout(push_constant, std430) uniform Params {
|
||||
vec2 texture_size;
|
||||
} params;
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
ivec2 size = ivec2(params.texture_size.x - 1, params.texture_size.y - 1);
|
||||
vec2 position = agent_buffer.positions[gl_GlobalInvocationID.x];
|
||||
|
||||
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
|
||||
|
||||
ivec2 tl = ivec2(0, 0);
|
||||
float current_v = imageLoad(current_trail, clamp(uv - ivec2(0, 1), tl, size)).r;
|
||||
float up_v = imageLoad(current_trail, clamp(uv - ivec2(0, 1), tl, size)).r;
|
||||
float down_v = imageLoad(current_trail, clamp(uv + ivec2(0, 1), tl, size)).r;
|
||||
float left_v = imageLoad(current_trail, clamp(uv - ivec2(1, 0), tl, size)).r;
|
||||
float right_v = imageLoad(current_trail, clamp(uv + ivec2(1, 0), tl, size)).r;
|
||||
|
||||
float new_v = current_v + 0.05;
|
||||
|
||||
vec4 result = vec4(new_v, new_v, new_v, 1.0);
|
||||
imageStore(output_trail, uv, result);
|
||||
}
|
||||
14
shaders/agents_cs.glsl.import
Normal file
14
shaders/agents_cs.glsl.import
Normal file
@@ -0,0 +1,14 @@
|
||||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://u3grg3r2bgi1"
|
||||
path="res://.godot/imported/agents_cs.glsl-b2836a7ba58df020a54fe9498ba98f67.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://shaders/agents_cs.glsl"
|
||||
dest_files=["res://.godot/imported/agents_cs.glsl-b2836a7ba58df020a54fe9498ba98f67.res"]
|
||||
|
||||
[params]
|
||||
|
||||
@@ -6,14 +6,12 @@ layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
// Our textures.
|
||||
layout(r32f, set = 0, binding = 0) uniform restrict readonly image2D current_image;
|
||||
layout(r32f, set = 1, binding = 0) uniform restrict readonly image2D previous_image;
|
||||
layout(r32f, set = 2, binding = 0) uniform restrict writeonly image2D output_image;
|
||||
layout(r32f, set = 1, binding = 0) uniform restrict writeonly image2D output_image;
|
||||
|
||||
// PushConstants
|
||||
layout(push_constant, std430) uniform Params {
|
||||
vec2 texture_size;
|
||||
float decay_factor;
|
||||
float dunno_lol;
|
||||
} params;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user