All Projects → schmelczer → sdf-2d

schmelczer / sdf-2d

Licence: other
A graphics library to enable the real-time rendering of 2D signed distance fields on the web.

Programming Languages

typescript
32286 projects
GLSL
2045 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to sdf-2d

Retrace.gl
Create, ray trace & export programatically defined Signed Distance Function CSG geometries with an API suited for generative art - in your browser! 🎉
Stars: ✭ 149 (+112.86%)
Mutual labels:  glsl, raytracing, webgl2
Nabla
OpenGL/OpenGL ES/Vulkan/CUDA/OptiX Modular Rendering Framework for PC/Linux/Android
Stars: ✭ 235 (+235.71%)
Mutual labels:  glsl, raytracing, graphics-library
Rayray
A tiny GPU raytracer, using Zig and WebGPU
Stars: ✭ 59 (-15.71%)
Mutual labels:  glsl, raytracing
Shady
CLI tool to render GLSL shaders
Stars: ✭ 79 (+12.86%)
Mutual labels:  glsl, raytracing
Webassembly Raytracer
a performance comparison of a simple raytracer in JavaScript, asm.js, WebAssembly, and GLSL
Stars: ✭ 102 (+45.71%)
Mutual labels:  glsl, raytracing
Glchaos.p
3D GPUs Strange Attractors and Hypercomplex Fractals explorer - up to 256 Million particles in RealTime
Stars: ✭ 590 (+742.86%)
Mutual labels:  glsl, webgl2
Nau
Nau - OpenGL + Optix 3D Engine
Stars: ✭ 18 (-74.29%)
Mutual labels:  glsl, raytracing
Medium
Progressive WebGL toolkit for art.
Stars: ✭ 90 (+28.57%)
Mutual labels:  glsl, webgl2
ElkEngine
Simple graphics engine used as submodule in many of my projects
Stars: ✭ 54 (-22.86%)
Mutual labels:  glsl, graphics-library
Twigl
twigl.app is an online editor for One tweet shader, with gif generator and sound shader, and broadcast live coding.
Stars: ✭ 145 (+107.14%)
Mutual labels:  glsl, webgl2
Godot 3 2d Crt Shader
A 2D shader for Godot 3 simulating a CRT
Stars: ✭ 183 (+161.43%)
Mutual labels:  glsl, 2d
Webclgl
GPGPU Javascript library 🐸
Stars: ✭ 313 (+347.14%)
Mutual labels:  glsl, graphics-library
Gl Water2d
2D liquid simulation in WebGL
Stars: ✭ 260 (+271.43%)
Mutual labels:  glsl, 2d
Curtainsjs
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.
Stars: ✭ 1,039 (+1384.29%)
Mutual labels:  glsl, webgl2
OpenTK-PathTracer
C# OpenGL Path Tracer, Real-Time GPU accelerated
Stars: ✭ 22 (-68.57%)
Mutual labels:  glsl, raytracing
Threejs Starter
Stars: ✭ 89 (+27.14%)
Mutual labels:  glsl, webgl2
glNoise
A collection of GLSL noise functions for use with WebGL with an easy to use API.
Stars: ✭ 185 (+164.29%)
Mutual labels:  glsl, webgl2
glsl-rotate
GLSL rotation functions with matrices: 2D and 3D (with X/Y/Z convenience functions).
Stars: ✭ 54 (-22.86%)
Mutual labels:  glsl, 2d
Sketch
Explorations on cross-hatching, engraving, and similar non-photorealistic rendering.
Stars: ✭ 136 (+94.29%)
Mutual labels:  glsl, webgl2
NobleRT
A Minecraft shaderpack that enhances one's experience with the help of good-looking graphics and light simulations.
Stars: ✭ 76 (+8.57%)
Mutual labels:  glsl, raytracing

SDF-2D logo SDF-2D library

A graphics library to enable the real-time rendering of 2D signed distance fields on the web.

screenshot of a bumpy tunnel

screenshot of merging circles

Links

Features

  • Works with both WebGL and WebGL2

    The former is mostly required for supporting iPhones.

  • Performant even on low-end mobile devices

    Try it out yourself!

  • Has a number of built-in shapes and lights
  • Easily extensible with new shapes
  • Antialiasing is implemented
  • Has built-in quality autoscaling
  • Requires no boilerplate code
    • Automatic detection of WebGL and its extensions is provided
    • Parallel, non-blocking shader compiling
    • Context lost is handled with automatic restoration
    • Can be used without thinking of the GPU (although for stunning results it, should be kept in mind)

four screenshots from mobiles

Four separate screenshots taken on a mobile device

Install

npm install sdf-2d --save-dev

Use

import { compile, CircleFactory, hsl, CircleLight } from 'sdf-2d';

const main = async () => {
  const Circle = CircleFactory(hsl(30, 66, 50));
  const canvas = document.querySelector('canvas');

  const renderer = await compile(canvas, [Circle.descriptor, CircleLight.descriptor]);

  renderer.addDrawable(new Circle([200, 200], 50));
  renderer.addDrawable(new CircleLight([500, 300], [1, 0.5, 0], 0.5));
  renderer.renderDrawables();
};

main();

A commented version of the above code can be found in this repo.

Examples

For further examples, please visit the following repositories:

Documentation

For more technical details, please consult the documentation available in the repository and at schmelczerandras.github.io/sdf-2d/.

Plans

  • Automatic tile multiplier scaling
  • Non-uniform tile sizes based on scene density
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].