News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Mode 7 - Part One

Started by Scott_Bro, October 17, 2021, 02:55:13 PM

Previous topic - Next topic

stevmjon

ok kev, i understand how mod works in C libraries now.

the point i was making, as i misunderstood, was between code & windows 10 calculator:

computer calculator:
8 mod 512 = 8
-8 mod 512 = 504

pb code:
8 mod 512 = 8
-8 mod 512 = -8

the negative value on the windows calculator wraps neg numbers between 0 - 512 as the boundary. so the windows calculator acts like the wrap command.

i understand the difference now, i will use the wrap command instead.

thanks kev
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

stevmjon

hey scott

i fixed the texture flipping issue, yay (see pic). compare this pic with the one in reply #11.
did you want the textures to face the same way too? depending on the angle, they can be upright or upside down... or just leave as is.

now i can refine my TextureStripH method. i will post when done.

  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

Scott_Bro

Can't wait to check it out!  I guess I would like the textures just to be right when I put image of say a race track on them it's the only logical thing I can think of.
Sorry, for the code errors but the tutorials I worked with did'nt seem to work this out right like where trying to do. So thanks for trying Steve O'

Scott_Bro

stevmjon

is the goal one of these methods:

1 > goal is like placing the image on the ground (but image is tiled) and player can move around like being on it?

2 > goal using an image and have it scroll down screen like a car driving (like pole position demo)?

i am actually having fun with this, so i will edit code again to make method 1. i am interested to see if i can do it, with image tiled on the ground, and it will have texturestriph draw method.
also, i assume the image is planned to be drawn on the bottom half of the screen only?

   stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

Scott_Bro

I was thinking like a mariokart of f-zero racetrack bottom only but it still makes a nice demo if you work out correct textexed tileing!


kevin


stevmjon

cool demo kev.

even after all these years in playbasic, i still seem to see programs for the first time. and that one was made back in 2006.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin

  Here's the WIP thread about PB Racer which has a bunch of progression screen shots. 

 Yeah it's pretty old alright..  I was thinking it was about 2010 ish, but it was posted in 2006.   Scary




stevmjon

#23
well scott

i finally got the demo for the image tiled on the ground. took longer than i thought. i left all the commented lines in so you can see i experimented a lot, that is why i took so long, lol.
this runs at 75 fps on my rig (lockbuffer = off). it was faster earlier, but as the image gets so small for the distance, the command texturestriph repeats a lot on those ray lines. it is still faster anyway.

i wanted to see if i could figure it out, before looking at kevs demo he posted. he has it done very well.

   had fun doing this, hope it helps, stevmjon

edit:  see edit 4 in post below (reply #27). it is a cleaned up version.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin


Very cool !    and a bit of scary nightmare to pick through the source code..   

I guess you could try making a 3*3  array of the texture which would keep more of the UV's inside clip zone, but then you offset that against the bigger chunk of memory that needs to read.

stevmjon

yeah, i left the code all in comments to show how much experimenting i needed to do, lol.

good idea with the texture. i didn't know that was a good idea actually. i thought the smaller the texture the faster it was read?
but i guess in this demo, making it bigger would help texturestriph.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin



Quotegood idea with the texture. i didn't know that was a good idea actually. i thought the smaller the texture the faster it was read?
but i guess in this demo, making it bigger would help texturestriph.

  Reading from a big interval between pixels in memory is indeed slow.   So making it too big will choke on systems with slower memory due to the data cache constantly being forced to read / flush chunks as they go in and out of scope.    The question is is the Vm cost more or less than the reading penalty ?     I've NO IDEA :)

  You could store the ground / roof textures in 16bits and or use a palette mapped 16bit.   Which halves the memory foot print and providing the source texture has less than 2^16 colours in it,  would produce the same visuals.     This is how first generation consoles and early software rendering solutions on the PC worked.

  or we could add masks to wrap the UV's with the source texture. 

stevmjon

hey scott

edit4 is a cleaned up version, compared to edit3. i also forgot to re-enable "lockbuffer", so this now runs even faster, at 300 fps on my rig (yay).
i also added move forwards / backwards too.

i left the border checks seperate to each other for easy reading/edit. so there is a right edge, left edge, top edge and bottom edge checking for the wrapping of the image texture.

   have fun, stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin



PlayBASIC - Code Snippet   Mode7 cart racing demo by Stevmjon & Scott_Bro - (2021-11-02)


    This video features Steve's 4th edit of the Mode7 demo that he and Scotty Bro have been working on in recent weeks.    You can find this and other various PlayBASIC source codes in the series on our forums.   

 





kevin


    Steve,

      You (or we if you like)  should wrap this stuff up into a little library to make mario kart style games.     would just need something to compute sprites and that's about it.