soupday / cc_unity_tools_3D

Package for importing and auto setup of Character Creator (3 & 4) and iClone (7 & 8) character exports for Unity Built-in (3D) Pipeline.
Other
65 stars 19 forks source link

Bake is failing #28

Closed liudger closed 2 days ago

liudger commented 1 year ago

When trying to bake a character this error appears and the bake stops. Not sure yet wat caused the missing value. The build materials seems to work fine. No errors. Any thought where I need to look for solving this issue?

Regards Willem-Jan

ArgumentNullException: Value cannot be null.
Parameter name: texture
UnityEngine.ComputeShader.SetTexture (System.Int32 kernelIndex, System.String name, UnityEngine.Texture texture) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Shaders/ComputeShader.cs:33)
Reallusion.Import.ComputeBake.BakeThicknessMap (UnityEngine.Texture2D thickness, System.Single thicknessScaleMin, System.Single thicknessScale, UnityEngine.Color subsurfaceFalloff, UnityEngine.Texture2D baseMap, System.Boolean invertMap, System.String name, System.String kernelName) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ComputeBake.cs:2175)
Reallusion.Import.ComputeBake.BakeSkinMaterial (UnityEngine.Material mat, System.String sourceName) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ComputeBake.cs:803)
Reallusion.Import.ComputeBake.BakeMaterials (System.Boolean hairOnly) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ComputeBake.cs:353)
Reallusion.Import.ComputeBake.BakeHQ () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ComputeBake.cs:279)
Reallusion.Import.ImporterWindow.BakeCharacter () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:1171)
Reallusion.Import.ImporterWindow.OnGUI () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:372)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at /Users/bokken/buildslave/unity/build/Editor/Mono/HostView.cs:442)
UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:387)
UnityEditor.DockArea.OldOnGUI () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:378)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:372)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:687)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:659)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:652)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:618)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:607)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:535)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/Events/EventHandler.cs:151)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/Events/MouseCaptureDispatchingStrategy.cs:88)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:381)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:344)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:306)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:270)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:75)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:372)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:222)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/Panel.cs:417)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:468)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:211)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:74)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:28)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
soupday commented 1 year ago

Looks like it's failing because of a missing diffuse map (Base Map) in a skin material.

soupday commented 1 year ago

I'll put more checks in to fall back to default/blank textures when one is found to be missing.

(I've also added some error warnings on the Build Materials, when there should be a texture there for a material, but it can't be found. Still working on the URP and 3D versions)

liudger commented 1 year ago

Thanks for the quick responses. I didn't have the original shaders on the character. In the first instance. That could have been the problem? With the fbx straight from reallusion I got this error while building the materials.

Unable to find json material data: CC_Base_Body/Materials/Default-Material
UnityEngine.Debug:LogError (object)
Reallusion.Import.Util:LogError (string) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/Util.cs:926)
Reallusion.Import.Importer:ProcessObjectBuildPass (UnityEngine.GameObject) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/Importer.cs:386)
Reallusion.Import.Importer:ProcessObjectTreeBuildPass (UnityEngine.GameObject) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/Importer.cs:333)
Reallusion.Import.Importer:Import () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/Importer.cs:253)
Reallusion.Import.ImporterWindow:ImportCharacter (Reallusion.Import.CharacterInfo) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:1023)
Reallusion.Import.ImporterWindow:BuildCharacter () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:1140)
Reallusion.Import.ImporterWindow:OnGUI () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:368)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

The json looks like this:

Renita_Reallusion.json.zip

I'll test some more characters today.

liudger commented 1 year ago

I got also warning before this error. This is I guess when you set the fbx material creation mode.

Importer(FBXImporter) generated inconsistent result for asset(guid:fa594fc0caa254b6095b09b072aec465) "Assets/CC_Assets/CC_utility/Renita_reallusion/Renita_Reallusion.Fbx"
UnityEngine.StackTraceUtility:ExtractStackTrace ()
RLPlugin.RLEditor:OnPostprocessAllAssets (string[],string[],string[],string[]) (at Assets/Editor/RLEditor.cs:942)
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[],bool)
Reallusion.Import.Importer:Import () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/Importer.cs:234)
Reallusion.Import.ImporterWindow:ImportCharacter (Reallusion.Import.CharacterInfo) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:1023)
Reallusion.Import.ImporterWindow:BuildCharacter () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:1140)
Reallusion.Import.ImporterWindow:OnGUI () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:368)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

