GithubHelp home page GithubHelp logo

adamnemecek / sdfmetaldemo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from novocodev/sdfmetaldemo

0.0 2.0 0.0 1.78 MB

A Signed Distance Bounds renderer using Apple's Metal compute pipeline

License: Apache License 2.0

Objective-C 57.26% Metal 32.28% Smarty 10.46%

sdfmetaldemo's Introduction

SDF Metal Demo

A Signed Distance Function Demo using Apple's Metal compute shaders.

Intro

SDF shaders use mathmatical functions to define object surfaces, they do not use pre-created model assets. SDF shaders trivially support Constructive solid geometry to generate complex objects by combining simple reometric primitives.

SDF Refereneces

IQ's Signed Distance Bounds demo on shadertoy

And the hg_sdf Signed distance library by mercury

Wikipedia's SDF page

Features

This demo includes some interesting features.

  1. Resolution variable rendering

The View controller tracks rendered frames per second and adjusts the view content scale dynamically to maintain a target frame rate. Typically 15FPS across desktop and mobile devices will give acceptable resolution.

  1. Shader JIT compilation

To support dynamic shader content the shader is re-compiled inflight when the structure of a scene changes. The metal Shader compiler aggressively optimises the shader for maximum rendering FPS.

  1. Shader based picking

The same shader is used to pick scene objects in response to touch or mouse events, picking uses exactly the same model state as the last frame rendered, giving perfect picking accuracy.

Demo scenes

When the Demo app is launched the following scenes will be displayed for 10 seconds each

  1. 3D Space Warping

SDF can fold space to generate infinite instances of an object, this is very cheap as it uses the modulus function on the projected light ray to acheive this. The number of visible instances in the scene is only limited by the cameras far clipping plane.

Alt text

  1. Polar Space Warping

A demo of space folding using polar coordinates rather than linear coordinates. A single complex object (cube minus sphere) is repeated 6 times around an origin.

Alt text

  1. Blob

Demonstrates an object with non planar surfaces.

Alt text

  1. Primitives

Demonstrates the range of supported SDF's, this is a port (in progress) of IQ's Signed Distance Bounds demo on shadertoy, this demo will continue to be updated as more functions are supported.

Alt text

Known Issues

When a shader is re-compiled inflight in iOS, previous versions are not garbage collected.

The shader is too slow to support full resolution rendering on device screens, the shader has not been optimised for Metal yet.

License

Apache License Version 2.0, January 2004

sdfmetaldemo's People

Contributors

adamnemecek avatar novocodev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.