Skip to content

Instantly share code, notes, and snippets.

@charlieroberts
Created September 11, 2019 17:58
Show Gist options
  • Save charlieroberts/20e8f601dd616de0435006707b44da3f to your computer and use it in GitHub Desktop.
Save charlieroberts/20e8f601dd616de0435006707b44da3f to your computer and use it in GitHub Desktop.
marching.js with hydra generated textures (local)
// first, download the hydra-synth repo: https://github.com/ojack/hydra-synth
// second, build it with browserify: browserify index.js -o hydra.js --standalone Hydra
// third, place the resulting hydra.js file in the smae directory as marching.js
script = document.createElement('script')
script.src = 'http://localhost:12000/hydra.js'
document.querySelector('head').appendChild( script )
canvas = document.createElement('canvas')
hydra = new Hydra({ canvas })
// thanks to Steven Yi: https://t.co/Ggr9acQnEv?amp=1
hydra.shape(2, 0.3, 0.1)
.color(4,2,1)
.hue(() => (time / 8) % 1)
.repeatY(30)
.mult(osc(5).rotate(-Math.PI/2))
.add(solid(.5))
.modulate(noise())
.mult(osc(10))
.diff(solid(1,1,0))
.invert()
.kaleid(16)
.modulate(noise(1.1))
.add(src(o0).scale(1.25).rotate(Math.PI/2), 0.9)
.out()
a = Texture('canvas', { canvas })
march(
b = Julia().texture( a )
)
.fog( .15, Vec3(0) )
.render(3, true )
.camera( 0,0,3 )
onframe = t => {
b.fold = 1.5 + sin(t) * .5
a.gltexture.setPixels( canvas )
b.rotate( t * 5, 0,1,1 )
}
a.strength = .5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment