Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bwiklund/js1k-love-raytracer
an unbaised raytracer in under 1k of javascript
https://github.com/bwiklund/js1k-love-raytracer
Last synced: 3 days ago
JSON representation
an unbaised raytracer in under 1k of javascript
- Host: GitHub
- URL: https://github.com/bwiklund/js1k-love-raytracer
- Owner: bwiklund
- Created: 2013-10-04T05:25:13.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-12T20:12:05.000Z (about 11 years ago)
- Last Synced: 2024-08-02T05:10:42.824Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.11 MB
- Stars: 67
- Watchers: 7
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
javascript raytracer in 901 bytes
===Made for [js1k 2012 - "love"](http://js1k.com/2012-love/)
See it in action here: https://rawgithub.com/bwiklund/js1k-love-raytracer/master/index.html
![render 3](https://raw.github.com/bwiklund/js1k-love-raytracer/master/samples/shot3.png)
It takes several render passes before it looks any good, and it's quite slow.
But, because it's simulating the behavior of photons (reverse photon mapping), lots of cool features fall out of it:
- Global illumination
- Atmospheric effects (rays have a slight chance to deflect while travelling through air)
- Antialiasing (each photon is slightly randomized within the pixel it originated from)Because it fits in under 1024 bytes of javascript, sacrifices had to be made:
- Photons are steped through space in small increments, then check for collisions. Actual sphere-line intersection and reflection would have taken up way too many bytes!
- No support for glossy materials, for above reason. When a photon finds itself within a sphere / heart shape, it changes it's direction randomly, and continues on it's way. Thus, diffuse surfaces.
- Fairly slow. Code length was the only thing optimized for.It uses uglifyjs for the final minification step. To get dependencies:
`npm install`
If you don't already have grunt installed globally, `npm install -g grunt-cli`
To minify:
`grunt`
Pull requests are very welcome!