-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1620 from heinezen/feature/flowfield_pathing
Flowfield pathing
- Loading branch information
Showing
73 changed files
with
7,372 additions
and
673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
17
assets/test/shaders/pathfinding/demo_0_cost_field.frag.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
15
assets/test/shaders/pathfinding/demo_0_cost_field.vert.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
29
assets/test/shaders/pathfinding/demo_0_flow_field.frag.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
15
assets/test/shaders/pathfinding/demo_0_flow_field.vert.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
16
assets/test/shaders/pathfinding/demo_0_integration_field.frag.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
15
assets/test/shaders/pathfinding/demo_0_integration_field.vert.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.