tested proper blurring of the trail
This commit is contained in:
@@ -17,7 +17,8 @@ layout(push_constant, std430) uniform Params {
|
||||
|
||||
float get_dissipation_from(ivec2 uv) {
|
||||
float v = imageLoad(current_image, uv).r;
|
||||
return v * params.dissipation_factor;
|
||||
// return v * params.dissipation_factor;
|
||||
return v;
|
||||
}
|
||||
|
||||
ivec2 loop_position(ivec2 pos) {
|
||||
@@ -27,27 +28,20 @@ ivec2 loop_position(ivec2 pos) {
|
||||
// The code we want to execute in each invocation
|
||||
void main() {
|
||||
|
||||
ivec2 size = ivec2(params.texture_size.x - 1, params.texture_size.y - 1);
|
||||
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
|
||||
|
||||
ivec2 tl = ivec2(0, 0);
|
||||
ivec2 up_uv = loop_position(uv - ivec2(0, 1));
|
||||
ivec2 down_uv = loop_position(uv + ivec2(0, 1));
|
||||
ivec2 left_uv = loop_position(uv - ivec2(1, 0));
|
||||
ivec2 right_uv = loop_position(uv + ivec2(1, 0));
|
||||
|
||||
// Just in case the texture size is not divisable by 8.
|
||||
if ((uv.x > size.x) || (uv.y > size.y)) {
|
||||
return;
|
||||
float current_sum = 0.0;
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
for (int j = -1; j <= 1; j++) {
|
||||
ivec2 kuv = loop_position(uv + ivec2(i,j));
|
||||
current_sum += get_dissipation_from(kuv);
|
||||
}
|
||||
}
|
||||
// ivec2 up_uv = loop_position(uv - ivec2(0, 1));
|
||||
// ivec2 down_uv = loop_position(uv + ivec2(0, 1));
|
||||
// ivec2 left_uv = loop_position(uv - ivec2(1, 0));
|
||||
// ivec2 right_uv = loop_position(uv + ivec2(1, 0));
|
||||
|
||||
float current_v = imageLoad(current_image, uv).r;
|
||||
|
||||
float new_v = current_v * params.decay_factor;
|
||||
new_v += get_dissipation_from(up_uv);
|
||||
new_v += get_dissipation_from(down_uv);
|
||||
new_v += get_dissipation_from(right_uv);
|
||||
new_v += get_dissipation_from(left_uv);
|
||||
|
||||
// Kill very old trails completely
|
||||
// if (new_v < 0.001) {
|
||||
@@ -56,7 +50,11 @@ void main() {
|
||||
|
||||
// new_v = clamp(new_v, 0, 1);
|
||||
|
||||
vec4 result = vec4(new_v, new_v, new_v, 1.0);
|
||||
// This is good when not using trail for showind as is.
|
||||
// https://github.com/Bleuje/physarum-36p/blob/main/bin/data/shaders/computeshader_deposit.glsl
|
||||
current_sum = current_sum / pow(3.0, 2.0);
|
||||
|
||||
vec4 result = vec4(vec3(current_sum), 1.0);
|
||||
imageStore(output_image, uv, result);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user