As someone with no experience in computer graphics it's always insane to see demos like this. Especially using just around 250 lines of javascript. Really impressive. Also on the topic, the demo scene stuff is mind blowing, too. [0] [0]: http://awards.scene.org/awards.php
Me three. It's covered the 're-read in 6 months time' criteria. I must confess I do change from reading to scanning as soon as the heavy math kicks in.
A first-person engine in 265 lines of JS
81–90 of 99 posts
Re: A first-person engine in 265 lines of JS
#82It is very interesting to me that you need to multiply the distance-to-wall by the cosine of the angle to transform the image from fisheye to normal. It makes me wonder, why is it that our eye in real life sees straight lines as straight, the way this demo renders the image? To illustrate the question, see https://en.wikipedia.org/wiki/File:Panotools5618.jpg – why do we see the world as in the bottom image instead of…
> It makes me wonder, why is it that our eye in real life sees straight lines as straight, the way this demo renders the image? Your eye doesn't see it as straight, your brain does. Your eye doesn't actually gather a single coherent image, in fact. It's constantly moving[1], bringing the higher-precision fovea at the center of your retina to bear on interesting parts of the scene. Your brain then accumulates all of t…
There were situations in traffic when I was driving a car and simply did not see cyclists or pedestrians coming. At the time I was aware that one of my eyes were obstructed by the rear-view mirror on the windshield, but that did not explain why I did not see them coming with the other eye.
I wonder why are people not alerted about this when taking the test for the drivers license.
Re: A first-person engine in 265 lines of JS
#83Re: A first-person engine in 265 lines of JS
#84This demo unfortunately uses an incorrect perspective transformation. There is no reason to go to trig if you represent the camera plane as a vector, and step along it one pixel at a time, and allowing the wall height to vary linearly in the distance to the camera vector (taking lines to lines). In addition to being correct[1], it has the added benefit of being faster if implemented well. My (admittedly n00bish and e…
I'm not sure I'm convinced, as finding the cosine does in fact find the linear distance from the camera plane to the intersection. This is, as far as I have seen, the standard implementation, eg: http://www.permadi.com/tutorial/raycast/rayc8.html#FINDING DISTANCE TO WALLS However, I would love to see your proposed solution demonstrated. Would you care to fork the raycaster and compute the results with an alternative…
Re: A first-person engine in 265 lines of JS
#85As someone with no experience in computer graphics it's always insane to see demos like this. Especially using just around 250 lines of javascript. Really impressive. Also on the topic, the demo scene stuff is mind blowing, too. [0] [0]: http://awards.scene.org/awards.php
Re: A first-person engine in 265 lines of JS
#86DN3D uses sectors (Convex Polygon) to store room's lines (or walls), and draws those lines using player's FOV (Field Of View).
When those sectors are connected with others sectors, it's called portal. This is used to sort only the sectors that is inside the player's FOV.
Re: A first-person engine in 265 lines of JS
#87My raycast engine in Javascript needs a few more lines and works a little bit different, but gives also impressive results I think :) . http://simulationcorner.net/index.php?page=comanche
Re: A first-person engine in 265 lines of JS
#88It is very interesting to me that you need to multiply the distance-to-wall by the cosine of the angle to transform the image from fisheye to normal. It makes me wonder, why is it that our eye in real life sees straight lines as straight, the way this demo renders the image? To illustrate the question, see https://en.wikipedia.org/wiki/File:Panotools5618.jpg – why do we see the world as in the bottom image instead of…
I was trying to crack exactly the same problem a decade ago - I was very frustrated by "classical" perspective distortions (such as looking up and down at a very tall pole, you notice in 3D projection the projected width at a given height changes depending on the pitch angle, which is counter-intuitive as your eye doesn't do that). I searched for answers, read Denis Zorin's disertation from Caltech, various different…
Re: A first-person engine in 265 lines of JS
#89Earlier quoted context omitted.
If you missed it a couple of weeks ago, this article about its creation was really interesting: http://fgiesen.wordpress.com/2012/04/08/metaprogramming-for-... ( Thread: https://news.ycombinator.com/item?id=7739599 )
It's really interesting but would someone mind explaining why they have to keep this code under some size limit?