From dfa6bcc3db9c65dd0845b952b5f1afbf374a423e Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 27 Sep 2026 13:44:49 +0530 Subject: Coco for coconut trees --- src/main/resources/shaders/vacation.glsl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/main/resources/shaders') diff --git a/src/main/resources/shaders/vacation.glsl b/src/main/resources/shaders/vacation.glsl index c1aeb2a..5678158 100644 --- a/src/main/resources/shaders/vacation.glsl +++ b/src/main/resources/shaders/vacation.glsl @@ -6,6 +6,7 @@ layout(local_size_x = 1, local_size_y = 1) in; #include uniform float seconds = 0; +uniform bool enable_antialiasing = false; layout(rgba8) uniform readonly image2D noise_texture; layout(rgba8) uniform writeonly image2D output_image; @@ -35,6 +36,7 @@ vec3 image(vec2 uv) { const vec3 tree_trunk_ring_color = srgb(vec3(0.73, 0.56, 0.46) / 2.9); const vec3 cloud_color = srgb(1, 1, 1); const vec3 dark_cloud_color = srgb(0.34, 0.55, 0.71); + const vec3 leaf_color = srgb(0.0, 0.4, 0.0); vec3 color = sky_color; @@ -121,11 +123,14 @@ vec3 image(vec2 uv) { vec3 shaded_trunk_color = dark_tree_trunk_color; color = mix(color, shaded_trunk_color, step(trunk, 0)); - { - vec2 leafpos = treepos - vec2(0.1, 3.1) * treesize; - float leafs = sdf_box(leafpos - vec2(0), vec2(2.1, 1.6) * treesize, 1.4 * treesize); - color = mix(color, srgb(0.0, 0.4, 0.0), step(leafs, 0)); - } + vec2 leafpos = treepos - vec2(0.1, 2.6) * treesize; + vec2 lp = leafpos * 200.0 + vec2(0, fbm(leafpos * 600) - 0.5); + float leafs = cos(atan((lp.y + 0.25 * lp.x * lp.x) / lp.x) * 20) + 0.4; + float leafbox = sdf_box(leafpos + 0.018 * (fbm(leafpos * 100) - 0.5), (vec2(2.1, 1.6) + 1.0 * fbm(leafpos * 20)) * treesize, 1.4 * treesize); + leafs = max(-leafs, leafbox); + vec3 shaded_leaf_color = mix(leaf_color, mix(leaf_color, sunshine_color, 0.2), clamp((leafpos.x - 0.016) * 500, 0, 1)); + shaded_leaf_color = mix(mix(leaf_color, vec3(0), 0.6), shaded_leaf_color, clamp(((leafpos.y + 0.028) + 2 * leafpos.x) * 500, 0, 1)); + color = mix(color, shaded_leaf_color, step(leafs, 0)); } return color; @@ -147,7 +152,6 @@ void main() { float aspect_ratio = resolution.y / resolution.x; vec2 uv = (gl_GlobalInvocationID.xy - resolution * 0.5) * vec2(1.0, aspect_ratio) / resolution; - // vec3 color = antialiased_image(uv); - vec3 color = image(uv); + vec3 color = enable_antialiasing ? antialiased_image(uv) : image(uv); imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(color, 1)); } -- cgit v1.3.1