FredKSchott / manyworlds

A visual study of signed distanced functions and noise fields in WebGL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

a looping gif of the animations rendered by manyworlds

manyworlds 🌌✨πŸͺπŸ‘½

A visual study of signed distanced functions and noise fields in WebGL.

Signed Distance Functions are fun. With them, you can compute the distance to an object in a metric space, provided you have a function to describe that object's volume. When used alongside Ray Marching techniques, you can render views of these 3D objects as seen through a 2D plane. This project is an experiment in combining this method with noise fields, through which these views can be manipulated and distorted.

See experiment: manyworlds.neef.co

(The site is quite GPU intensive. Try running it in a smaller window if the framerate is low)

Project setup

This project is a simple single-page app built with TypeScript & Preact, and bundled with Snowpack & esbuild. The WebGL scene is rendered by a custom renderer component that uses React/Preact hooks to create and manage a WebGL context. The renderer can accept shader uniforms, a fragment shader as a glsl string, and an onFrame callback used to update the uniforms and other attributes of the sketch. If you pass it all of these things you've made yourself a WebGL scene! The interfaces for the renderer and callback props can be found in the component's file.

Tools

  • Preact β€” Teeny React-like library
  • Snowpack β€” ESM-first build tool
  • esbuild β€” Blazing fast bundler
  • glslify β€” Enables importing inside glsl

Getting Started

To get started on your device, fork this repo and run npm install && npm run start to set up the (lightning fast, thanks to Snowpack) dev server.

Fast refresh dev server workaround

As a workaround for an issue that causes builds to fail, I've disabled Fast Refresh (via prefresh) by commenting out the appropriate lines in snowpack.config.js and .babelrc.

Resources

The resources that I've found valuable regarding shaders, Ray Marching, SDFs are:

License

This repo is GNU Licensed.

About

A visual study of signed distanced functions and noise fields in WebGL

License:GNU General Public License v3.0


Languages

Language:TypeScript 83.5%Language:GLSL 8.2%Language:CSS 3.6%Language:HTML 3.3%Language:JavaScript 1.5%