r/GraphicsProgramming • u/draemmli • Nov 17 '17
I wrote a single-threaded CPU volume ray casting engine in vanilla JavaScript. It runs at 60fps on my five year old notebook.
https://draemm.li/various/volumeRendering/cpu/
40
Upvotes
7
u/sarkie Nov 17 '17
9 FPS on my phone
7
u/draemmli Nov 17 '17 edited Nov 17 '17
Source code on GitHub
Edit to amend:
I thought I'd give a bit of an overview over the various optimisations I used to speed things up.
squared[]array, which, for everyi, containsMath.pow(i/256, 2).~~floatis a lot faster thanMath.floor(float)for some reason.requestAnimationFrameinstead ofsetTimeoutorsetInterval. Not only is it smoother and smarter, it's also a lot more performant.2
u/dreamin_in_space Nov 18 '17
Errr, what about this is raycasting?
There's certainly no effects that would demonstrate it.
3
u/Nickd3000 Nov 17 '17
Cool, 30-40 fps on iPhone 6
2
u/mindbleach Nov 18 '17
Niche problem, but in tall aspect ratios it's half-offscreen.
2
u/proyb2 Nov 25 '17
46-60 FPS on iphone 7+, iOS 11.2 beta.
0
u/[deleted] Nov 17 '17
[deleted] — view deleted comment
0
u/[deleted] Nov 17 '17
[deleted] — view deleted comment