saving what I've done
This commit is contained in:
@@ -15,6 +15,12 @@ run/main_scene="uid://bf4ohdg0sfl8l"
|
|||||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=1920
|
||||||
|
window/size/viewport_height=1080
|
||||||
|
window/stretch/mode="viewport"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
environment/defaults/default_clear_color=Color(0.0605303, 0.0605304, 0.0605303, 1)
|
environment/defaults/default_clear_color=Color(0.0605303, 0.0605304, 0.0605303, 1)
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|||||||
layout(r32f, binding = 0) uniform restrict readonly image2D current_trail;
|
layout(r32f, binding = 0) uniform restrict readonly image2D current_trail;
|
||||||
layout(r32f, binding = 1) uniform restrict writeonly image2D output_trail;
|
layout(r32f, binding = 1) uniform restrict writeonly image2D output_trail;
|
||||||
layout(binding = 2) restrict buffer AgentBuffer {
|
layout(binding = 2) restrict buffer AgentBuffer {
|
||||||
vec2 positions[1024];
|
vec2 positions[1024 * 1024];
|
||||||
float headings[1024];
|
float headings[1024 * 1024];
|
||||||
} agent_buffer;
|
} agent_buffer;
|
||||||
|
|
||||||
layout(push_constant, std430) uniform Params {
|
layout(push_constant, std430) uniform Params {
|
||||||
@@ -19,13 +19,17 @@ layout(push_constant, std430) uniform Params {
|
|||||||
|
|
||||||
const float SPEED = 1.0;
|
const float SPEED = 1.0;
|
||||||
|
|
||||||
|
float random(vec2 coords) {
|
||||||
|
return fract(sin(dot(coords.xy, vec2(12.9898,78.233))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
vec2 loop_position(vec2 pos) {
|
vec2 loop_position(vec2 pos) {
|
||||||
int width = params.texture_size.x;
|
int width = params.texture_size.x;
|
||||||
int height = params.texture_size.y;
|
int height = params.texture_size.y;
|
||||||
if (pos.x > width) pos.x = mod(pos.x, width);
|
if (pos.x > width) pos.x = mod(pos.x, width);
|
||||||
if (pos.y > height) pos.y = mod(pos.y, height);
|
if (pos.y > height) pos.y = mod(pos.y, height);
|
||||||
if (pos.x < 0) pos.x = width - pos.x;
|
if (pos.x < 0) pos.x = width + pos.x;
|
||||||
if (pos.y < 0) pos.y = height - pos.y;
|
if (pos.y < 0) pos.y = height + pos.y;
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ layout(r32f, set = 1, binding = 0) uniform restrict writeonly image2D output_ima
|
|||||||
|
|
||||||
// PushConstants
|
// PushConstants
|
||||||
layout(push_constant, std430) uniform Params {
|
layout(push_constant, std430) uniform Params {
|
||||||
vec2 texture_size;
|
ivec2 texture_size;
|
||||||
float decay_factor;
|
float decay_factor;
|
||||||
float dissipation_factor;
|
float dissipation_factor;
|
||||||
} params;
|
} params;
|
||||||
@@ -20,11 +20,16 @@ float get_dissipation_from(ivec2 uv) {
|
|||||||
return v * params.dissipation_factor;
|
return v * params.dissipation_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ivec2 loop_position(vec2 pos) {
|
ivec2 loop_position(ivec2 pos) {
|
||||||
// int width = params.texture_size.x;
|
int width = params.texture_size.x;
|
||||||
// int height = params.texture_size.y;
|
int height = params.texture_size.y;
|
||||||
// return ivec2(mod(pos + params.texture_size, params.texture_size));
|
vec2 looped = pos;
|
||||||
// }
|
if (pos.x > width) looped.x = mod(pos.x, width);
|
||||||
|
if (pos.y > height) looped.y = mod(pos.y, height);
|
||||||
|
if (pos.x < 0) looped.x = width - pos.x;
|
||||||
|
if (pos.y < 0) looped.y = height - pos.y;
|
||||||
|
return ivec2(looped);
|
||||||
|
}
|
||||||
|
|
||||||
// The code we want to execute in each invocation
|
// The code we want to execute in each invocation
|
||||||
void main() {
|
void main() {
|
||||||
@@ -33,10 +38,10 @@ void main() {
|
|||||||
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
|
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
|
||||||
|
|
||||||
ivec2 tl = ivec2(0, 0);
|
ivec2 tl = ivec2(0, 0);
|
||||||
ivec2 up_uv = clamp(uv - ivec2(0, 1), tl, size);
|
ivec2 up_uv = loop_position(uv - ivec2(0, 1));
|
||||||
ivec2 down_uv = clamp(uv + ivec2(0, 1), tl, size);
|
ivec2 down_uv = loop_position(uv + ivec2(0, 1));
|
||||||
ivec2 left_uv = clamp(uv - ivec2(1, 0), tl, size);
|
ivec2 left_uv = loop_position(uv - ivec2(1, 0));
|
||||||
ivec2 right_uv = clamp(uv + ivec2(1, 0), tl, size);
|
ivec2 right_uv = loop_position(uv + ivec2(1, 0));
|
||||||
|
|
||||||
// Just in case the texture size is not divisable by 8.
|
// Just in case the texture size is not divisable by 8.
|
||||||
if ((uv.x > size.x) || (uv.y > size.y)) {
|
if ((uv.x > size.x) || (uv.y > size.y)) {
|
||||||
@@ -51,6 +56,10 @@ void main() {
|
|||||||
new_v += get_dissipation_from(right_uv);
|
new_v += get_dissipation_from(right_uv);
|
||||||
new_v += get_dissipation_from(left_uv);
|
new_v += get_dissipation_from(left_uv);
|
||||||
|
|
||||||
|
// Kill very old trails completely
|
||||||
|
// if (new_v < 0.001) {
|
||||||
|
// new_v = 0;
|
||||||
|
// }
|
||||||
|
|
||||||
// new_v = clamp(new_v, 0, 1);
|
// new_v = clamp(new_v, 0, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ extends Node2D
|
|||||||
@onready var mesh := $MeshInstance2D
|
@onready var mesh := $MeshInstance2D
|
||||||
|
|
||||||
## Needs to be changed from the shader as well
|
## Needs to be changed from the shader as well
|
||||||
const AGENTS: int = 1024
|
const AGENTS: int = 1024 * 1024
|
||||||
|
|
||||||
var texture: Texture2DRD
|
var texture: Texture2DRD
|
||||||
var next_texture: int = 0
|
var next_texture: int = 0
|
||||||
|
|||||||
@@ -10,19 +10,19 @@ shader = ExtResource("2_pxe3a")
|
|||||||
shader_parameter/trail_tex = SubResource("Texture2DRD_pxe3a")
|
shader_parameter/trail_tex = SubResource("Texture2DRD_pxe3a")
|
||||||
|
|
||||||
[sub_resource type="QuadMesh" id="QuadMesh_pxe3a"]
|
[sub_resource type="QuadMesh" id="QuadMesh_pxe3a"]
|
||||||
|
size = Vector2(1920, 1080)
|
||||||
|
|
||||||
[node name="SlimeSimulation" type="Node2D"]
|
[node name="SlimeSimulation" type="Node2D"]
|
||||||
script = ExtResource("1_pxe3a")
|
script = ExtResource("1_pxe3a")
|
||||||
texture_size = Vector2i(1152, 648)
|
texture_size = Vector2i(1920, 1080)
|
||||||
decay_factor = 0.75
|
decay_factor = 0.75
|
||||||
dissipation_factor = 0.06
|
dissipation_factor = 0.06
|
||||||
sensor_angle = 8.0
|
sensor_angle = 7.0
|
||||||
sensor_distance = 20.0
|
sensor_distance = 20.0
|
||||||
rng_seed = 8008
|
rng_seed = 8008
|
||||||
|
|
||||||
[node name="MeshInstance2D" type="MeshInstance2D" parent="."]
|
[node name="MeshInstance2D" type="MeshInstance2D" parent="."]
|
||||||
self_modulate = Color(0.581022, 0.701395, 0.890748, 1)
|
self_modulate = Color(0.581022, 0.701395, 0.890748, 1)
|
||||||
material = SubResource("ShaderMaterial_pxe3a")
|
material = SubResource("ShaderMaterial_pxe3a")
|
||||||
position = Vector2(576, 324)
|
position = Vector2(960, 540)
|
||||||
scale = Vector2(1152, 648)
|
|
||||||
mesh = SubResource("QuadMesh_pxe3a")
|
mesh = SubResource("QuadMesh_pxe3a")
|
||||||
|
|||||||
Reference in New Issue
Block a user