Advertisement

MagicaVoxel

Started by October 17, 2022 12:38 AM
34 comments, last by Geri 2 years, 2 months ago

JoeJ said:

taby said:
I am working on an obj importer now, using OpenGL.

Keep in mind obj is too limited to cover all bases. Iirc it lacks things like multiple UVs and bone weights, so no quake levels, and no skinned characters.

Richer formats are fbx or glTF. That's so much work i'd already recommend using Assimp library (which also supports obj), and from that eventually make your own native format if needed.

I have not used Assimp to import animation though. Seems people often have problems with animation corner cases, and thus end up making their own fbx importer anyway.

I'd actually be more worried about the opposite. Obj is a generalized data format that supports textures, non-integer vertex coordinates and custom normals, none of which are necessary for voxel rendering. If you're using a generalized .obj renderer, then your voxel rendering is not as efficient as it could be.

a light breeze said:
If you're using a generalized .obj renderer, then your voxel rendering is not as efficient as it could be.

Yeah, my comment was about general mesh import, not specific to voxels.

I assume MagicaVoxel mesh export does at least optimizations like merging coplanar faces to larger polygons, but i agree it might make sense to work with voxel data directly, depending on your needs.

Advertisement

How do you suggest that I implement a voxel renderer?

OpenGL4 with shadows

Another cool voxel game, similar to your artstyle.

Maybe they use voxels for raytracing to enable soft shadows and stuff. The game Teardown would be an advanced example, and the dev has a related blog.
But most voxel games with blocky/cute/retro artstyle do just traditional gfx using triangle meshes.
It also depends on your needs for dynamic worlds and physics (building? destruction?).

Just static geometry for the world, for now. I’m going to basically make a prototype that shows off a battle system similar to Final Fantasy Tactics.

taby said:
Just static geometry for the world, for now.

Then i would use traditional triangle meshes and rendering.
So the only extra work probably is to merge coplanar faces to reduce triangle count. You need to check Magica output it wireframe to see if they already do this.

For terrain you probably need to do it yourself, because you generate it procedurally?
There sure are Minecraft tutorials around with proposals. But i would do the merging with a motorcycle graph, which i can explain if you want.

Advertisement

JoeJ said:

Then i would use traditional triangle meshes and rendering.
So the only extra work probably is to merge coplanar faces to reduce triangle count. You need to check Magica output it wireframe to see if they already do this.

OK, will try that out.

For terrain you probably need to do it yourself, because you generate it procedurally?
There sure are Minecraft tutorials around with proposals. But i would do the merging with a motorcycle graph, which i can explain if you want.

This will be just a one-level demonstration of a tactics game. Of course I would love to hear you explain motorcycle graphs. I'm not at all familiar with the subject.

Thanks for your feedback!

Here is the mesh drawn as lines.

There are no details inside of the surface. And, here is how many vertices used each of the 6 face normals:

-1 0 0 → 516

0 -1 0 → 579

0 0 -1 → 579

0 0 1 → 630

0 1 0 → 513

1 0 0 → 555

Lines
with lines
with tri edges

I see the mesh is already reduced. Some edge flips to maximize angles would still improve it, but i doubt it's worth the work.

The contour lines probably don't look good if you render the character smaller like in the game, because you get too much of them, causing just flicker and exaggeration of the voxel quantization.
You could try to render the contours in the same color as the voxel, just a bit darker. This should look better in general, and also allows to highlight important objects by using black only for those.
However, the issues remain. If you have a bush, it will cause noise of many lines and a darker appearance, while a simple box would cause only a few lines and no darkening. (We have similar issues by using AO with realistic gfx too.)

A solution would be to make contour lines only per object, not per voxel. Guess this could be done using the stencil buffer for object IDs, but never did anything like that.
The idea to combine cel shading contours with voxels surely isn't overused. So you could get some unique artstyle out of it.

SSAO would look good too i guess, although voxels make the artifacts even easier to see than realistic gfx. So i would use it only a little bit, just so much it's visible.

For shading i would experiment with modeling brightness from shifting hue. Artists do this all the time, but in games lighting it's never done. Not sure why.
The problem i want to solve is easiest to see on yellow voxels. Yellow is a nice color, but in shadow it gets some ugly, dirty brown. This happens because we mix it with black.
But we can do better: To make yellow darker, we can rotate it's hue either towards red or green (we can measure the direction from the initial color).
This works with every color, and we get more saturated results.
I never tried to formulate some math to calculate this, but it should be easy to figure out. Once it works, shadows and AO should look much better than usual (if some cutesy artstyle is the goal ofc.)


This topic is closed to new replies.

Advertisement