unity 2021.2.4f1

soupday commented 1 year ago

That's unusual. It looks like there is a material missing from the FBX.

Basically the importer takes the base materials defined in the FBX, matches them with the data in the JSON and uses that to set up the material correctly.

But it looks like you've got an extra material slot, without a corresponding material, so the importer doesn't know what to do with it. Unity has filled the empty material with the 'Default-Material', which has no textures, which is why the bake fails.

Judging by that FBX import warning, the FBX file itself is either corrupt, or Unity just doesn't like it.

What export settings are you using?

soupday commented 1 year ago

It's also possible that one of the clothing items is broken in some way.

There have been cases where a clothing item has corrupt UV maps which cause import errors as the FBX data was corrupted. The old Punk Vest in CC3 did this, and caused no end of problems. But it worked find in Character Creator.

liudger commented 1 year ago

I am gonna try it in a clean project. This could have been the issue

liudger commented 1 year ago

I am sorry. It was something in the project that broke the fbx material import. It works now without problems! Still the bake has the same error in a clean project. Tested multiple characters.

ArgumentNullException: Value cannot be null.
Parameter name: texture
UnityEngine.ComputeShader.SetTexture (System.Int32 kernelIndex, System.String name, UnityEngine.Texture texture) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Shaders/ComputeShader.cs:33)
Reallusion.Import.ComputeBake.BakeThicknessMap (UnityEngine.Texture2D thickness, System.Single thicknessScaleMin, System.Single thicknessScale, UnityEngine.Color subsurfaceFalloff, UnityEngine.Texture2D baseMap, System.Boolean invertMap, System.String name, System.String kernelName) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ComputeBake.cs:2175)
Reallusion.Import.ComputeBake.BakeSkinMaterial (UnityEngine.Material mat, System.String sourceName) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ComputeBake.cs:803)
Reallusion.Import.ComputeBake.BakeMaterials (System.Boolean hairOnly) (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ComputeBake.cs:353)
Reallusion.Import.ComputeBake.BakeHQ () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ComputeBake.cs:279)
Reallusion.Import.ImporterWindow.BakeCharacter () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:1171)
Reallusion.Import.ImporterWindow.OnGUI () (at Library/PackageCache/com.soupday.cc3_unity_tools@eb2942ae9a/Editor/ImporterWindow.cs:372)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at /Users/bokken/buildslave/unity/build/Editor/Mono/HostView.cs:442)
UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:387)
UnityEditor.DockArea.OldOnGUI () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:378)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:372)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:687)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:659)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:652)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:618)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:607)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs:535)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/Events/EventHandler.cs:151)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/Events/MouseCaptureDispatchingStrategy.cs:88)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:381)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:344)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:306)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:270)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:75)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:372)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:222)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/Panel.cs:417)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:468)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:211)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:74)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:28)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
soupday commented 1 year ago

I have a fix incoming for this. So it won't be a problem for much longer.

liudger commented 1 year ago

Thanks for the update. I am on the latest dev version. There is still something going wrong. The bake doesn't error, but it looks like there is an issue with the head texture that is lost in the bake. image it tries to load the local path instead of relative it looks like?

Invalid AssetDatabase path: /Volumes/GitRepos/Git/internal-character-setup/Assets/characters/Timothy_reallusion/Baked/Timothy_Reallusion/Textures/Std_Skin_Head_Pbr_BaseMap.png. Use path relative to the project folder.
UnityEditor.AssetDatabase:LoadAssetAtPath<UnityEngine.Texture2D> (string)
Reallusion.Import.ComputeBakeTexture:SaveAndReimport () (at /Users/liudger/Talespin/Git/cc_unity_tools_3D/Editor/ComputeBakeTexture.cs:126)
Reallusion.Import.ComputeBake:BakeHeadDiffuseMap (UnityEngine.Texture2D,UnityEngine.Texture2D,UnityEngine.Texture2D,single,single,single,single,string) (at /Users/liudger/Talespin/Git/cc_unity_tools_3D/Editor/ComputeBake.cs:1771)
Reallusion.Import.ComputeBake:BakeSkinMaterial (UnityEngine.Material,string) (at /Users/liudger/Talespin/Git/cc_unity_tools_3D/Editor/ComputeBake.cs:704)
Reallusion.Import.ComputeBake:BakeMaterials (bool) (at /Users/liudger/Talespin/Git/cc_unity_tools_3D/Editor/ComputeBake.cs:352)
Reallusion.Import.ComputeBake:BakeHQ () (at /Users/liudger/Talespin/Git/cc_unity_tools_3D/Editor/ComputeBake.cs:278)
Reallusion.Import.ImporterWindow:BakeCharacter () (at /Users/liudger/Talespin/Git/cc_unity_tools_3D/Editor/ImporterWindow.cs:1196)
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()
soupday commented 1 year ago

