View Single Post
08 September 2015, 11:53   #23
Dunny
Registered User

Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 1,124
Quote:
 Originally Posted by ReadOnlyCat That's actually what I understood. So for a strip which is distorted exactly diagonally you will have to proceed to 16 blitter copies of the original strip each copying only one column of the source, and if the bitplanes are not interleaved the number of blits is multiplied by 8. In practice however perspective projection means that all lines of the strip must be distorted differently and on a y basis, so the distortion is a function of x and y and not just y. Maybe I am misunderstanding but I get the feeling that this requires one blit per line and column except when walls are almost perpendicular to the line of sight.
In a raycasting engine (like Wolfenstein, similar to Doom) all the walls are perpendicular to the floor and there are no slopes to walk up or down. We can use this to our advantage - every texture strip we draw will be vertical.

So for each horizontal pixel position, we cast a ray out from our position - when it hits a wall, we know:

How far the wall was from our position

Which texture we've hit, and where on the texture we hit it.

That's all we need to know - we then scale depending on the distance, this gives us our wall height at this point. We know which column of texture pixels to use from the texture.

All we have to do is stretch that column of pixels to the right size, and pop it on the screen at the current horizontal coordinate, centred in the y-axis.

Do that for all horizontal pixels (320 of them for a nice highres) and you're done - repeat for every frame.

I did a raycaster in BASIC:

http://www.zxspectrum4.net/forum/vie....php?f=8&t=150

(Textured version is about halfway down the page).

The source is really simple, it's just an horrendously slow and repetitive task. It gets slower as you add floor and ceiling texturing (slows down by a factor of about 8) and if you add variable height floors and textures with transparent sections you could add about another 4 - 8x on top of that.

As Mrs Beanbag says, if the blitter is able to do the actual final stretch of the texture strips, that will help enormously - the rest of the raycasting loop is just a few add instructions and a test.

D.

Page generated in 0.06531 seconds with 11 queries