AssetRipper / AssetRipper

GUI Application to work with engine assets, asset bundles, and serialized files
https://assetripper.github.io/AssetRipper/
GNU General Public License v3.0
4.24k stars 561 forks source link

[Bug]: Constant IRenderer.ScaleInLightmap #592

Open Gyron777 opened 2 years ago

Gyron777 commented 2 years ago

Hello, I noticed some issues with the baked light, I made a build from your git with last changes to LightingData. Some of the objects in my scene are set is static and have light map scale parameter "Scale in Lightmap" Problem is in Scale in Lightmap always equal to 1 and scene are object is had disabled static object options.

ds5678 commented 2 years ago

You are welcome to investigate this issue and make a pull request.

ScaleInLightmap gets set in RendererExtensions.ConvertToEditorFormat, which gets called by the EditorFormatProcessor. The purpose of that processor is to set "editor-only" fields, ie fields that exist in the Unity Editor, but not in compiled game files. ScaleInLightmap is one of those fields. Without this processing, it would have its C# default value of zero.

Currently, ScaleInLightmap always gets set to 1. However, it may be possible to calculate a more appropriate value. Good luck in your investigations!

ds5678 commented 2 years ago

I just pushed 060fe0ef2de6eb7cb7627bbe02e79b30c1b77043 which elaborates on my words here.

If you have a Discord account, you should consider joining the discord server. We often have development discussions there.

Gyron777 commented 2 years ago

Thanks for the answer, I assumed a similar outcome, tell me the ScaleInLightmap parameters it should be in Scene or LightingData?

ds5678 commented 2 years ago

ScaleInLightmap is in renderer assets, ie the scene file.

Gyron777 commented 2 years ago

Thanks. It looks like there are some problems with the lightmap, after all, without my intervention, some of the objects have the uv mesh of the wrong size in the LightingData.asset What are some ideas to solve this trouble?

ds5678 commented 2 years ago

What are some ideas to solve this trouble?

Place break points to debug the issue and figure out what makes some different from others. The solution is not obvious to me when looking at my source gen (you should open AssetRipper.SourceGenerated.dll in ILSpy if you haven't already).

ds5678 commented 2 years ago

How's it going?

Gyron777 commented 2 years ago

Hello, unfortunately I could not figure this out, the objects on the lightmap still have different sizes. I don't know in which direction to work further, I'm not so good at navigating the source code of the assetripper

ds5678 commented 2 years ago

Are you in the discord server? I find it easier to have these conversations there.

ds5678 commented 2 years ago

I'm not so good at navigating the source code of the assetripper

Thankfully, this problem doesn't require much code navigation. Most of the relevant code can be found in just a couple files.

I don't know in which direction to work further

If you're not using break points, you should be. You'll have a very difficult time otherwise. The general idea is that this information is stored somewhere. A couple ideas come to mind:

The most important part is to find something that's correlated to the scaling so that you can determine how they're related.

It may help for you to build a test project and experiment with changing settings. If you encounter a binary file in the editor, they can be deserialized with the JsonSerializer.

ds5678 commented 2 years ago

@Gyron777 How's it going?

ds5678 commented 1 year ago

Perhaps 0.0512f is a more appropriate value. This is the setting used for Terrain.