diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-04-21 15:04:56 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-04-21 15:04:56 +0300 |
commit | 24639575c32e48a3db46e06be6a3a25cd80e8991 (patch) | |
tree | c8d86d84ce9581a65471d0d4aa6720b4506fe6ae /blog/2021-10-27.md | |
parent | 0b7bc99af62aa53148b7fcede648e5dfb6e2ca22 (diff) | |
download | eug-vs-xyz-24639575c32e48a3db46e06be6a3a25cd80e8991.tar.gz |
refactor: change prject structure
Diffstat (limited to 'blog/2021-10-27.md')
-rw-r--r-- | blog/2021-10-27.md | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/blog/2021-10-27.md b/blog/2021-10-27.md deleted file mode 100644 index 06b9a0d..0000000 --- a/blog/2021-10-27.md +++ /dev/null @@ -1,34 +0,0 @@ -# Ray marching in Rust :rust: ! -I'm currently learning Rust for fun and re-writing my [ascii-renderer](https://github.com/eug-vs/ascii-3d-renderer) from Python :python:. I'm using Ray Marching this time, here's how it looks (if you are on mobile, use desktop version of the site): - -[![asciicast](https://asciinema.org/a/jsDqGeMkRwLeYhVIMqNbaec0M.svg)](https://asciinema.org/a/jsDqGeMkRwLeYhVIMqNbaec0M) - -You can see that Ray Marching allows for some cool stuff like smooth surface blending and proper shadowing. - -# Ray marching -Usually 3d renderers use a triangular mesh to describe objects in a scene. In Python version of `ascii-renderer` I defined each object as a set of points -(i.e object is defined by a function `__contains__` that determines whether the given point is in this object). It allowed me for some cool Ray Tracing stuff, but that was just me toying around. - -Behold - Ray Marching! It's a cool rendering technique where you describe your scene with a *Distance Field* - each point in this field contains a distance from that point to the scene. -Well, actually it's a *Signed Distance Field* - the distance to the object is considered negative *inside* the object, and positive *outside*. - -What's cool about Ray Marching is that since the whole scene is defined with mathematical expression, I can apply any mathematical transformations to it. For example I can make an object wavy -using a `sin`, or make it repeat forever with `%` operator. Also, `SDF` allows for different ways to combine objects - I can find a `union`, `difference`, and `intersection` for free! - - - -## Performance -Currently it's rendering 4 shapes at ~19 FPS, which is pretty bad. That's probably due to my dirty and inefficient code :laughing: - I'm nowhere near a good understanding of Rust :rust: patterns. - -My goal is to render 8 shapes at 24 FPS: - - 24 FPS is OK for a human eye - - 8 distinct shapes is usually enough to create a complex scene (ray marching allows for cool tricks that can multiply amount of your shapes without performance decrease) - - -# Plans - - Cleanup the code and increase performance - - Build an actually usable API - - Use `ncurses` instead of just printing to `STDOUT` - - Create an `ncurses` GUI for building a scene - - Allow importing/exporting scenes in `JSON` - - Do some magic :star: and expose API to the browser using `WebAssembly` |