3D on MSX

Страница 3/4
1 | 2 | | 4

By turbor

Champion (476)

Аватар пользователя turbor

18-06-2009, 09:06


thanks i guess the realtime texture mapped 3D for MSX2 is the one that shows the best what i wanted to see : it shows quite a lot of difference between turboR and MSX2 .
For me that means that the CPU calculation speed makes a lot of difference and VDP is not the bottleneck. I guess all the job is done in RAM and then there just a transfer to VRAM which does not account for a large part of the time otherwise turboR would be as slow as msx2

FYI, the texture mapping routine in the realtime texturemapped 3D demo is like this:

  • Calculate delta-u end delta-v in the texturemap needed to draw a horizontal line on screen. There is no depth correction, only linear mapping!
  • Calculate the maximum number of horizontal pixels need in the triangle to be drawn on screen.
  • Create an offset table for the (u,v) texturemap in ram, the offsets are ram-address-based offsets related to the startpoint of the line in the texturemap space. Size of this table was calculated in the previous step.
  • The core loop itself is something like this:
    di
    store sp somewhere in ram
    ld sp,offsettable
    ld de,address of first pixel in texturemap
    ld b,calculated_nr_of_pixels_for_line
    pop hl
    add hl,de
    ld a,(hl)
    out (c),a
    djnz loop:
    restore sp
    ei
    

It is mainly due to the increased speed of all this on R800 that everything goes so much faster.
If you do only the 3D wireframe calculations and have the vdp draw only line commandos you will notice that, while there is still a difference, the percentage of gained speed is much less.

By Leo

Paragon (1236)

Аватар пользователя Leo

18-06-2009, 09:17

There is also 3D rotation , not only polygon filling , or is it all precalculated ?

By MicroTech

Champion (385)

Аватар пользователя MicroTech

18-06-2009, 09:22

Thanks enribar and jitursan for your appreciating Running Naked in a Field of Flowers
Hope you have a 1chipMSX for next E3D release... Cool

Leo wrote:
thanks i guess the realtime texture mapped 3D for MSX2 is the one that shows the best what i wanted to see : it shows quite a lot of difference between turboR and MSX2 .
For me that means that the CPU calculation speed makes a lot of difference and VDP is not the bottleneck. I guess all the job is done in RAM and then there just a transfer to VRAM which does not account for a large part of the time otherwise turboR would be as slow as msx2

Imho cpu speed makes a lot of difference in transfomations and texturemap calculations but it is not the only bottleneck: also vdp plays an important role, especially if you are going to use filled polygons.

By turbor

Champion (476)

Аватар пользователя turbor

18-06-2009, 10:18

There is also 3D rotation , not only polygon filling , or is it all precalculated ?

Everything is real time calculated.

The only precalc done is that I store the center-of-gravity for each polygon as a separate point instead of realtime calculating it (used for depth sorting), and also the normal vector is stored instead of being calculated.

This way I first calculate the rotation of the normal vector so that I can decide if the polygon is visible, if so only then do I start calculating the points of polygon itself. (after checking the buffer to see if maybe I already calculated the point for a adjacent polygon Smile )
Thus making this a 1 (or maximal 4 if needed) rotation calculations instead of the more regular 3 rotations+normal_vector_calculation found in most engines.

As an extra I only calculate the Z-component of the rotated normal vector since this determines the visibility.

In short, I calculate everything real time, but the code tries to be as minimalistic as possible about the number of needed calculations.

By Leo

Paragon (1236)

Аватар пользователя Leo

18-06-2009, 13:01

ok no offense , i really though it was real time from the begining anyway.
I took a look to the source for the 3D object definition , they have around 40 polygons max, right ?

By Leo

Paragon (1236)

Аватар пользователя Leo

18-06-2009, 13:07

I tried to get it again, but the link seems to be broken :(: Maze by xl2s newpost

Afair, although it had screen 3 render resolution (64 columns raycasted x 48 height [1pixel=4x4pixels]), it was done in screen 2 (or 4) and columns depth was shown by them height and pixel pattern of the "pixel". Sprites had better res than the walls (1 pixel=2x2pixels), as they were hardware zoomed regular sprites. I think I remember it quite well because it impressed me back then, and made me investigate a lot about raycasting for my own wip project.

[Edit: I've found it at the download section, right here]

Taking a look again at the demo, the walls resolution is lower that what I remembered. So, just 32 columns raycasted and pixels were 1pixel=8x4 pixels. Anyway a well done raycasting demo. Although raycasting is not real 3D, I really think that's the way to go in order to have something 3Dish on MSX.

I tried once to do some raycasting just like the demo you are talking about , the idea was to have in vram ( lets say page2 in screen 5) vertical stripes that represent the same wall texture but streched with different height, they could be from 8 to 2 pixel wide also.
to get a texture with some variation i had 2 type of stripes .
So i used these stripes with hmmm vdp commands : the result was waaay too slow but i think it was also due to the raycasting engine that was very poorly coded in basic, not sure that idea was all that bad.

By cesco

Champion (453)

Аватар пользователя cesco

25-06-2009, 23:06

This is not exactly related to the MSX, but quite close... Wolfenstein 3D for the ZX Spectrum:

http://www.youtube.com/watch?v=vzm9KkJ5lGI&feature=related

Do you think it's a fake video or is it really possible ?

By NYYRIKKI

Enlighted (5776)

Аватар пользователя NYYRIKKI

25-06-2009, 23:20

It is real ZX Spectrum code, but it does not run in original ZX Spectrum speed. (Emulators make anything possible)

By ARTRAG

Enlighted (6506)

Аватар пользователя ARTRAG

25-06-2009, 23:32

not correct
IIRC it is running on a Russian zx clone at 7MHz

By Leo

Paragon (1236)

Аватар пользователя Leo

26-06-2009, 08:15

7MHz ... should then be possible to do the same speed on Tr , and even faster.

Страница 3/4
1 | 2 | | 4