View Single Post
Old 25 April 2018, 18:27   #134
britelite
Registered User
 
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 818
Ok, let's get back to the real discussion...

Quote:
Originally Posted by Kalms View Post
Slightly different topic; if there is a desire to reduce the CPU time spent for raycasting, then here is an alternative approach:

Discover wall segments near the player by walking through the map, starting at the player's position, and gradually moving away. This can be accomplished via a flood fill. It can also be handled via iteration across a 2D subrect. These can then be combined with culling against the view field. This sort of walk can be made to discover walls in an exact front-to-back order.

Whenever a non-empty block is encountered, it vertices would get projected 2D->1D to screen space. It would then be clipped against previously-discovered spans through insertion into an 1D spanbuffer or similar.

The dual of the spanbuffer is the set of on-screen regions which are not yet covered by walls. Each such non-occluded region could be thought of as a 2D portal. The wall discovery should restrict itself against the current set of portals. (It could either do exact clipping against the portal's edges, or just use it for culling.)

Once you have a set of line segments, you could then perform 1D rasterization to create the list of spans to draw (heights and corresponding texture coordinates). The primary tricky thing here, for a 68000, is that it would involve perspective correct interpolation for the texture U coordinates. It _may_ be possible to simplify that bit by noting that A) the walls are always axis aligned and/or B) perform raycasting per-span but knowing ahead of time that all rays in the group will hit the same wall segment.
I remember we had a talk about this at Revision, and I wasn't completely sure about what you meant. But seeing it written makes more clear, and I agree that this could be a nice way to implement the wall calculations. Especially if the rooms/levels are designed in a way to take advantage of the method

One thing I was wondering regarding the flood fill, is how well it would handle small "pillars" compared to walls. As I was first thinking of stopping the fill for a certain line/column when hitting a pillar, but then realized that depending on angle the wall behind might still be partially visible.

EDIT: Actually, flood fill would handle pillars just great, so disregard my previous little brainfart
I noticed that you could split the room into four segments for the flood fill, with the player position being the dividing point. Then taking the player field of view into account, you can directly disregard at least two of the segments. And when hitting a solid block, you would only add the vertices/wall segment depending on from which direction your filling and not for the whole block.

Last edited by britelite; 26 April 2018 at 07:18.
britelite is offline  
 
Page generated in 0.04315 seconds with 11 queries