Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AACS Ray Marching

AACS Ray Marching

Filippo Vitale

February 07, 2018
Tweet

More Decks by Filippo Vitale

Other Decks in Programming

Transcript

  1. public class AnimationLoop extends AnimationTimer { public AnimationLoop(Canvas c, long

    t0, double n, double u, double m) {...} private static double computeIntensity(final double x, final double y, final double s, final double t) { double intensity = 1; for (double d = intensity * 4, df = 1; .025 < df * intensity; intensity -= .025) { double X = d * x / s - d / 2; double Y = d * y / s - d / 2; double Z = d / 2 - 9; df = ???; d += df; } return intensity; } @Override public void handle(long currentNanoTime) { double t = (currentNanoTime - t0) / (500 * oneMillisecondInNanoTime); gc.clearRect(0, 0, w, h); // clear the Canvas for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { double i = computeIntensity(x, y, n, t); gc.setGlobalAlpha(i); gc.fillOval(x * u, y * u, i * m * 1.4, i * m * 1.4); } } } }
  2. Resources - SDF shapes - Sphere Tracing - Ray Marching

    - ShaderToy Shapes - ShaderToy 2d Vine - ShaderToy 3d Vine