slipster216 / VertexPaint

Unity 5.3 Vertex Painter
Other
906 stars 151 forks source link

Baked mesh lose existing data #11

Closed ArieLeo closed 8 years ago

ArieLeo commented 8 years ago

I'm getting this error when i'm trying to use baked mesh

Mesh doesn't have albedo UVs. Please create them in your modelling package

And maybe this case help you to investigate the problem. So i'm using 2 layer specular blend material, and painting the mask using vertex color and paint the flow direction for 2nd layer. Now in the the vertex painter window i can see that now the mesh have edited data in Colors and UV2. So i bake the mesh so i can use it as static mesh. and replace the mesh filter with baked mesh then i get that error. Still an assumption, but it seems when the mesh are baked it lose the existing unedited mesh data like UV0 and UV1. Can i request to add an option "Keep Existing Data" just beside the Save Mesh button? or maybe you can just make the existing data transferred into baked mesh by default when baking without using an option. i'm still unsure do we need a toggle for that or not.

ArieLeo commented 8 years ago

what is "Flow Drift" for actually? i cannot see any differences, or maybe just missed them

ArieLeo commented 8 years ago

The workaround for this is by removing the VertexInstanceStream component manually. Is there a way to reset the vertex stream safely? since if the component are removed i'm spammed by these error

NullReferenceException: Object reference not set to an instance of an object JBooth.VertexPainterPro.VertexPainterWindow.RevertMat () (at Assets/VertexPainterTool/Editor/VertexPainterWindow_Painting.cs:1000) JBooth.VertexPainterPro.VertexPainterWindow.InitMeshes () (at Assets/VertexPainterTool/Editor/VertexPainterWindow_Painting.cs:1009) JBooth.VertexPainterPro.VertexPainterWindow.OnSelectionChange () (at Assets/VertexPainterTool/Editor/VertexPainterWindow_GUI.cs:677) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:187) UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:180) UnityEditor.HostView.OnSelectionChange () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:135)

NullReferenceException: Object reference not set to an instance of an object JBooth.VertexPainterPro.VertexInstanceStream.Start () (at Assets/VertexPainterTool/VertexInstanceStream.cs:98)

also is there a way to automate mesh filter swap with baked mesh? just thinking if there's a lot of static mesh painted and lightmapped. Something like this maybe, it could help on artist workflow. https://www.youtube.com/watch?v=pv8wjMGGGDM Kinda make me wondering how did other engine handle vertex painting. . .

slipster216 commented 8 years ago

When you bake out a mesh, it does keep the existing data. Do you have a mesh before/after baking that displays this error that I can use to repro this?

You can clear each channel individually on the mesh using the channel UV (click on Color or UV2 to delete that channel). If you give me an exact repro I can look into suppressing those errors.

A "swap when done baking" option could be added to make the save and replace a bit faster. Though currently the tool allows you to bake several objects into one object, so that would need to be accounted for as you might have other components/code on your models.

How engines handle vertex painting is highly dependent on how they handle meshes, instancing, and serialization. For instance, in an internal engine at a previous employer, we could save meshes into scene data, which allowed us to bake the data right in the scene instead of having to save our unique painted assets for each mesh. This made the workflow much easier, as users didn't have to worry about the specifics of batching/saving/etc- they just painted the data and it baked a unique mesh into the scene for them.

ArieLeo commented 8 years ago

hmm i hope this can help MeshTest.zip Note there's should be texture missing from the material but actually i'm using the same texture as in AlphaFlowTest material