Skip to content

Commit

Permalink
Merge pull request #1620 from heinezen/feature/flowfield_pathing
Browse files Browse the repository at this point in the history
Flowfield pathing
  • Loading branch information
TheJJ authored Jul 19, 2024
2 parents 1ab1d28 + 12cd944 commit 29df8ac
Show file tree
Hide file tree
Showing 73 changed files with 7,372 additions and 673 deletions.
4 changes: 4 additions & 0 deletions assets/test/shaders/pathfinding/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
install(DIRECTORY "."
DESTINATION "${ASSET_DIR}/test/shaders/pathfinding"
FILES_MATCHING PATTERN "*.glsl"
)
17 changes: 17 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_cost_field.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#version 330

in float v_cost;

out vec4 out_col;

void main()
{
if (v_cost == 255.0) {
out_col = vec4(0.0, 0.0, 0.0, 1.0);
return;
}
float cost = (v_cost / 256) * 2.0;
float red = clamp(cost, 0.0, 1.0);
float green = clamp(2.0 - cost, 0.0, 1.0);
out_col = vec4(red, green, 0.0, 1.0);
}
15 changes: 15 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_cost_field.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 330

layout (location = 0) in vec3 position;
layout (location = 1) in float cost;

uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;

out float v_cost;

void main() {
gl_Position = proj * view * model * vec4(position, 1.0);
v_cost = cost;
}
10 changes: 10 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_display.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#version 330

uniform sampler2D color_texture;

in vec2 v_uv;
out vec4 col;

void main() {
col = texture(color_texture, v_uv);
}
10 changes: 10 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_display.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#version 330

layout(location=0) in vec2 position;
layout(location=1) in vec2 uv;
out vec2 v_uv;

void main() {
gl_Position = vec4(position, 0.0, 1.0);
v_uv = uv;
}
29 changes: 29 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_flow_field.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#version 330

in float v_cost;

out vec4 outcol;

void main() {
int cost = int(v_cost);
if (bool(cost & 0x40)) {
// wavefront blocked
outcol = vec4(0.9, 0.9, 0.9, 1.0);
return;
}

if (bool(cost & 0x20)) {
// line of sight
outcol = vec4(1.0, 1.0, 1.0, 1.0);
return;
}

if (bool(cost & 0x10)) {
// pathable
outcol = vec4(0.7, 0.7, 0.7, 1.0);
return;
}

// not pathable
outcol = vec4(0.0, 0.0, 0.0, 1.0);
}
15 changes: 15 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_flow_field.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 330

layout(location=0) in vec3 position;
layout(location=1) in float cost;

uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;

out float v_cost;

void main() {
gl_Position = proj * view * model * vec4(position, 1.0);
v_cost = cost;
}
8 changes: 8 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_grid.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#version 330

out vec4 out_col;

void main()
{
out_col = vec4(0.0, 0.0, 0.0, 0.3);
}
11 changes: 11 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_grid.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#version 330

layout (location = 0) in vec3 position;

uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;

void main() {
gl_Position = proj * view * model * vec4(position, 1.0);
}
16 changes: 16 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_integration_field.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#version 330

in float v_cost;

out vec4 out_col;

void main()
{
if (v_cost > 512.0) {
out_col = vec4(0.0, 0.0, 0.0, 1.0);
return;
}
float cost = 0.05 * v_cost;
float green = clamp(1.0 - cost, 0.0, 1.0);
out_col = vec4(0.75, green, 0.5, 1.0);
}
15 changes: 15 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_integration_field.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 330

layout (location = 0) in vec3 position;
layout (location = 1) in float cost;

uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;

out float v_cost;

void main() {
gl_Position = proj * view * model * vec4(position, 1.0);
v_cost = cost;
}
9 changes: 9 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_obj.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 330

uniform vec4 color;

out vec4 outcol;

void main() {
outcol = color;
}
7 changes: 7 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_obj.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#version 330

layout(location=0) in vec2 position;

void main() {
gl_Position = vec4(position, 0.0, 1.0);
}
9 changes: 9 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_vector.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 330

uniform vec4 color;

out vec4 outcol;

void main() {
outcol = color;
}
11 changes: 11 additions & 0 deletions assets/test/shaders/pathfinding/demo_0_vector.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#version 330

layout(location=0) in vec3 position;

uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;

void main() {
gl_Position = proj * view * model * vec4(position, 1.0);
}
10 changes: 10 additions & 0 deletions assets/test/shaders/pathfinding/demo_1_display.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#version 330

uniform sampler2D color_texture;

in vec2 v_uv;
out vec4 col;

void main() {
col = texture(color_texture, v_uv);
}
10 changes: 10 additions & 0 deletions assets/test/shaders/pathfinding/demo_1_display.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#version 330

layout(location=0) in vec2 position;
layout(location=1) in vec2 uv;
out vec2 v_uv;

void main() {
gl_Position = vec4(position, 0.0, 1.0);
v_uv = uv;
}
8 changes: 8 additions & 0 deletions assets/test/shaders/pathfinding/demo_1_grid.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#version 330

out vec4 out_col;

void main()
{
out_col = vec4(0.0, 0.0, 0.0, 0.3);
}
11 changes: 11 additions & 0 deletions assets/test/shaders/pathfinding/demo_1_grid.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#version 330

layout (location = 0) in vec2 position;

uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;

void main() {
gl_Position = proj * view * model * vec4(position, 0.0, 1.0);
}
9 changes: 9 additions & 0 deletions assets/test/shaders/pathfinding/demo_1_obj.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 330

uniform vec4 color;

out vec4 outcol;

void main() {
outcol = color;
}
11 changes: 11 additions & 0 deletions assets/test/shaders/pathfinding/demo_1_obj.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#version 330

layout(location=0) in vec2 position;

uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;

void main() {
gl_Position = proj * view * model * vec4(position, 0.0, 1.0);
}
Loading

0 comments on commit 29df8ac

Please sign in to comment.