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

Dunny's Avatar
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 1,124
Originally Posted by ReadOnlyCat View Post
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:

(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.

Dunny is offline  
Page generated in 0.06531 seconds with 11 queries