darkfall / magicavoxelunity Goto Github PK
View Code? Open in Web Editor NEWUnity3D plugin for MagicaVoxel's vox format.
License: MIT License
Unity3D plugin for MagicaVoxel's vox format.
License: MIT License
I've got questions, proposed changes, etc., but if you're not interested in working on this then I'll just play with my fork of this repo.
Steps to reproduce:
Get latest unity build.
Install this repo.
Load the knight model, without alpha model.
Select the individual voxel option, reimport.
Select the voxels that form the axe, or another voxel set. Try to merge them.
An error pops up here: alphaMax.voxels is null and you try to access it:
int alpha = alphaMask == null ? (byte)0 : alphaMask.voxels[ x, y, z ];
Fixing it like this:
int alpha = alphaMask == null || alphaMask.voxels == null ? (byte)0 : alphaMask.voxels[ x, y, z ];
Creates this error :S help
NullReferenceException: Object reference not set to an instance of an object
(wrapper managed-to-managed) object:ElementAddr_3_1 (object,int,int,int)
MVImporter.GenerateFaces (.MVVoxelChunk voxelChunk, .MVVoxelChunk alphaMask) (at Assets/MagicaVoxel/Scripts/MVImporter.cs:420)
MVVoxModelVoxelInspector.CombineVoxels (.MVVoxModelVoxel[] voxels) (at Assets/MagicaVoxel/Scripts/Editor/MVVoxModelVoxelInspector.cs:43)
MVVoxModelVoxelInspector.OnInspectorGUI () (at Assets/MagicaVoxel/Scripts/Editor/MVVoxModelVoxelInspector.cs:20)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1240)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
When "Import as Individual Voxels is selected", there is a bug with mesh building : in the following screen, I've imported a model as individual voxels, then used the "Combine Selected" function on the left half of the voxels.
There clearly is a problem with lighting and I believe this is due to incorrect normals. In MVImporter.CubeMeshWithColor(float, Color) only 8 vertices are added to the mesh, one for each "corner". There should 3 for each corner : one for each corner and for each face (normal).
On the other hand models will have 3 times more data...
I'm not concerned about individual voxels (yet), so I just open this ticket so that people knows what's going on with lighting. I don't know if this should be fixed or not.
Your how to is either out of date or incorrect for MVInport.
Is there any way you could include some demo code?
I can't seem to figure out how to use this after a few hours spent attempting to load a vox model.
When using the MVVoxMOdel script, how do you get the colors used in MagicaVoxel to show in the imported model?
I"m using Unity 5.6.1f1
I'm getting this error:
Shader error in 'Hidden/SSAO': Can't find include file frag_ao.cginc at line 59
Hi,
I'm getting back to work on my old voxel project, and first thing to do is to get it up to date with Unity and MagicaVoxel.
I thought I could work on MagicaVoxelUnity on parallel and get it working again.
Here are a few changes that come to my mind :
What do you think @darkfall ?
Unity 2017.1
when i try to recompine a selection of separated voxels, i get this error:
NullReferenceException: Object reference not set to an instance of an object MVVoxelChunk.get_sizeX () (at Assets/MagicaVoxel/Scripts/MVImporter.cs:28) MVVoxModelVoxelInspector.CombineVoxels (.MVVoxModelVoxel[] voxels) (at Assets/MagicaVoxel/Scripts/Editor/MVVoxModelVoxelInspector.cs:38) MVVoxModelVoxelInspector.OnInspectorGUI () (at Assets/MagicaVoxel/Scripts/Editor/MVVoxModelVoxelInspector.cs:20) UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1240) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Probably, because of shaders. FlatColor shader looks like solid black, when I change to StandardVertexTransp it looks similar to normal, but looks like it have z-order of faces wrong
http://i.imgur.com/oWkxVLC.png
Suggested fixes:
use tex coords instead of color:
//in cycle
var texCoords = new Vector2(cidx / 255f, 0.5f);
uv.Add(texCoords);
uv.Add(texCoords);
uv.Add(texCoords);
uv.Add(texCoords);
...
uv.Add(texCoords);
And use standard shader and a palette png that MagicaVoxel generates when exports obj.
void vert (inout appdata_full v, out Input o)
to
void vert (inout appdata_full v, out v2f o)
(i.e. do not lose vertex position along the way)
Result is still looks pretty meh, because unshaded
I have also found this shaders that seems to do the trick
Shader "Vertex Color Lit" {
Properties{
_MainTex("Base (RGB)", 2D) = "white" {}
}
SubShader{
Pass{
Lighting On
ColorMaterial AmbientAndDiffuse
SetTexture[_MainTex]{
combine texture * primary DOUBLE
}
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.