aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-10-03 23:15:07 +0530
committerAkshay Nair <phenax5@gmail.com>2026-10-04 00:34:30 +0530
commit57ff3d2eb6c5b0d2a3f67296844390376851b13c (patch)
treea518d3b8e8b123bcf990ede56c785fd299c354c1
parentb32d32248e0bfd6e763991b14c9d7bf29063ed29 (diff)
downloadart-playground-openrndr-57ff3d2eb6c5b0d2a3f67296844390376851b13c.tar.gz
art-playground-openrndr-57ff3d2eb6c5b0d2a3f67296844390376851b13c.zip
More eyeball stuff
-rw-r--r--src/main/kotlin/time/TimeProgram.kt45
-rw-r--r--src/main/resources/shaders/time.glsl62
-rw-r--r--video/newton.NewtonProgram.mp4bin38857307 -> 495899 bytes
-rw-r--r--video/time.TimeProgram.mp4bin0 -> 2307449 bytes
4 files changed, 58 insertions, 49 deletions
diff --git a/src/main/kotlin/time/TimeProgram.kt b/src/main/kotlin/time/TimeProgram.kt
index 1c39300..0f5db32 100644
--- a/src/main/kotlin/time/TimeProgram.kt
+++ b/src/main/kotlin/time/TimeProgram.kt
@@ -4,14 +4,14 @@ import java.time.LocalTime
import org.openrndr.application
import org.openrndr.color.*
import org.openrndr.draw.*
-import org.openrndr.extra.noise.filters.SimplexNoise3D
import org.openrndr.math.*
import phenax.utils.*
fun main() = application {
recordDuration(5.seconds())
- if (recordingEnabled || screenshotEnabled) {
+ // TODO: remove hardcode
+ if (captureEnabled) {
configure {
width = 1920
height = 1080
@@ -26,37 +26,28 @@ fun main() = application {
}
oliveProgram {
- val char_size = 200.0
- val font = program.loadFont("data/fonts/default.otf", char_size)
+ val enableAntialiasing = captureEnabled
+ val charSize = 200.0
+ val font = program.loadFont("data/fonts/default.otf", charSize)
val cs by liveComputeShader("time")
- val outputBuffer = colorBuffer(width, height, type = ColorType.UINT8)
-
- val size = Math.max(width, height) * 4
- val noiseBuffer = colorBuffer(size, size, type = ColorType.UINT8)
- val noiseFilter = SimplexNoise3D()
- noiseFilter.scale = Vector3.ONE * 2.4
- noiseFilter.octaves = 8
- noiseFilter.premultipliedAlpha = true
- noiseFilter.seed = Vector3(0.18, 0.01, 0.001)
- noiseFilter.apply(emptyArray(), noiseBuffer)
+ val scale = if (enableAntialiasing) 2 else 1
+ val computeShaderBuffer = colorBuffer(scale * width, scale * height, type = ColorType.UINT8)
val characters = 0..9
val textTarget =
- renderTarget(char_size.toInt() * characters.count(), char_size.toInt()) {
+ renderTarget(charSize.toInt() * characters.count(), charSize.toInt()) {
colorBuffer(type = ColorType.UINT8)
}
extend {
- cs.image("noise_texture", 1, noiseBuffer.imageBinding(0, ImageAccess.READ))
-
drawer.isolatedWithTarget(textTarget) {
drawer.clear(ColorRGBa.TRANSPARENT)
drawer.ortho(textTarget)
drawer.fontMap = font
drawer.fill = ColorRGBa.WHITE
for (char in characters) {
- drawer.text(char.toString(), Vector2(char * char_size.toDouble(), char_size / 2.0 + 5))
+ drawer.text(char.toString(), Vector2(char * charSize.toDouble(), charSize / 2.0 + 5))
}
}
@@ -65,14 +56,20 @@ fun main() = application {
cs.image("text_texture", 2, textBuffer.imageBinding(0, ImageAccess.READ))
val time = LocalTime.now()
- cs.uniform("hours", time.getHour().toFloat())
- cs.uniform("minutes", time.getMinute().toFloat())
- cs.uniform("seconds", time.getSecond().toFloat())
+ if (recordingEnabled) {
+ cs.uniform("hours", 10.0)
+ cs.uniform("minutes", 10.0 + seconds / 60.0)
+ cs.uniform("seconds", time.getSecond().toFloat())
+ } else {
+ cs.uniform("hours", time.getHour().toFloat())
+ cs.uniform("minutes", time.getMinute().toFloat())
+ cs.uniform("seconds", time.getSecond().toFloat())
+ }
cs.uniform("time", seconds)
- cs.image("output_image", 0, outputBuffer.imageBinding(0, ImageAccess.WRITE))
- cs.execute(outputBuffer.width, outputBuffer.height, 1)
- drawer.image(outputBuffer)
+ cs.image("output_image", 0, computeShaderBuffer.imageBinding(0, ImageAccess.WRITE))
+ cs.execute(computeShaderBuffer.width, computeShaderBuffer.height, 1)
+ drawer.image(computeShaderBuffer, 0.0, 0.0, width.toDouble(), height.toDouble())
}
}
}
diff --git a/src/main/resources/shaders/time.glsl b/src/main/resources/shaders/time.glsl
index 2d52ecf..61726ac 100644
--- a/src/main/resources/shaders/time.glsl
+++ b/src/main/resources/shaders/time.glsl
@@ -11,18 +11,12 @@ uniform float hours = 0;
uniform float minutes = 0;
uniform float seconds = 0;
uniform float time = 0;
-layout(rgba8) uniform readonly image2D noise_texture;
layout(rgba8) uniform readonly image2D text_texture;
layout(rgba8) uniform writeonly image2D output_image;
uniform float antialiasing = 0.28;
uniform bool enable_antialiasing = false;
-float sample_noise(in vec2 p) {
- vec4 noise = imageLoad(noise_texture, ivec2((p + 0.5) * imageSize(noise_texture)));
- return noise.x;
-}
-
float digit(in vec2 uv, in int dig, in float size) {
vec2 p = uv * 5000 / size;
float digitSize = imageSize(text_texture).x / 10.;
@@ -32,6 +26,15 @@ float digit(in vec2 uv, in int dig, in float size) {
return s.w;
}
+float veiny_veins(in vec2 p, in vec2 noise) {
+ p.y += 0.32 * (fbm(p * noise) - 0.5);
+ p.x += 0.10 * (fbm(p * noise * 2 + 17.0) - 0.5);
+ p.y = abs(p.y) - 0.22 * p.x;
+ p.y = abs(p.y) - 0.12 * p.x;
+ p.y = abs(p.y) - 0.11 * p.x;
+ return abs(p.y) - (0.018 + fbm(p * 28.0) * 0.006) * (1.0 - 0.7 * p.x);
+}
+
vec3 image(in vec2 uv) {
const vec3 eye_color = srgb(1, 0.99, 0.91);
const vec3 iris_color = srgb(0.15, 0.18, 0.29);
@@ -39,8 +42,8 @@ vec3 image(in vec2 uv) {
const vec3 irispat2_color = srgb(0.21, 0.27, 0.24);
const vec3 pupil_color = srgb(0.08);
const vec3 background_color = srgb(0.15, 0.18, 0.29);
- const vec3 bloodvessel_color = srgb(0.81, 0.40, 0.21);
- const vec3 caruncle_color = srgb(0.81, 0.40, 0.21);
+ const vec3 bloodvessel_color = srgb(0.64, 0.24, 0.12);
+ const vec3 caruncle_color = mix(bloodvessel_color, vec3(0), 0.3);
const vec3 clockdigit_color = mix(bloodvessel_color, vec3(0), 0.3);
const vec3 eyeoutline_color = mix(bloodvessel_color, vec3(0), 0.8);
const vec3 pat1_color = srgb(0.81, 0.40, 0.21);
@@ -50,15 +53,19 @@ vec3 image(in vec2 uv) {
float theta = atan(uv.y, uv.x);
{
- float eye = sdf_circle(uv, 0.41 * (1 - 0.08 * fbm(100 * uv)));
+ float eye = sdf_circle(uv, 0.44 * (1 - 0.08 * fbm(100 * uv)));
vec3 eyeball_color = eye_color;
- float veins = sin((uv.y + 1) * 260 * sin((uv.x + 1) * 0.1) * fbm(uv * 20)) + 0.97;
+ float veins = sin((uv.y + 1) * 260 * sin((uv.x + 1) * 0.1) * fbm(uv * 20)) + 0.96;
eyeball_color = mix(eyeball_color, bloodvessel_color,
mix(0, step(veins, 0), clamp(ease_in_out_quart(fbm(vec3(uv * 10, 28), 8)) - 0.3, 0, 1)));
color = mix(color, eyeball_color, step(eye, 0));
- float caruncle_shine = sdf_circle(uv - vec2(0.44, 0), 0.02);
- caruncle_shine = min(caruncle_shine, sdf_circle(uv + vec2(0.44, 0), 0.02));
- color = mix(color, mix(color, vec3(1), 0.3), 1 - smoothstep(-0.01, 0.01, caruncle_shine));
+
+ float vein = veiny_veins(12 * (-uv + vec2(0.45, 0)), vec2(8., 4.));
+ vein = min(vein, veiny_veins(10 * (uv + vec2(0.45, 0)), vec2(10., 5.)));
+ color = mix(color, caruncle_color, 1.0 - smoothstep(-0.01, 0.01, vein));
+ // float bug = sdf_circle(uv - vec2(0.3, 0), 0.014);
+ // color = mix(color, vec3(0), clamp(step(bug, 0) * (bug - 0.1) * 100, 0, 1));
+
color = mix(color, mix(color, vec3(0), 0.5), smoothstep(0, 0.12, eye + 0.20));
}
@@ -66,12 +73,12 @@ vec3 image(in vec2 uv) {
// minutes
float angle = PI / 2 - minutes * PI / 30;
vec2 offset = 0.148 * vec2(cos(angle), sin(angle));
- float iris_bounds = sdf_circle((uv - offset) * vec2(0.5, 1), 0.012);
- color = mix(color, bloodvessel_color, step(iris_bounds + 0.01 * fbm(uv * 200), 0));
+ float iris_bounds = sdf_circle(uv - offset, 0.012);
+ color = mix(color, bloodvessel_color, step(iris_bounds + 0.012 * fbm(uv * 300), 0));
}
{
- float iris = sdf_circle(uv, 0.144);
+ float iris = sdf_circle(uv, 0.154);
color = mix(color, iris_color, step(iris, 0));
float floral = uv.x * 8 / cos(theta) - sin(15 * theta) * cos(12 * theta);
float irispatangle = 50 * theta + 10.0 * fbm(uv * 100);
@@ -90,14 +97,15 @@ vec3 image(in vec2 uv) {
}
{
- float pupil = sdf_circle(uv, 0.04);
+ float pupil = sdf_circle(uv, 0.05);
vec3 shaded_pupil_color = pupil_color;
shaded_pupil_color = mix(shaded_pupil_color, background_color, clamp(step(pupil, 0) * (pupil + 0.02) * 6, 0, 1));
color = mix(color, shaded_pupil_color, step(pupil, 0));
{
float eyeball = sdf_circle(uv, 0.03);
- color = mix(color, vec3(1), step(eyeball, 0.));
+ vec3 shaded_eyeball_color = mix(eye_color, mix(bloodvessel_color, vec3(0), 0.5), smoothstep(-0.03, -0.006, eyeball));
+ color = mix(color, shaded_eyeball_color, step(eyeball, 0.));
float t = time / 2;
vec2 offset = ease_in_out_quart(vec2(fbm(vec2(t)), fbm(vec2(t / 2)))) - 0.40;
@@ -116,8 +124,8 @@ vec3 image(in vec2 uv) {
float a = mix(0, eye_open_factor, mix(1, blink, should_blink));
float eyelid_size = 60;
float eyelid = a * cos(eyelid_size * eyep.x / 2 * PI) - abs(eyep.y) + a;
- eyelid = max(eyelid, sdf_circle(eyep, 0.03));
- color = mix(color, shaded_pupil_color, step(eyelid, 0.005));
+ eyelid = max(eyelid, sdf_circle(eyep, 0.03)) - 0.005;
+ color = mix(color, shaded_pupil_color, step(eyelid + 0.002, 0));
}
}
@@ -125,7 +133,7 @@ vec3 image(in vec2 uv) {
// TODO: Switch to domain repetition
for (int i = 0; i < 12; i++) {
float angle = PI / 6.;
- float r = 0.17;
+ float r = 0.175;
vec2 digitpos = uv + vec2(0.011, 0.036) - r * vec2(cos(-i * angle + PI / 3), sin(-i * angle + PI / 3));
digitpos *= (1 + 0.8 * fbm(60 * uv));
float digit_size = 1.6;
@@ -139,11 +147,10 @@ vec3 image(in vec2 uv) {
}
}
- float eye_open_factor = 0.092;
- float eyelid_size = 4;
-
{
vec2 eyep = uv;
+ float eye_open_factor = 0.098;
+ float eyelid_size = 3.6;
float blinkduration = 0.6;
float blink_every = 8;
float blinkt = mod(time, blink_every) * 2 / blinkduration;
@@ -151,13 +158,18 @@ vec3 image(in vec2 uv) {
float blink = ease_in_out_quart(mod(blinkt, 1));
blink = mix(1 - blink, blink, clamp(int(blinkt) % 2, 0., 1.));
float a = mix(0, eye_open_factor, mix(1, blink, should_blink));
- float eyelid = a * cos(eyelid_size * eyep.x / 2 * PI) - abs(eyep.y) + a;
+ float eyelid = a * cos(eyelid_size * eyep.x / 2 * PI) - abs(eyep.y) + a - 0.003;
+ float circle = sdf_circle(eyep, 0.50);
+ eyelid = max(eyelid, circle);
vec3 eyelid_color = background_color;
vec3 patterning = mix(pat1_color, pat2_color, pow(sin(eyep.x * 16 + 100 * fbm(vec3(eyep * 10, time / 20), 3)), 2));
float patnoise = smoothstep(-eyelid, 0, 0.028 * fbm(eyep * 100));
eyelid_color = mix(eyelid_color, patterning, 1 - clamp(patnoise, 0, 1));
float shadow = 1 - smoothstep(-0.01, 0.03, eyelid);
color = mix(eyelid_color, mix(color, eyeoutline_color, shadow), 1 - step(eyelid, 0));
+ color = mix(color,
+ mix(background_color, pat2_color, smoothstep(0, 1.5, sin(uv.y * 100 * (1 + 0.01 * fbm(uv * 800))))),
+ 1 - step(circle, 0));
}
return color;
diff --git a/video/newton.NewtonProgram.mp4 b/video/newton.NewtonProgram.mp4
index b7d69e9..c3de790 100644
--- a/video/newton.NewtonProgram.mp4
+++ b/video/newton.NewtonProgram.mp4
Binary files differ
diff --git a/video/time.TimeProgram.mp4 b/video/time.TimeProgram.mp4
new file mode 100644
index 0000000..f554b7e
--- /dev/null
+++ b/video/time.TimeProgram.mp4
Binary files differ