Add textures
This commit is contained in:
parent
5723b91b32
commit
7bfad8711b
25 changed files with 407 additions and 104 deletions
34
src/graphics/rendering/shaders/random-fs.glsl
Normal file
34
src/graphics/rendering/shaders/random-fs.glsl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#version 300 es
|
||||
|
||||
precision lowp float;
|
||||
|
||||
in vec2 uvCoordinates;
|
||||
|
||||
uniform float scale;
|
||||
uniform float amplitude;
|
||||
|
||||
float noise(float x){
|
||||
return fract(sin(x) * 43758.5453123) / 100.0;
|
||||
}
|
||||
|
||||
float terrain(float x) {
|
||||
float result = 0.0;
|
||||
|
||||
float frequency = 0.01;
|
||||
float amplitude = 1.0;
|
||||
|
||||
const float pi = 3.141592654;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
result += sin(2.0 * pi * x * frequency - 2.0 * pi * noise(float(i) * 200.0)) * amplitude;
|
||||
frequency *= 1.5;
|
||||
amplitude /= 1.2;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
out vec4 fragmentColor;
|
||||
|
||||
void main() {
|
||||
fragmentColor = vec4(vec3(terrain(uvCoordinates.x * scale) * amplitude + 0.5), 1.0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue