Earlier quoted context omitted.
It's an handful amount of lines of code doing a world generation, texture map generation, and ray casting rendering with a few tricks like a simple lightning model that still looks good. All this using nothing more than a frame buffer, so you could port this easily from a C64 to any other computer. This code contains a lot of knowledge VS use of pre-build APIs. If a programmer reads this code and understands how ever…
>This code contains a lot of knowledge VS use of pre-build APIs. It contains a lot of general knowledge about 3D graphics, and absolutely 0 specific knowledge about the environment in which it's running. All he's accomplished by doing it this way is show off that he knows trig and prevent any of it from being hardware accelerated. >If a programmer reads this code and understands how every part works But he never will…
Notch trying jsFiddle
121–130 of 143 posts
Re: Notch trying jsFiddle
#122Earlier quoted context omitted.
>This code contains a lot of knowledge VS use of pre-build APIs. It contains a lot of general knowledge about 3D graphics, and absolutely 0 specific knowledge about the environment in which it's running. All he's accomplished by doing it this way is show off that he knows trig and prevent any of it from being hardware accelerated. >If a programmer reads this code and understands how every part works But he never will…
I hope this simplified version helps. I removed texture mapping and camera rotation, plus simplified a few unusual constructs. https://gist.github.com/4195130
Re: Notch trying jsFiddle
#123Re: Notch trying jsFiddle
#124who the heck is Notch?
Re: Notch trying jsFiddle
#125Earlier quoted context omitted.
This code uses zero canvas / javascript specific functions. It is using basic trigonometric functions and is using canvas only to write RGB pixels. Canvas are much more powerful and high level than that, but this is not a good example as Notch just needed to set pixels.
Reminds me of when I wrote a Game of Life implementation in JavaScript in college using a bunch of tiny absolutely positioned .
And if that sounds crazy, my last implementation of the GoL was built for micro-optimization... my field space was a 1D array that held both the current generation and the swap space for the next generation. So I could see things being made slightly more simple by having the draw space semantically match the logic.
Re: Notch trying jsFiddle
#126Re: Notch trying jsFiddle
#127Earlier quoted context omitted.
This code uses zero canvas / javascript specific functions. It is using basic trigonometric functions and is using canvas only to write RGB pixels. Canvas are much more powerful and high level than that, but this is not a good example as Notch just needed to set pixels.
Reminds me of when I wrote a Game of Life implementation in JavaScript in college using a bunch of tiny absolutely positioned .
Re: Notch trying jsFiddle
#128Earlier quoted context omitted.
Nice :) Shows you how fast ARM is progressing...
But only 4-5 fps on my iPad 3. Hmmmph, thought that'd be faster.
Re: Notch trying jsFiddle
#129Earlier quoted context omitted.
This code uses zero canvas / javascript specific functions. It is using basic trigonometric functions and is using canvas only to write RGB pixels. Canvas are much more powerful and high level than that, but this is not a good example as Notch just needed to set pixels.
Having watched Notch write Prelude of the Chambered (which I then ported to JRuby) it seems he really loves this direct pixel manipulation style - as do I! The sad part, though, is it doesn't particularly scale well with canvas (yet) and using sprites, shape primitives, or even WebGL is way to get full speed at a regular resolution. (Imagine a 640x480 pixel field of randomized colors, you can get hundreds of FPS for…
> The sad part, though, is it doesn't particularly scale well with canvas (yet) and using sprites, shape primitives, or even WebGL is way to get full speed at a regular resolution.
It doesn't just not scale well with canvas, it doesn't scale well with modern hardware. A single call to draw a textured polygon of any size is ~as expensive as the call drawing a single pixel. A call to draw a stored model with with thousands of polygons is ~as expensive as the call to draw a single polygon.
When doing pixel at a time drawing like that you are completely ignoring the specialized hardware found in the GPU, which is vastly more efficient at pushing pixels than the CPU, even in the lowest-end Intel integrated GPUs of the newest generation.
If you want to do serious graphics, you really should just get used to OpenGL/DirectX.
Re: Notch trying jsFiddle
#130I've recorded a screencast that digs into how the programmatic texture generation works in this code: https://www.youtube.com/watch?v=WaZvDCmlERc