Cool ideas for a modern 2D system.
Moderator: Moderators
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: Cool ideas for a modern 2D system.
I'm not even going to lie, but I've never really understood what raycasting is or how it works. Is it no more "3D" than scaling and rotating sprites or mode 7 style BGs?
Re: Cool ideas for a modern 2D system.
Ray casting is a variant of ray tracing. Ray tracing requires that you trace a ray from the camera viewpoint to the level geometry for each pixel in the viewport. This is computationally expensive (640x480 = ~300k rays!). However, if we constrain the camera viewpoint so it is unable to rotate about the z-axis, and we constrain the level geometry so all walls are at 90-degree angles to flat surfaces (floors, ceilings, etc), then we need only cast one ray for each pixel in the x-dimension of the viewport. For a viewport of 640x480, this is a 480x reduction in rays cast.
It's easier to explain in motion, and I couldn't hope to explain it better than this website: http://fabiensanglard.net/doomIphone/do ... nderer.php
It's easier to explain in motion, and I couldn't hope to explain it better than this website: http://fabiensanglard.net/doomIphone/do ... nderer.php
Re: Cool ideas for a modern 2D system.
That being said, it's important to note that Doom uses neither ray casting nor ray tracing.
Re: Cool ideas for a modern 2D system.
toku is right, and I'm mistaken. Wolfenstein-3D uses ray casting. Doom, on the other hand:
http://doom.wikia.com/wiki/Doom_rendering_engineThe Doom engine renders the walls as it traverses the BSP tree, drawing subsectors by order of distance from the camera (that is, the closest segs are drawn first). As the segs are drawn, they are stored in a linked list. This is used to clip other segs rendered later on, reducing overdraw. The list is also used later to clip the edges of sprites. ...
Once the engine reaches a solid (one-sided) wall at a particular X coordinate, no more lines need to be drawn at that area. As this occurs, the engine builds up a "map" of areas of the screen where solid walls have been reached. This allows distant parts of the level, currently invisible to the player, to be clipped completely.
Re: Cool ideas for a modern 2D system.
The Build engine, used for Duke Nukem 3D, uses "portal casting", which traverses a network of sectors that are connected to adjacent sectors and rejects any sector obscured by the walls of closer sectors. If portal casting were applied to the square grid world of Wolfenstein 3D, it'd look like the GIF I posted here. Replace the square grid with arbitrary polygons and you have Build.
- ShaneM
- Posts: 353
- Joined: Wed Apr 04, 2012 4:15 pm
- Location: United States of America (USA)
- Contact:
Re: Cool ideas for a modern 2D system.
To hyperlink, simply do (url)link_here(/url) replacing the ()s with []s. So, it becomes: http://doom.wikia.com/wiki/Doom_rendering_engine
I hope this was helpful.
EDIT: Or, simply hit the "URL" button at the top adjacent to "Message body:".
Re: Cool ideas for a modern 2D system.
Forget about how Doom does it, with triangles you can get arbitrary 3D meshes (and they're much easier to compute than any other kind of filled primitive), plain and simple. (also the Lynx does quads to some extent too, which is how you render sprites normally in fact)Espozo wrote:I really don't get it, but why would having triangles be any better than squares?
In any case my point being that arbitrary 3D meshes are better than restricted 3D engines no matter how you look at it =P (provided you have enough performance)