UnityGLTF icon indicating copy to clipboard operation
UnityGLTF copied to clipboard

glb files - too dark normal maps after import

Open sebastianwibergmicrosoft opened this issue 7 years ago • 4 comments

correct dark

File imports properly in other applications. In UnityGLTF the file has 118, 118, 255 as "neutral" normal color, instead of 127,127,255. This completely breaks some models, that rely on normal maps to describe geometry.

I did some research. The buffers are correct, but when using "EncodeToPNG" the texture becomes to dark. I did a test inside ConstructUnityTexture, I wrote the raw bufer to a png file, then did texture.LoadImage(...) then texture.Apply() and finally texture.EncodeToPNG. This texture ended up too dark (like illustrated above).

This sounds like it could be an srgb issue. Does changing the Unity value from gamma to linear fix the issue?

Get Outlook for Androidhttps://aka.ms/ghei36


From: sebastianwibergmicrosoft [email protected] Sent: Monday, February 18, 2019 6:52:26 AM To: KhronosGroup/UnityGLTF Cc: Subscribed Subject: Re: [KhronosGroup/UnityGLTF] glb files - too dark normal maps after import (#362)

I did some research. The buffers are correct, but when using "EncodeToPNG" the texture becomes to dark. I did a test inside ConstructUnityTexture, I wrote the raw bufer to a png file, then did texture.LoadImage(...) then texture.Apply() and finally texture.EncodeToPNG. This texture ended up too dark (like illustrated above).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKhronosGroup%2FUnityGLTF%2Fissues%2F362%23issuecomment-464759796&data=02%7C01%7Cblgross%40microsoft.com%7Cf689471047cf4ff8f9af08d695b0b3d4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636860983502060242&sdata=Y3Id%2BzyrtMjuMs6hfQN6BJlpzvejOJJ2XGeV0jC0zes%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAdqpN0xmugjcy_HDWORnrHZ91aBnPZo7ks5vOr4qgaJpZM4bA-3Q&data=02%7C01%7Cblgross%40microsoft.com%7Cf689471047cf4ff8f9af08d695b0b3d4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636860983502060242&sdata=xYQiYI9X8z9qz%2BDYyaz1wAzhxrU0PxBqlU4uJhYgdIQ%3D&reserved=0.

blgrossMS avatar Feb 18 '19 15:02 blgrossMS

It isnt a big enough change to be srgb. A conversion of that kind should put it at 90, not 118. Also, I did the write, loadimage, encode, write directly after one another, all using linear. There should be no conversion. I have seen some threads on the unity forums about encodeToPng being a nit dark as well. A solution, from our end, is to not use the encoder in unity, and instead write the raw buffer and use that. I tried and it worked perfectly.

Please update to the latest version and open a new issue if the problem persists. Thanks!

robertdorn83 avatar Feb 09 '24 08:02 robertdorn83