Amélioration de l'ambiance de Aqua
This commit is contained in:
49
common/vfx/materials/shaders/caustics.gdshader
Normal file
49
common/vfx/materials/shaders/caustics.gdshader
Normal file
@@ -0,0 +1,49 @@
|
||||
shader_type spatial;
|
||||
|
||||
uniform float scale : hint_range(0.1, 2.0, 0.1) = 1.0;
|
||||
uniform float speed : hint_range(0.1, 2.0, 0.1) = 0.2;
|
||||
uniform float strenght : hint_range(10., 500., 10.) = 100.;
|
||||
uniform sampler2D color_ramp;
|
||||
varying vec3 world_position;
|
||||
|
||||
vec2 random(vec2 uv) {
|
||||
return vec2(fract(sin(dot(uv.xy,
|
||||
vec2(12.9898,78.233))) * 43758.5453123));
|
||||
}
|
||||
|
||||
float worley(vec2 uv, float columns, float rows) {
|
||||
|
||||
vec2 index_uv = floor(vec2(uv.x * columns, uv.y * rows));
|
||||
vec2 fract_uv = fract(vec2(uv.x * columns, uv.y * rows));
|
||||
|
||||
float minimum_dist = 1.0;
|
||||
|
||||
for (int y= -1; y <= 1; y++) {
|
||||
for (int x= -1; x <= 1; x++) {
|
||||
vec2 neighbor = vec2(float(x),float(y));
|
||||
vec2 point = random(index_uv + neighbor);
|
||||
|
||||
vec2 diff = neighbor + point - fract_uv;
|
||||
float dist = length(diff);
|
||||
minimum_dist = min(minimum_dist, dist);
|
||||
}
|
||||
}
|
||||
|
||||
return minimum_dist;
|
||||
}
|
||||
|
||||
void vertex(){
|
||||
world_position = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
||||
}
|
||||
|
||||
void fragment(){
|
||||
float worley_value = worley(world_position.xz * scale + TIME * speed, 3.0, 3.0);
|
||||
float worley_value_2 = worley(world_position.xz * scale * 2. - TIME * speed, 3.0, 3.0);
|
||||
|
||||
float color = texture(color_ramp, vec2(worley_value*worley_value_2)).r;
|
||||
color = min(0.99, color);
|
||||
color = log(0.999)/log(color);
|
||||
color *= strenght;
|
||||
ALPHA = color;
|
||||
EMISSION = vec3(color);
|
||||
}
|
||||
1
common/vfx/materials/shaders/caustics.gdshader.uid
Normal file
1
common/vfx/materials/shaders/caustics.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://740mg4jlufyc
|
||||
Reference in New Issue
Block a user