Log In  

Update : I don't think my cart is very usable. Possily math issues and globally unoptimized process won't make it a decent base for games or sketches. I'll hold further dev of it for now. Check instead freds' version istead, it seems pretty more promising Here be dragons.

Hello everyone, I'll be posting my 3d (+extra) toolkit here. Been a while I haven't touched it until a few days ago. I could even optimize it further than before (at the expense of a few things).

The cart is a basic demo of what it can do, I'll be writing a few more explanations (and a link to a Blender export tool) later, if you don't mind.

What's supported (or inside the pipeline):

  • wireframe/flat/light shading (ambiant+light power+light direction)
  • backface culling
  • zsorting (thanking a few people for offering good heapsorts)
  • Translate/Rotate/Scale per object
  • basic vector/matrix library

What's not supported

  • Proper frustrum culling (put a mesh behind the camera and see the disaster)
  • Texturing

What's maybe planned

  • Mesh compression (not yet planned)
  • Vertex keyframing (still wondering how to make it the quickiest)

Extra features

  • The water/reflecton effect you all loved in my demos (with palette indirection)
  • record utility to quickly record a number of frames

Cart #54374 | 2018-07-24 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
10

P#54375 2018-07-24 02:23 ( Edited 2018-07-25 05:12)

3

(follow up from Twitter discussion!)

My version uses a simpler lightning, but runs about twice as fast :)
Key differences that I can tell:

  • unrolled matrix operations
  • no oop in vector/matrix math
  • (hence) much reduced memory usage
  • (hence) almost no memory allocation during rendering (stable at 165KB), your version fluctuates between 505-522KB!!!)
  • support for convex faces with any number of edges (quads...) :)
  • backface culling in object space
  • trifill from @p01 (fastest in town :)

Cart #54386 | 2018-07-24 | Code ▽ | Embed ▽ | No License
3

P#54385 2018-07-24 16:21 ( Edited 2018-07-25 05:02)

Hey, nice work! This is damn good!

The memory unstability cames from building the triangle draw list. Somehow, it exploded the usage. I haven't understood yet why it 'd have exploded so much. Before this current method I used pre-sized lists for normals/zpos and indices of triangles to draw, it was stable, but it was eating quite a bit of the slice.

Wasn't the add function heavier than just using array[#array+1]? I did some micro benches and I got a slightly better result for adding the old lua way.

So, zbuf_draw is the zsorting function for models? How does it fare with weird shaped objects? Also, nice, Quaternions. I'm awfully bad with them, that explains my old 3 matrix way, I guess they really added a lot, performance wise, right?

I'm still having a small hard time understanding what happens ,but it seems pretty good. Well done. I guess it makes a better library than mine, haha! I didn't have the intention to provide the best one around the corner. Do you want to make your version a real library?

Edit : if you prefer comparing with the previous version, here it is :

Cart #54388 | 2018-07-24 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

What's your tool to compress the mesh data into the spritesheet? I wonder if you store face color in the data. There could be a good export tool to be made on Blender. I did start one for my own stuff, but I didn't get far past just exporting the existing mesh according to custom settings in the materials. I thought of making a small subpanel for the Material Panel where you would click on the color for the material. Nothing really fancy, but something that'd have made the mesh coloring easier.
Here's a gist holding the source of the proto export I did, maybe you could make something from it? https://gist.github.com/Eiyeron/d8c05fe46c31101e5e42f303d4a4b848

P#54387 2018-07-24 16:43 ( Edited 2018-07-24 21:15)

The plan is not to release a library per se (doesn’t really work for pico I guess) but to compare 3d engines, see where we can squeeze some more performance!

Quaternion are not core, more a convenieny way for me to express orientation.

Blender export: I do have a portable export script that will export multiple models into gfx+map data (that’s how I did for Attack on the Deathstar). I don’t have face color export as of now, but will certainly be needed for my next project ;) See my github account (pico/models) - the entry point is run_export.py.

Sorting/odd shaped: I don’t have a massive draw list of all world faces. Objects are first z-sorted/culled and then rendered (zbuf_draw). It allows objects of different natures (say sprites/3d model) to be rendered in a unified way.
For each actor, a draw method is called. For 3d models, I transform and cull faces. Visibles faces are sorted and rendered using regular trifill (with support for ngon).
side-effect: don’t do banana shaped models that overlap!

note: I’ll bench also the array[#array+1]. Thanks for the hint.

P#54403 2018-07-25 01:12 ( Edited 2018-07-25 05:15)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 22:31:15 | 0.020s | Q:23