aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/shaders/play_shader.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources/shaders/play_shader.cs')
-rw-r--r--src/main/resources/shaders/play_shader.cs26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/main/resources/shaders/play_shader.cs b/src/main/resources/shaders/play_shader.cs
index c92e8b6..ec19900 100644
--- a/src/main/resources/shaders/play_shader.cs
+++ b/src/main/resources/shaders/play_shader.cs
@@ -90,10 +90,10 @@ vec2 scene(in vec3 p) {
float c1 = sdf_circle(p - vec3(0, 1, 2.4), 0.2);
float c2 = sdf_circle(p - vec3(-0.6, 1, 3), 0.3);
float box = sdf_box(p - vec3(1, 0.5, 3), vec3(0.5, 0.18, 0.2), 0.07);
- float terrain_noise =
- 3.0 * noise(p / 20.0) + noise(p / 4.0) + noise(p * 5) / 30.0;
+ float terrain_noise = 6.0 * noise(p / 20.0) + 0.2 * noise((p + 200.0) / 2.0) +
+ 0.005 * noise((p - 50.0) * 20.0);
float terrain =
- sdf_plane(p + vec3(0.0, terrain_noise, 0.0), vec3(0.0, 1.0, 0.0), 0.0);
+ sdf_plane(p + vec3(0.0, terrain_noise, 0.0), vec3(0., 1., 0.), 0.0);
float light_indicator =
sdf_circle(p - primary_light_position + vec3(0.1, 0.1, -0.4), 0.01);
float dist = min(min(min(min(c1, c2), terrain), box), light_indicator);
@@ -135,17 +135,17 @@ float shadow_scene(in vec3 ray_origin, in vec3 ray_direction,
in float light_intensity) {
float dist = 0.;
float res = 1.;
- float ph = 1e10;
+ float prev_gap = 1e10;
for (int i = 0; i < 50 && dist < MAX_DISTANCE; i++) {
vec3 p = ray_origin + dist * ray_direction;
vec2 obj = scene(p);
float gap = obj.x;
if (obj.y < 0.) // Debug objects dont cast shadows
continue;
- float y = gap * gap / (2.0 * ph);
- float d = sqrt(gap * gap - y * y);
- res = min(res, light_intensity * d / max(0.0, dist - y));
- ph = gap;
+ float y = gap * gap / (10000.0 * prev_gap);
+ float d = sqrt(abs(gap * gap - y * y));
+ res = min(res, light_intensity * d / max(0., dist - y));
+ prev_gap = gap;
dist += gap;
if (res < 0.0001)
@@ -187,15 +187,17 @@ void main() {
}
if (depth < MAX_DISTANCE && oid > 0.) {
- float illumination = shadow_scene(p, light_dir, 24.0);
- float contrast = clamp(dot(normal, light_dir), 0, 1.) * illumination;
+ float contrast = 1.;
+ contrast *= clamp(dot(normal, light_dir), 0, 1.);
+ contrast *= shadow_scene(p, light_dir, 24.0);
float spe =
pow(clamp(dot(normal, hal), 0.0, 1.0), 16.0) * contrast *
(0.04 + 0.96 * pow(clamp(1.0 + dot(hal, uv_direction), 0.0, 1.0), 5.0));
col = col * 1.1 + 0.01;
- col += 12.0 * spe * vec3(1.00, 0.70, 0.5);
+ if (oid != OID_TERRAIN)
+ col += 12.0 * spe * vec3(1.00, 0.70, 0.5);
col *= contrast;
- // col *= max(0.2, exp(-0.00005 * depth * depth * depth));
+ // col *= max(0.1, exp(-0.00005 * depth * depth * depth));
}
imageStore(output_image, ivec2(gl_GlobalInvocationID.xy),