This commit is contained in:
2024-07-29 16:19:22 +03:00
parent ba6e615159
commit ba77e88342
4 changed files with 171 additions and 165 deletions

View File

@ -1,3 +1,9 @@
/* uses some snippets from:
* "Seascape" by Alexander Alekseev aka TDM - 2014
* License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
* Contact: tdmaav@gmail.com
*/
precision mediump float;
uniform vec2 u_resolution;
uniform float u_time;
@ -15,33 +21,27 @@ float smax( float a, float b, float k )
return max(a, b) + h*h*0.25/k;
}
float hash(vec2 p)
{
p = 50.*fract( p*0.3183099);
float hash(vec2 p, int algo)
{
if (algo == 1) {
float h = dot(p,vec2(127.1,311.7));
return fract(sin(h)*43758.5453123);
}
p = 50.*fract( p*0.3183099);
return fract( p.x*p.y*(p.x+p.y) );
}
float noise(vec2 p, float scale )
float noise(vec2 p, float scale, int a)
{
vec2 i = floor( p ),
f = fract( p ),
u = f*f*(3.-2.*f);
return -scale+scale*mix( mix( hash( i + vec2(0.) ),
hash( i + vec2(1.0,0.0) ), u.x),
mix( hash( i + vec2(0.0,1.0) ),
hash( i + vec2(1.) ), u.x), u.y);
}
float hash2( vec2 p ) {
float h = dot(p,vec2(127.1,311.7));
return fract(sin(h)*43758.5453123);
}
float noise2( in vec2 p ) {
vec2 i = floor( p ), f = fract( p ), u = f*f*(3.0-2.0*f);
return -1.0+2.0*mix( mix( hash2( i + vec2(0.) ),
hash2( i + vec2(1.0,0.0) ), u.x),
mix( hash2( i + vec2(0.0,1.0) ),
hash2( i + vec2(1.) ), u.x), u.y);
float sc = scale;
if (a == 1) sc = 2.;
return -scale+sc*mix( mix( hash( i + vec2(0.), a),
hash( i + vec2(1.0,0.0), a ), u.x),
mix( hash( i + vec2(0.0,1.0), a),
hash( i + vec2(1.), a), u.x), u.y);
}
/////////////////
@ -140,7 +140,7 @@ float prismAnim(vec2 i) {
// SCENE //
//////////////
float sea_octave(vec2 uv, float choppy) {
uv += noise2(uv);
uv += noise(uv, 1., 1);
vec2 wv = 1.0-abs(sin(uv));
vec2 swv = abs(cos(uv));
wv = mix(wv,swv,wv);
@ -220,7 +220,7 @@ vec2 map(vec3 p, int displace)
if (d==d2) mat = 2.0;
// sand
d2 = (p.y + 4.25) + noise((vec2((p.x*.04),(p.z-40.)*.04))+100., 15.)*1.5;
d2 = (p.y + 4.25) + noise((vec2((p.x*.04),(p.z-40.)*.04))+100., 15., 0)*1.5;
d = min(d,d2);
if (d==d2) mat = 3.0;
@ -408,7 +408,7 @@ vec3 sceneGate(vec2 uv)
else if(mat==2.)
col *= vec3(.3, .1, .0); // - 0.2*noise((vec2(100.*p.x+300.,75.*p.z+150.0)), -2.2) * noise((vec2(15.*p.x+2.0,3.*p.z+2.)), -1.) + noise((vec2(15.*p.x+2.4,3.*p.z+2.)), -0.25);
else if(mat==3.)
col *= vec3(.8, .8, .5) + noise(p.xz*500.+100., .3); // + noise(p.xz*1000.+5000., 0.1) + noise(p.xz*1000.+5000., 0.1);
col *= vec3(.8, .8, .5) + noise(p.xz*500.+100., .3,0); // + noise(p.xz*1000.+5000., 0.1) + noise(p.xz*1000.+5000., 0.1);
else if(mat==4.)
col *= vec3(.1);
else if(mat ==5.)