Are you characters stored outside the projects? Linked folders or hard links?

liudger commented 1 year ago

Nope none of this. I'll try to debug why this is happening. I did another bake and now the face texture did show up. image

liudger commented 1 year ago

Found the issue and made a pull request #33 bake is now creating correct files in bake folder. Before it was empty

liudger commented 1 year ago

there is still a small issue :) image It changed the color of the texture while baking. Any idea?

soupday commented 1 year ago

There were a few other places I've updated that needed alternate path separator support too.

Now then why is the hair turning white?

What material shader(s) is on the hair of the original character? Does it have a full set of textures?

If you could attach the .json file for that character it might shed some light on the problem.

liudger commented 1 year ago

It looks like the texture bake is changing the color. image It's the shader that is assigned by the tool when building materials. (Maybe again a mac specific issue?) I'll have a look if there are any differences when writing texture platform wise. I know directx does things differently. We had some issues with normal maps before (our own baker tool) on windows builds when it was using directx.

soupday commented 1 year ago

That looks like a color space issue. What color space is the project in? And are the diffuse textures for the hair sRGB?

liudger commented 1 year ago

Just a small update.

I tried the latest, but now also the head has a lighter color. (so maybe you know what changed between 1.4.1 and 1.4.2?) Everything is sRGB. Just default from Reallusion. I hadn't much time to test and go through the code. I'll continue exploring when I got time. image

soupday commented 1 year ago

The bake function wasn't replacing all the materials, just the hair. Which is why is seemed only the hair was affected, now it's all the baked materials. So the skin on the head, the eyes, the teeth and tongue should also be too bright too.

So firstly check the project is set to linear color space:

cs

(It looks like it is, otherwise everything else would also be too bright)

So I think the problem is most likely due to a difference in the compute shader render texture colour space on the various platforms. Windows renders in Linear colour space so I have to do the linear to sRGB color conversion for diffuse texture maps within the compute shader.

But it looks like on the Mac, this colour space conversion is done automatically, or is redundant as it's already in sRGB colour space. In which case the sRGB conversion is done twice, making the diffuse map textures look far too bright.

If you're up for a bit of tinkering: In the compute shader code (Packages: CC/iC Unity Tools 3D /Editor/Compute/RLBakeShader.compute)

replace the function LinearTosRGB at line 307 to:

float4 LinearTosRGB(float4 In)
{
    return In;
}

This should stop the diffuse map colour space conversions.

liudger commented 1 year ago

Yes this fixed the issue. It looks all fine now. So we need to change this function also with a platform aware switch

soupday commented 1 year ago

How about this as an alternative.

float4 LinearTosRGB(float4 In)
{
#ifdef UNITY_COLORSPACE_GAMMA
    return In; 
#else
    float3 sRGBLo = In.xyz * 12.92;
    float3 sRGBHi = (pow(max(abs(In.xyz), 1.192092896e-07), float3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
    float3 sRGB = float3(In.xyz <= 0.0031308) ? sRGBLo : sRGBHi;
    return float4(sRGB, In.a);
#endif
}

If not I will have to set my own shader keywords based on the platform.

liudger commented 6 months ago

Hi Victor,

Sorry for the really long delay. We weren't using this tool yet. But now it looks like we are going to use it for a new demo.

The last solution isn't working. I am now also working in URP. The colourspace is linear so

float4 LinearTosRGB(float4 In)
{
    return In;
}

this is working,

But this isn't

float4 LinearTosRGB(float4 In)
{
#ifdef UNITY_COLORSPACE_GAMMA
    return In; 
#else
    float3 sRGBLo = In.xyz * 12.92;
    float3 sRGBHi = (pow(max(abs(In.xyz), 1.192092896e-07), float3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
    float3 sRGB = float3(In.xyz <= 0.0031308) ? sRGBLo : sRGBHi;
    return float4(sRGB, In.a);
#endif
}

I guess we need to set our own keywords base on platform. There were no other Mac users?

liudger commented 4 months ago

@soupday I created a fix in URP branch. Let me know if this works for you?