Jump to content
DrTypo

(demo) 3d engine

Recommended Posts

Posted (edited)

After Tube2020, I decided to make a more complete 3d engine.

It is still a very simple engine and lacks many features.

It displays only flat shaded triangles and does rotations only around Y axis.

 

So what to say about it?

It's not very fast despite the fact that it uses the GPU and blitter.

On my PAL machine, it runs in 3 frames (16.6 fps) while computing about 254 triangles.

Possible optimisations are:

  • improve depth sorting: if I remove depth sorting, it runs in 2 frames (25 fps). To do depth sorting I uses comb sort, which is an optimized bubble sort. Shell sort would probably be better. Another optimisation would be to do depth sorting only on the objects and use convex objects.
  • backface culling: I didn't implement backface culling (because lazyness). This would likely speed things up quite  bit.
  • use the DSP for transformation and clipping, the GPU for rasterisation.
  • reduces the amount of transformations: there are duplicate vertices that are transformed multiple times. This could be improved.

 

Doing this would take time and also run into the 4K limit of the GPU (except using DSP, this would help a lot with the 4K limit but good-bye U235 sound engine).

The routine could easily be split into 2 chunks for the GPU (transformation/clipping and rasterisation).

 

Anyway, doing fast 3D on the Jag is not easy (who knew?). Now I understand Checkered Flag (which probably uses a faster engine than this one).

But I don't understand No Second Prize on the Atari ST.

 

Edit: I implemented backface culling and things are indeed quite a bit faster. It now runs in 2 frames (25fps).

The effects of backface culling are two-fold: there are fewer triangles the rasterize will attempt to draw and fewer triangles to depth sort.

By the way I'll explain the meaning of the numbers on screen:

  • the first is the size of the routine in bytes. I can check that I stay within the 4096 bytes limitation of the GPU.
  • the second one is the number of triangles rendered.
  • the third one is a bit hard to grasp: it's the number of ticks (1/50th ou 1/60th of a second depending on your region) used to render 50 frames. So if the number is 50, one frame takes one tick. You are at full framerate (50fps or 60fps). If the number is 100, one frame takes two ticks you're at half framerate (25fps or 30fps).

 

 

 

 

engine.zip

Edited by DrTypo
edit: backface culling implemented
  • Like 17

Share this post


Link to post
Share on other sites
2 hours ago, DrTypo said:

After Tube2020, I decided to make a more complete 3d engine.

It is still a very simple engine and lacks many features.

It displays only flat shaded triangles and does rotations only around Y axis.

 

So what to say about it?

It's not very fast despite the fact that it uses the GPU and blitter.

On my PAL machine, it runs in 3 frames (16.6 fps) while computing about 254 triangles.

Possible optimisations are:

  • improve depth sorting: if I remove depth sorting, it runs in 2 frames (25 fps). To do depth sorting I uses comb sort, which is an optimized bubble sort. Shell sort would probably be better. Another optimisation would be to do depth sorting only on the objects and use convex objects.
  • backface culling: I didn't implement backface culling (because lazyness). This would likely speed things up quite  bit.
  • use the DSP for transformation and clipping, the GPU for rasterisation.
  • reduces the amount of transformations: there are duplicate vertices that are transformed multiple times. This could be improved.

 

Doing this would take time and also run into the 4K limit of the GPU (except using DSP, this would help a lot with the 4K limit but good-bye U235 sound engine).

The routine could easily be split into 2 chunks for the GPU (transformation/clipping and rasterisation).

 

Anyway, doing fast 3D on the Jag is not easy (who knew?). Now I understand Checkered Flag (which probably uses a faster engine than this one).

But I don't understand No Second Prize on the Atari ST.

 

engine.zip 30.75 kB · 14 downloads

Great stuff! Can I ask a question? How do you  make and import your 3D meshes?

Share this post


Link to post
Share on other sites
4 hours ago, agradeneu said:

Great stuff! Can I ask a question? How do you  make and import your 3D meshes?

I make the 3D meshes in Blender and export them as .obj files. Then I convert them in raw structures for my engine using a tool I made.

 

  • Like 1

Share this post


Link to post
Share on other sites

I implemented backface culling. More info in the original post.

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

Cool! Pretty zippy, too!

 

*It would be cool for an auto spin around routine to kind of automate and show off the 3D at full speed without any user interaction, say pressing 5 and it could loop to 4 points, pausing at each one briefly or spinning around complete then ping ponging to another coordinate point at random though I suppose that may be silly and useless. Also, I take it the U235 isn't implemented at all on this one but am curious as to impact it would make if added.

 

**and maybe other goofy stuff like background color cycling

Edited by Clint Thompson
  • Like 2

Share this post


Link to post
Share on other sites

But can it do a completely straight road with weird random clipping errors?

  • Like 1
  • Haha 6

Share this post


Link to post
Share on other sites
1 hour ago, CyranoJ said:

But can it do a completely straight road with weird random clipping errors?

 

Only the best of the best ultra-wang coders could even dream of such greatness!

  • Like 4
  • Haha 1

Share this post


Link to post
Share on other sites
5 hours ago, CyranoJ said:

But can it do a completely straight road with weird random clipping errors?

:D I'm not elite enough to attempt such a task. But it does overflow when things are a bit far.

 

@Clint Thompson I don't think I'll implement an auto-spin feature. However I'll try to have U235 SE play some music. I expect the impact to be minimal. From my experience, U235 SE has hardly any effect on the rest of the system.

  • Like 7

Share this post


Link to post
Share on other sites
10 hours ago, CyranoJ said:

But can it do a completely straight road with weird random clipping errors?

He hasn't worked out the 200 pages of spreadsheets showing cycle counts nor re-worked the engine continuously for 2.5 years.  Give it time, and it just may be possible!

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...