-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DynamicTerrain] The tessellated terrain now has colors
- They are computed the same way the static terrain's are, but with a compute shader that's executed after the noise one
- Loading branch information
Showing
6 changed files
with
96 additions
and
40 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
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
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
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
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,22 @@ | ||
layout(local_size_x = 1, local_size_y = 1, local_size_x = 1) in; | ||
|
||
const vec3 waterColor = vec3(0.0, 0.0, 1.0); | ||
const vec3 grassColor = vec3(0.24, 0.49, 0.0); | ||
const vec3 groundColor = vec3(0.62, 0.43, 0.37); | ||
const vec3 rockColor = vec3(0.5, 0.5, 0.5); | ||
const vec3 snowColor = vec3(1.0, 1.0, 1.0); | ||
|
||
layout(r16f, binding = 0) uniform readonly image2D uniHeightmap; | ||
layout(rgba8, binding = 1) uniform writeonly image2D uniColorMap; | ||
|
||
void main() { | ||
ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); | ||
|
||
float height = imageLoad(uniHeightmap, pixelCoords).r; | ||
vec3 color = (height < 0.33 ? mix(waterColor, grassColor, height * 3.0) | ||
: (height < 0.5 ? mix(grassColor, groundColor, (height - 0.33) * 5.75) | ||
: (height < 0.66 ? mix(groundColor, rockColor, (height - 0.5) * 6.0) | ||
: mix(rockColor, snowColor, (height - 0.66) * 3.0)))); | ||
|
||
imageStore(uniColorMap, pixelCoords, vec4(color, 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