Page 2 of 4

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Thu Nov 03, 2016 2:38 pm
by evgiz
kikito wrote:It's probably that my parser has a bug. I'll give it a look, thanks!
It looks like the voxel is included, but all color values are set to 0 in the texture which is why I couldn't see it

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Thu Nov 03, 2016 3:26 pm
by s-ol
evgiz wrote:
kikito wrote: The next step I want to take is where our paths divert: Instead of rendering the slices directly, I want to try using the texture as a 3d texture and render it using a shader, as explained here and here. But I don't know if I will be able to do it.
I don't know enough about shaders to do this myself, but I look forward to seeing what you can come up with!
Does löve have 3d texture support? Which formats can do that?

If it does the rendering should be rather straightforward, the only thing I'm not sure how to do is casting a ray into the 3d texture to find the first pixel hit (and doing it better than just looping over it).

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Thu Nov 03, 2016 6:02 pm
by kikito
evgiz wrote:
kikito wrote:It's probably that my parser has a bug. I'll give it a look, thanks!
It looks like the voxel is included, but all color values are set to 0 in the texture which is why I couldn't see it
Hi, I am having trouble reproducing this. Can you pass me your current code + the vox model that you are using for tests?

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Thu Nov 03, 2016 7:08 pm
by evgiz
kikito wrote: Hi, I am having trouble reproducing this. Can you pass me your current code + the vox model that you are using for tests?
Yeah of course. Here is a love file, just click the example button and it'll load up example.vox
sprit3r-voxelerror.love
(3.14 MiB) Downloaded 131 times
As you can see on the bottom spritesheet there's a black pixel on the cyan circle, the last voxel I placed.

The code is pretty much the same as the one in your example, but tweaked to flip the model (it was upside down) as well as rendering any pixels with 0 alpha at 255 alpha so you can actually see them.

EDIT: Solved it! I changed this line in vox_model:readChar from self.str:len() to self.str:len()+1

Code: Select all

if self.index > self.str:len()+1 then return 0 end
I'm not exactly sure what it does, but it seems to work... Thanks for all your help!

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Thu Nov 03, 2016 10:59 pm
by Tjakka5
Hey,

Your post inspired me to mess around with the same concept of 2d sprites to 3d display.
So far I've got "models" as well as animations working with a simple camera, but there's one thing I'm still missing...

In your application you can switch between "flat" and "voxel" mode.
How did you achieve the "voxel" mode? I've looked trough your code, but can't figure it out.

Thanks in advance!

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Thu Nov 03, 2016 11:18 pm
by evgiz
Tjakka5 wrote:In your application you can switch between "flat" and "voxel" mode.
How did you achieve the "voxel" mode? I've looked trough your code, but can't figure it out.
Thanks in advance!
To render voxels I simply draw each layer multiple times depending on the zoom and model scale so that they cover every pixel inbetween. This is veeery inefficient, but works fine for a single model. If you're planning on making a game I'd recommend finding an approach with better performance, for instance by pre rendering at set angles, clever spritebatching or something else.

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Thu Nov 03, 2016 11:48 pm
by s-ol
Oh just by the way - i had also seen the reddit post and tried around with the concept for a little, but I got sidetracked and made this animation:
Image
the way it is rendered is the same except that the rotation is different between the layers most of the time, and the layer density is animated. Sprites could simply be substituted for the rectangles though.

and since apparently noone linked the thread, here is the original one on reddit with links to explanation videos and the games.

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Thu Nov 03, 2016 11:59 pm
by zorg
evgiz wrote:I'm not exactly sure what it does, but it seems to work... Thanks for all your help!
It was an off-by-one indexing error; the code assumed that the array was zero-based (0 to length-1), but apparently, it's one-based (1 to length)
Interestingly, it should have also ignored the 0th (or, first) value before, as well, not just the last... i think.

In any case, i löve this project! Hope it keeps being relevant :3

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Fri Nov 04, 2016 3:05 pm
by D0NM
The Sprit3r idea is very great. Way to go!

Re: Sprit3r - 3D model viewer for spritesheets

Posted: Fri Nov 04, 2016 3:22 pm
by Ulydev
I love it! You should put it on Github if it isn't already :)