Thursday 28 February 2019

Yoshi In Lego - Coloured Voxels Part 4


Here's Yoshi in Lego!  The original in Blender is top left, the voxel file in Goxel top right and the final Lego model rendered in Stud.io underneath.  I've now accessed the colour data from the vox file and I've written a comparison function to compare the RGB voxel data to the closet Lego colour (using the colour data from LDConfig.ldr), so the conversion of voxel colours to Lego colours is now automatic.

Wednesday 27 February 2019

Goxel to LDR - Coloured Voxels Part 3

I've carried working on optimising coloured voxel models into ldr files - I'm making progress.  In the image, on the left is the voxel file from Goxel (that I made on my iphone BTW!).  The optimised ldr (that I create by processing the resulting .vox file) is top right and the file rendered image in Stud.io bottom right - for some reason Stud.io has decided to delete some of the bricks from the render (all the bricks appear correctly in the stud.io interface but when I click render some bricks are not rendered!) - I'll worry about that later!  However the script does now convert the individual 1x1 bricks into larger bricks and does the 90 degree rotation on alternate layers to add strength.



There are still a few problems -

1) I can't currently read the colours!  Weird I know but I get a colour from the .vox file (and that colour is consistent where it appears) but I can't currently read the RGB values - I manually fix the colours with a find replace - hopefully I'll get the RGB values shortly - then I need to do a compare between the voxel RGB and Lego RGB and find the closest match.

2) Due to the way my script scans the .vox model there is a tendency for it leave a number of 1x1 bricks on each layer pass - this didn't occur with single colour models as the 1x1 bricks would be merged with their nearest neighbour.  However with coloured voxels this is not always the case - I should be a be able to fix this with a second pass to clean up any remaining 1x1 bricks which have the same colour neighbour.

3) There is some kind of mirroring/reflection going on when I process the .vox file

Monday 18 February 2019

Big Models = Big Colour - Coloured Voxels Part 2

Although I'm only creating 1x1 ldr models I thought I would see how big my current script could go.  So I loaded one of the Magica Voxel demo files into my script and let it run.  It took over an hour to process on my workstation but in the end it did create an ldr of the original voxel model - this ldr file contains over 220,000 bricks!  Not very practical but it does mean that I should be able to process some quite large models.





Saturday 16 February 2019

A World of Colour - Coloured Voxels Part 1



I've returned to converting voxel models to ldr files, but this time my hope is to be able to convert coloured 3D models to a .ldr file with coloured bricks.  Binvox does not seem to support coloured models so I needed to research other voxel modelers with colour support.  Consequently I discovered Magica Voxel and Goxel - both support coloured voxel models and both are free to use.  Both have useful toolsets for creating and rendering voxels models but Goxel has better import/export options than Magica Voxel and there is also a iOS goxel app (but you have to pay for that).   Magica Voxel created and use their own .vox format (which supports coloured voxels) and Goxel can import and export .vox files




Goxel also supports it's own internal scripting language which opens up considerable possibilities for procedural builds and designs.



As part of my research I also discovered py-vox-io (which like binvoxpy) would take the heavy lifting out of having to decode Magica Voxel's .vox file format as py-vox-io allows python to read and write .vox files.  Unfortunately py-vox-io only runs under Python 3 so I would need to switch from Python 2.7 to Python 3.  To be honest I needed an excuse to switch to Python 3, which has become increasingly established so I decided to jump in with this project.  I also decided to switch my IDE to Microsoft's Visual Studio Code.  My previous IDE was a lash up of Notepad++ with some plug-ins so I could call python directly - it worked for me but it wasn't exactly "standard"!


Changing to Python 3 and switching my IDE means that I've had to go back an rewrite some of my binvox code that I created previously to build .ldr files from binvox files and I also needed to add support for reading the colour information in the .vox file format.  Currently although I can access details about the differences in colour between each voxel linking together the Lego colour palette and the .vox file palette is quite complex and at the moment I need to manually assign the correct Lego colours in the LDR file.


So the image above shows the original .vox model in Magica Voxel, the initial LDR output (before processing the colours) and the final LDR file with the colours manually remapped (using a find/replace function) to Lego colours




   


Friday 1 February 2019

Stud.io v2.0 and Eyesight Photo Real Renderer

I've had a quick look at the "Photo Real" renderer that Stud.io v2.0 uses - its called Eyesight and there are some reports that it's based on Blender's "Cycles" renderer but I can't be certain of that.

Eyesight seems to be a command line renderer so you throw commands at it and it renders something.  Here's the command that Stud.io creates when you click the render button

"C:\Program Files\Studio 2.0\PhotoRealisticRenderer\win\64\eyesight.exe" --daewindingorder clockwise --autoexit --device-occupation 5 --device CPU --logpath C:\pathToMyFile\logFile.log --width 640 --height 480 --samples 256 --ground --ground-red 0.8 --ground-green 0.8 --ground-blue 0.8 --defaultlight --preset BUILD_RL --defaultlight-rotz 29.58608 --light-intensity 1 --daefile C:\pathToMyFile\myFile.dae --output C:\pathToMyFile\myFile.png

Stud.io wrties the .dae file to this location (or you can just use export>dae from the file menu)

C:\Users\[yourUsername]\AppData\Local\Temp\Studio

The .dae file that Stud.io creates for Eyesight to render is a txt file based on Collada's .dae XML file format (so you can just edit it with a text editor) - this gives you access to all the "internal" render parameters.  Stud.io also lets you add scratches to the render which is unusal - I've over-cooked the scratches on this model to make it obvious! 



The scratches are configured in the .dae XML file and use some preset textures that are stored here...

C:\Program Files\Studio 2.0\PhotoRealisticRenderer\win\64\textures

So you could in theory make you own scratches - plus there is also a Lens dirt texture in there but I can't see how to apply that in Stud.io.

Typing

"C:\Program Files\Studio 2.0\PhotoRealisticRenderer\win\64\eyesight.exe" --help

will give you Eyesignt's command line help



There are some interesting options there - particularly the "animation" ones.