Add textures
This commit is contained in:
parent
5723b91b32
commit
7bfad8711b
25 changed files with 407 additions and 104 deletions
|
|
@ -6,6 +6,8 @@ uniform float maxMinDistance;
|
|||
uniform float distanceNdcPixelSize;
|
||||
in vec2 position;
|
||||
|
||||
#define WEBGL2_IS_AVAILABLE
|
||||
|
||||
{macroDefinitions}
|
||||
|
||||
{declarations}
|
||||
|
|
|
|||
32
src/graphics/rendering/shaders/random-fs-100.glsl
Normal file
32
src/graphics/rendering/shaders/random-fs-100.glsl
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#version 100
|
||||
|
||||
precision lowp float;
|
||||
|
||||
varying 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;
|
||||
}
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(vec3(terrain(uvCoordinates.x * scale) * amplitude + 0.5), 1.0);
|
||||
}
|
||||
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);
|
||||
}
|
||||
18
src/graphics/rendering/shaders/random-vs-100.glsl
Normal file
18
src/graphics/rendering/shaders/random-vs-100.glsl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#version 100
|
||||
|
||||
precision lowp float;
|
||||
|
||||
attribute vec4 vertexPosition;
|
||||
varying vec2 uvCoordinates;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(vertexPosition.xy, 0.0, 1.0);
|
||||
|
||||
uvCoordinates = (
|
||||
vec3(vertexPosition.xy, 1.0)
|
||||
* mat3(
|
||||
0.5, 0.0, 0.5,
|
||||
0.0, 0.5, 0.5,
|
||||
0.0, 0.0, 1.0
|
||||
)).xy;
|
||||
}
|
||||
18
src/graphics/rendering/shaders/random-vs.glsl
Normal file
18
src/graphics/rendering/shaders/random-vs.glsl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#version 300 es
|
||||
|
||||
precision lowp float;
|
||||
|
||||
in vec4 vertexPosition;
|
||||
out vec2 uvCoordinates;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(vertexPosition.xy, 0.0, 1.0);
|
||||
|
||||
uvCoordinates = (
|
||||
vec3(vertexPosition.xy, 1.0)
|
||||
* mat3(
|
||||
0.5, 0.0, 0.5,
|
||||
0.0, 0.5, 0.5,
|
||||
0.0, 0.0, 1.0
|
||||
)).xy;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue