diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-09-27 13:44:49 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-09-28 01:48:05 +0530 |
| commit | dfa6bcc3db9c65dd0845b952b5f1afbf374a423e (patch) | |
| tree | b4c4ad78fb47474bd0ca064abeae15f470268132 | |
| parent | 5f41d4cded56121af66b18c232c7f557ab803f94 (diff) | |
| download | art-playground-openrndr-dfa6bcc3db9c65dd0845b952b5f1afbf374a423e.tar.gz art-playground-openrndr-dfa6bcc3db9c65dd0845b952b5f1afbf374a423e.zip | |
Coco for coconut trees
| -rw-r--r-- | screenshot/vacation.VacationProgram.png | bin | 2135153 -> 2086120 bytes | |||
| -rw-r--r-- | src/main/kotlin/vacation/VacationProgram.kt | 2 | ||||
| -rw-r--r-- | src/main/resources/shaders/vacation.glsl | 18 |
3 files changed, 13 insertions, 7 deletions
diff --git a/screenshot/vacation.VacationProgram.png b/screenshot/vacation.VacationProgram.png Binary files differindex 528ef09..f96dd49 100644 --- a/screenshot/vacation.VacationProgram.png +++ b/screenshot/vacation.VacationProgram.png diff --git a/src/main/kotlin/vacation/VacationProgram.kt b/src/main/kotlin/vacation/VacationProgram.kt index b4d9d12..0ed8c70 100644 --- a/src/main/kotlin/vacation/VacationProgram.kt +++ b/src/main/kotlin/vacation/VacationProgram.kt @@ -26,6 +26,7 @@ fun main() = application { oliveProgram { val cs by liveComputeShader("vacation") + val antialiasingEnabled = false val outputBuffer = colorBuffer(width, height, type = ColorType.UINT8) @@ -42,6 +43,7 @@ fun main() = application { cs.image("noise_texture", 1, noiseBuffer.imageBinding(0, ImageAccess.READ)) cs.uniform("seconds", seconds) + cs.uniform("enable_antialiasing", antialiasingEnabled || recordingEnabled || screenshotEnabled) cs.image("output_image", 0, outputBuffer.imageBinding(0, ImageAccess.WRITE)) cs.execute(outputBuffer.width, outputBuffer.height, 1) drawer.image(outputBuffer) 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 <utils> 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)); } |
