Genny and 3D

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
ob1
Very interested
Posts: 410
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Genny and 3D

Post by ob1 » Wed Dec 06, 2006 4:33 pm

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.

Stef
Very interested
Posts: 3058
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Wed Dec 06, 2006 6:20 pm

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

TmEE co.(TM)
Very interested
Posts: 2404
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Dec 07, 2006 8:52 am

You may want to examine how Duke3D, Zero Tolerance or Bloodshot works. These are fine raycasters made for MD and run quite fast
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3058
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Thu Dec 07, 2006 9:22 am

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 :)

ob1
Very interested
Posts: 410
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Thu Dec 07, 2006 10:37 am

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.

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Thu Dec 07, 2006 6:19 pm

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 :)

Stef
Very interested
Posts: 3058
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Dec 08, 2006 11:14 am

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.

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Fri Dec 08, 2006 1:42 pm

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.

Stef
Very interested
Posts: 3058
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Dec 08, 2006 10:22 pm

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 :-/

stalepie
Very interested
Posts: 101
Joined: Sun Dec 10, 2006 1:18 pm

Post by stalepie » Fri Dec 15, 2006 12:59 pm

Star Cruiser intro (Megadrive)
http://www.youtube.com/watch?v=MIMEfxYh3lc

TmEE co.(TM)
Very interested
Posts: 2404
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri Dec 15, 2006 1:16 pm

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.
Last edited by TmEE co.(TM) on Sat Dec 16, 2006 11:10 am, edited 1 time in total.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

ob1
Very interested
Posts: 410
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Fri Dec 15, 2006 2:55 pm

stalepie wrote:Star Cruiser intro (Megadrive)
http://www.youtube.com/watch?v=MIMEfxYh3lc
Amazing !

cdoty
Very interested
Posts: 117
Joined: Wed Nov 29, 2006 2:54 pm
Location: Houston, TX
Contact:

Post by cdoty » Sun Dec 17, 2006 5:36 am

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?

stalepie
Very interested
Posts: 101
Joined: Sun Dec 10, 2006 1:18 pm

Post by stalepie » Sun Dec 17, 2006 10:27 am

Star Cruiser was a port of the PC88 game of the same name. I am not sure how the two compare.

Mask of Destiny
Very interested
Posts: 594
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Sun Dec 17, 2006 7:15 pm

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.

Post Reply