• Stars
    star
    116
  • Rank 303,894 (Top 6 %)
  • Language
    Rust
  • Created about 5 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Signed Distance Field Utilities

sdfu - Signed Distance Field Utilities

This is a small crate designed to help when working with signed distance fields in the context of computer graphics, especially ray-marching based renderers. Most of what is here is based on Inigo Quilez' excellent articles.

If you're using one of the more popular math libraries in Rust, then just enable the corresponding feature (currently, ultraviolet, nalgebra and vek are supported) and hopefully all the necessary traits are already implemented for you so that you can just start passing in your Vec3s or whatever your lib calls them and you're off to the races! If not, then you can implement the necessary traits in the mathtypes module and still use this library with your own math lib.

Demo

demo image

The image above was rendered with my own path tracing renderer, rayn by leveraging sdfu. The SDF that is rendered above was created with the following code:

use sdfu::SDF;
use ultraviolet::Vec3;

let sdf = sdfu::Sphere::new(0.45)
    .subtract(
        sdfu::Box::new(Vec3::new(0.25, 0.25, 1.5)))
    .union_smooth(
        sdfu::Sphere::new(0.3).translate(Vec3::new(0.3, 0.3, 0.0)),
        0.1)
    .union_smooth(
        sdfu::Sphere::new(0.3).translate(Vec3::new(-0.3, 0.3, 0.0)),
        0.1)
    .subtract(
        sdfu::Box::new(Vec3::new(0.125, 0.125, 1.5)).translate(Vec3::new(-0.3, 0.3, 0.0)))
    .subtract(
        sdfu::Box::new(Vec3::new(0.125, 0.125, 1.5)).translate(Vec3::new(0.3, 0.3, 0.0)))
    .subtract(
        sdfu::Box::new(Vec3::new(1.5, 0.1, 0.1)).translate(Vec3::new(0.0, 0.3, 0.0)))
    .subtract(
        sdfu::Box::new(Vec3::new(0.2, 2.0, 0.2)))
    .translate(Vec3::new(0.0, 0.0, -1.0));

More Repositories

1

ultraviolet

A wide linear algebra crate for games and graphics.
Rust
738
star
2

rayn

A small path tracing renderer written in Rust.
Rust
529
star
3

rendy-pbr

PBR rendering example/experiment with rendy
Rust
224
star
4

i3-vim-nav

Seamlessly navigate i3 windows and vim splits
Go
99
star
5

colstodian

An opinionated, practical color management library for games and graphics.
Rust
34
star
6

nano-rs

An implementation of Nano in Rust using Tokio
Rust
28
star
7

ggez_snake

Rust
25
star
8

cint

A lean, minimal, and stable set of types for color interoperation between crates in Rust.
Rust
19
star
9

CCBullet3D

An easy-to-use wrapper in the Cocos/Objective-C style to integrate the robust, C++ physics library "Bullet" with Cocos3D.
C++
16
star
10

gfx-hal-tutorial

Rust
15
star
11

hot

A mid-level Vulkan abstraction library for the experts and the masses.
Rust
10
star
12

rgba

Reasonably Good Bluetooth Audio - A tiny, inline Bluetooth audio receiver for IEMs.
8
star
13

rmpt2d

A 2d ray-marching path-tracer in Processing
Processing
7
star
14

luluu

A cute and smart arm warmer sleeve ^_^
Rust
6
star
15

CCBullet3D-Sample

Sample use of the CCBullet3D wrapper.
C++
5
star
16

giftrogue

Small roguelike in rust/tcod as part of a gift to someone.
Rust
4
star
17

rayn2d

Rust
4
star
18

dotfiles

My dotfiles managed by yadm
Lua
4
star
19

nanopow-rs-node

A JavaScript wrapper for nanopow-rs to provide fast, safe, fully multithreaded Nano proof-of-work generation in Node.js.
Rust
4
star
20

egui-color-picker-oklab

Rust
3
star
21

simple-rayn

A simple raytracing renderer written in Rust.
Rust
3
star
22

thunderclap

A ray marching experiment in Zig
C
3
star
23

nano-base32

A small, quick, self-contained implementation of the Base32 encoding/decoding scheme used by the cryptocurrency Nano.
JavaScript
3
star
24

linmath.zig

Small, computer-graphics focused linear algebra library for Zig
Zig
3
star
25

fu5ha

2
star
26

vsps

Casing & power supply design for VSPS (Very Simple Phono Stage) by RJM Audio
2
star
27

nanowarpwallet

A Nano brain wallet generator that uses scrypt.
JavaScript
2
star
28

p5.Asteroids

Asteroids implementation in p5.js
JavaScript
1
star
29

TicTacToe-Ruby

A simple, two-player, command-line Tic Tac Toe game.
Ruby
1
star
30

grayolson.me

JavaScript
1
star
31

graphics-experiments

C#
1
star
32

rust-toh

A simple, terminal-interface Towers of Hanoi simulator in Rust
Rust
1
star
33

CheckpointTitler

An OpenPlanet plugin to automatically update your Twitch stream title with your current checkpoint status when playing RPG or trial maps.
AngelScript
1
star