Page 1 of 10

Genny and 3D

Posted: Wed Dec 06, 2006 4:33 pm
by ob1
OMG !!!
I've tried to plot a pixel all the day long (my boss won't be happy !) and ... nothing ! drawing a single plot takes me 350 cycles, with some bugs still, and I'm far, very far indeed from Stef demo (man! 10fps with the cube)
Guess I have missed something ...
I'll post later.

Posted: Wed Dec 06, 2006 6:20 pm
by Stef
Megadrive hardware is really not designed for 3D rendering nor than bitmap drawing...
for drawing a single pixel, you have to convert your bitmap coordinat in tile coordinate, then write mode access and adress to the VDP port, then write your pixel data. That's definitly not a fast way for drawing pixel but with this hardware, you don't have choice.
For my 3D rendering, i used a bitmap buffer located in main ram and i convert it to tiles during VRAM transfert. For many pixel drawing, it's the fastest method i think

Posted: Thu Dec 07, 2006 8:52 am
by TmEE co.(TM)
You may want to examine how Duke3D, Zero Tolerance or Bloodshot works. These are fine raycasters made for MD and run quite fast

Posted: Thu Dec 07, 2006 9:22 am
by Stef
The 3D level of Toy Story is the most impressive imo. I do want to examine that game :p
The main trick is that they only render half of screen and use vertical flip for the other part, anyway, this is still quite impressive :)

Posted: Thu Dec 07, 2006 10:37 am
by ob1
Here we go with flat shading.
  • 1- Transform vertices (3D points) into pixels (2D points)
    2- get lines (step 1 needed)
    3- transform lines into polygon (step 2 needed)
    4- get 3D vectors
    5- compute the normal to the vectors (step 4 needed)
    6- get color from the normal (step 5 needed)
    7- for all the polygon points, plot them with the color (step 3 an 6 needed).
Steps 1, 2 and 3 are independent from steps 4, 5, 6. We can make them parallely. 68k could make steps 1, 2 then 3, while Z80 would make steps 4, 5 then 6. Or vice-cersa. Finally, the 68k would make the step 7.

Step 1 is a projection with trigonometry.
Step 2 is getting 2D cartesian equation, using divisons and remainings
Step 3 is just a graphical library consideration
Step 4 is getting 3D cartesian equation, using divisions and remainings.
Step 5 is making a normal product, using multipy and adds
Step 6 is only a Color Look-Up Table (CLUT).
Step 7 is quite compute hungry. I am currently working on it.

Posted: Thu Dec 07, 2006 6:19 pm
by Fonzie
Well, i have a trick to render vertical lines (half horizontal rez only) at full speed...

Just put your tiles like that (for a display size of 4 tiles height)
0 4 8 12
1 5 9 ....
2 6 10
3 7 11

Then, just render your pixels as Bytes and increase the adress per 4 after each write, and DMA all to vram at once... (or set the VDP data bias to 0x4 to render directly in vram). You get ultra fast vertical line drawing...

Héhé, stef can confirm from what he saw :P

Btw: Yeah, Toystory and Blood shot do mirror :)

Posted: Fri Dec 08, 2006 11:14 am
by Stef
The VDP bias reg is really usefull indeed, it permit some trick with DMA operations ;)
Why about using the DMA fill operation to draw vertical line ? it should be faster.

Posted: Fri Dec 08, 2006 1:42 pm
by Fonzie
If you render your 3D or scalling by software and per horizontal line, no need DMA fill, just use my method (you'll get 90° reversed picture) to render at fullspeed without making a mad BMP2Tiles calculus... that is the trick.

Posted: Fri Dec 08, 2006 10:22 pm
by Stef
My software BMP2Tile is almost as fast than a simple software copy.
Anyway a DMA copy is a lot faster than a software copy. But i've to admit i don't understand your method exactly. I just can't use DMA to transform my bitmap buffer to tile buffer in VRAM... actually i can, but i've to do severals transferts and transfert 2x the total size, so all gains are lose :-/

Posted: Fri Dec 15, 2006 12:59 pm
by stalepie
Star Cruiser intro (Megadrive)
http://www.youtube.com/watch?v=MIMEfxYh3lc

Posted: Fri Dec 15, 2006 1:16 pm
by TmEE co.(TM)
stalepie wrote:Star Cruiser intro (Megadrive)
http://www.youtube.com/watch?v=MIMEfxYh3lc
Intro is very nice. I never thought that MD is fast enough to create such complex 3D objects.
Well, I'm not sure, but game itself uses raycasting. Edit: No raycasting, 3D objects all the way.

Posted: Fri Dec 15, 2006 2:55 pm
by ob1
stalepie wrote:Star Cruiser intro (Megadrive)
http://www.youtube.com/watch?v=MIMEfxYh3lc
Amazing !

Posted: Sun Dec 17, 2006 5:36 am
by cdoty
That is impressive. It's definately not updating the 3D at 30 frames per second though.

I thought they were rendering to a sprite, until I saw the large object come in on the right. Too bad the in game stuff doesn't look as good.

Silpheed is the best looking 3D on the Genesis, but that is helped a lot by the Sega CD processor, I believe.

Using the Sega CD, I wonder if the Sub CPU could handle all of the rotation and translation, and the Main CPU handle the rendering?

Posted: Sun Dec 17, 2006 10:27 am
by stalepie
Star Cruiser was a port of the PC88 game of the same name. I am not sure how the two compare.

Posted: Sun Dec 17, 2006 7:15 pm
by Mask of Destiny
cdoty wrote:Silpheed is the best looking 3D on the Genesis, but that is helped a lot by the Sega CD processor, I believe.

Using the Sega CD, I wonder if the Sub CPU could handle all of the rotation and translation, and the Main CPU handle the rendering?
I would imagine that it used the Sega CD graphics chip for the bulk of the rendering. AFAIK, you can do multiple deformed sprite renders to the same buffer. Of course, the 68ks still need to handle the 3D and 3D to 2D transforms.