diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-10-18 21:46:52 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-10-18 21:46:52 +0530 |
| commit | a2cbcea7144380cfa51d050530251c1dd9bc4d1a (patch) | |
| tree | a1282b2cff0f72c9c1a4a0dde0b9bbd198d2bd58 /src | |
| parent | d3b2736d64988af02b58e934d63fe1c2f0f38d6a (diff) | |
| download | art-playground-openrndr-a2cbcea7144380cfa51d050530251c1dd9bc4d1a.tar.gz art-playground-openrndr-a2cbcea7144380cfa51d050530251c1dd9bc4d1a.zip | |
Kaliedo rotate
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/kotlin/roll_credits/RollCreditsProgram.kt | 14 | ||||
| -rw-r--r-- | src/main/resources/shaders/kaleidos.glsl | 30 | ||||
| -rw-r--r-- | src/main/resources/shaders/roll_credits.glsl | 14 |
3 files changed, 37 insertions, 21 deletions
diff --git a/src/main/kotlin/roll_credits/RollCreditsProgram.kt b/src/main/kotlin/roll_credits/RollCreditsProgram.kt index 472ce85..05327c0 100644 --- a/src/main/kotlin/roll_credits/RollCreditsProgram.kt +++ b/src/main/kotlin/roll_credits/RollCreditsProgram.kt @@ -3,6 +3,7 @@ package roll_credits import org.openrndr.application import org.openrndr.color.* import org.openrndr.draw.* +import org.openrndr.math.IntVector2 import phenax.utils.* fun main() = application { @@ -24,20 +25,21 @@ fun main() = application { oliveProgram { val enableAntialiasing = captureEnabled + val shaderLocalSize = IntVector2(8, 8) + val cs by liveComputeShader("roll_credits") val scale = if (enableAntialiasing) 2 else 1 val outputBuffer = colorBuffer(scale * width, scale * height, type = ColorType.UINT8) - // val camera_manager = CameraManager() - // extend(camera_manager) - extend { - // camera_manager.setUniforms(cs) - cs.uniform("seconds", seconds) cs.image("output_image", 0, outputBuffer.imageBinding(0, ImageAccess.WRITE)) - cs.execute(outputBuffer.width, outputBuffer.height, 1) + cs.execute( + (outputBuffer.width + shaderLocalSize.x - 1) / shaderLocalSize.x, + (outputBuffer.height + shaderLocalSize.y - 1) / shaderLocalSize.y, + 1 + ) drawer.image(outputBuffer, 0.0, 0.0, width.toDouble(), height.toDouble()) } } diff --git a/src/main/resources/shaders/kaleidos.glsl b/src/main/resources/shaders/kaleidos.glsl index b8c499b..689d806 100644 --- a/src/main/resources/shaders/kaleidos.glsl +++ b/src/main/resources/shaders/kaleidos.glsl @@ -96,17 +96,35 @@ void main() { float aspect_ratio = resolution.y / resolution.x; vec2 uv = (gl_GlobalInvocationID.xy - resolution / 2) * vec2(1.0, aspect_ratio) / resolution; - vec3 color = enable_antialiasing ? antialiased_image(uv) : image(uv); - float t = seconds / 3; + vec2 offset = vec2(mod(t * sin(t * 8), 0.02), 0); + + float tilt = 0, scale = 1.0; + float div1 = mod(t * 10, 17); + int s1 = 7, s2 = 15; + bool gshake = int(div1) == s1 || int(div1) == s2; + tilt = mix(tilt, PI / 3, ease_in_out_quart(smoothstep(s1 + 1, s1 + 2, div1))); + scale = mix(scale, 1.3, ease_in_out_quart(smoothstep(s1 + 1, s1 + 1.5, div1))); + scale = mix(scale, 1, ease_in_out_quart(smoothstep(s1 + 1.5, s1 + 2, div1))); + tilt = mix(tilt, PI / 2, step(div1, s2 + 2) * smoothstep(s1 + 1, 30, div1)); + tilt = mix(tilt, 0, ease_in_out_quart(smoothstep(s2 + 1, s2 + 2, div1))); + scale = mix(scale, 1.3, ease_in_out_quart(smoothstep(s2 + 1, s2 + 1.5, div1))); + scale = mix(scale, 1, ease_in_out_quart(smoothstep(s2 + 1.5, s2 + 2, div1))); + + float saturate = smoothstep(s1 + 2, s2, div1); + + uv *= mat2x2(cos(tilt), -sin(tilt), sin(tilt), cos(tilt)); + uv *= scale; + + vec3 color = enable_antialiasing ? antialiased_image(uv) : image(uv); - vec2 offset = vec2(mod(t, 0.01), mod(t, 0.003)); - if (int(t * 5) % 20 == 10) { + if (int(t * 5) % 20 == 5) { color.r = (color.r + image(uv + offset).r / 2 + image(uv - offset).r / 2) / 2.; - color.b = (color.b + image(uv + offset).b + image(uv - offset).b) / 3.; - } else if (int(t * 10) % 17 == 7) { + color.b = (color.b + image(uv + vec2(offset.y, offset.x)).b + image(uv - offset).b) / 3.; + } else if (gshake) { color.g = (color.g + image(uv + offset).g / 2 + image(uv - offset).g / 2) / 2.; } + color.r *= (0.7 + saturate); imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(color, 1)); } diff --git a/src/main/resources/shaders/roll_credits.glsl b/src/main/resources/shaders/roll_credits.glsl index 416a5e6..83c3c34 100644 --- a/src/main/resources/shaders/roll_credits.glsl +++ b/src/main/resources/shaders/roll_credits.glsl @@ -1,5 +1,5 @@ #version 430 -layout(local_size_x = 1, local_size_y = 1) in; +layout(local_size_x = 8, local_size_y = 8) in; #include <sdf> #include <utils> @@ -18,7 +18,6 @@ const float MIN_GAP = 0.001; uniform float seconds = 0; -layout(rgba8) uniform readonly image2D noise_texture; layout(rgba8) uniform writeonly image2D output_image; uniform float antialiasing = 0.28; @@ -40,11 +39,6 @@ vec3 sandyellow = srgb(0.81, 0.66, 0.43); // 0.79,0.60,0.34 vec3 red1 = srgb(0.69, 0.09, 0.06); vec3 gold = srgb(0.89, 0.77, 0.26); -float sample_noise(in vec2 p) { - vec4 noise = imageLoad(noise_texture, ivec2(p * imageSize(noise_texture))); - return noise.x; -} - const int O_DUNE1 = 1; const int O_CAPE = 2; const int O_WALKSTICK = 3; @@ -173,10 +167,12 @@ vec3 get_material_properties(in int obj_id, in vec3 surface_point, in vec2 scree color = srgb(0.78, 0.31, 0.61); ambient = 0.2; } else { - fog = 0; + fog *= (1 - smoothstep(-0.0, 0.2, screen_point.y)); + // fog = 0; + // color = mix(color, vec3(1, 0, 0), (1 - smoothstep(0.0, 0.2, screen_point.y)) * (0.2 + fbm(screen_point * 10))); } - color += fog; + color += fog * (0.2 + fbm(screen_point * 10)); return color; } |
