OCB7D2D / OcbCustomTextures

OCB Core Mod for Custom Texture Atlas - 7 Days to Die (A20) Addon
https://www.nexusmods.com/7daystodie/mods/2788
6 stars 0 forks source link

Error when loading new mod that uses this core mod #3

Closed donjon56 closed 12 months ago

donjon56 commented 1 year ago

When I drop in my new mod (leveraged your Demo pattern. changed atlas name. used only my new textures)

I am getting Graphics.CopyTexture called with null source texture errors

new-mod-added-new-game.Player.log

But all mods seem to be working. Do you know why this error is occurring? It appears to be within the OcbCustomTextures code.

Screenshot 2023-12-03 102000

(https://github.com/donjon56/7D2D-extended-painting-textures)

mgreter commented 1 year ago

Pretty sure you are not referring the correct resource in your asset bundle. Make sure your xml config and references match exactly what you exported.

donjon56 commented 1 year ago

I'd be lying if I said I know what I am doing with textures

I realized I was using the wrong version of unity when generating the Asset file.... now I do not get copy null errors.

Screenshot 2023-12-05 151851

But I am still getting the errors below. I have no idea where to go from there.

That being said.... the texture seems to be loading and it seems to be taking ambient light, so I think it is there. I am still messing with my specular to try and make sure.

Code is updated based for this one texture for now.

2023-12-05T15:10:17 29.037 INF StartAsServer 2023-12-05T15:10:17 29.337 INF Set Microsplat diffuse: MicroSplatConfig_diff_tarray (UnityEngine.Texture2DArray) 2023-12-05T15:10:17 29.337 INF Set Microsplat normals: MicroSplatConfig_normal_tarray (UnityEngine.Texture2DArray) 2023-12-05T15:10:17 29.337 INF Set Microsplat smooth: MicroSplatConfig_smoothAO_tarray (UnityEngine.Texture2DArray) 2023-12-05T15:10:17 29.366 INF Loaded (local): materials in 0.31 2023-12-05T15:10:17 29.416 INF Loaded (local): physicsbodies in 0.05 Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 131072 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 262144 bytes) Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 32768 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 65536 bytes) Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 8192 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 16384 bytes) Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 2048 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 4096 bytes) Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 512 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 1024 bytes) Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 128 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 256 bytes) Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 32 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 64 bytes) Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 8 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 16 bytes) Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 8 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 16 bytes) Graphics.CopyTexture called for entire mipmaps with different memory size (source (RGB Compressed DXT1|BC1 sRGB) is 8 bytes and destination (RGBA Compressed DXT5|BC3 sRGB) is 16 bytes) 2023-12-05T15:10:18 30.021 INF Release: ta_opaque_0 (UnityEngine.Texture2DArray) 2023-12-05T15:10:18 30.021 INF Set Opaque diffuse: extended_ta_opaque_0 (UnityEngine.Texture2DArray) 2023-12-05T15:10:18 30.021 INF Release: ta_opaque_n_0 (UnityEngine.Texture2DArray) 2023-12-05T15:10:18 30.021 INF Set Opaque normal: extended_ta_opaque_n_0 (UnityEngine.Texture2DArray) 2023-12-05T15:10:18 30.021 INF Release: ta_opaque_s_0 (UnityEngine.Texture2DArray) 2023-12-05T15:10:18 30.021 INF Set Opaque MOER: extended_ta_opaque_s_0 (UnityEngine.Texture2DArray) 2023-12-05T15:10:18 30.023 INF Loaded (local): painting in 0.61 2023-12-05T15:10:18 30.524 INF Loaded (local): shapes in 0.50

donjon56 commented 1 year ago

Normal looks right based on your images... but basecolor/diffuse... looks a little different on my machine.

Screenshot 2023-12-05 160903 Screenshot 2023-12-05 160919

donjon56 commented 1 year ago

Maybe this is the missing piece?

About Specular: This (DXT5 sRGB) texture uses all four channels to carry material parameters:

Specified Light Map and rebuilt asset file..... no errors now.

Are these setting correct, or should I use different setting for the specular texture file? image

mgreter commented 1 year ago

"Specular" uses the same format as the diffuse texture. Easiest way to get started is to check the unity demo project here: https://github.com/OCB7D2D/OcbCustomTexturesPaints/tree/master/Unity/CustomPaintDemo You are already on the right track. If unity chooses a different format for export it may be due to your project settings. Lightmap type seems very wrong, it may export in the expected texture format, but no idea what else it will do to it. Also make sure you do not overrule the automatic format in the other tabs there (windows, mac etc).

donjon56 commented 12 months ago

Ok... Seems that if you set Alpha Channel to 255 in your Texture Packer the resulting specular image will encode to DXT1... If I just set it back to 254 then the resulting image is encoded to DXT5...

I really appreciate your input and responses.

Thank you so much for your help and a cool base mod.

Having fun trying some texture ideas out....

Full metallic paint:

Screenshot 2023-12-05 171351

mgreter commented 12 months ago

Ok... Seems that if you set Alpha Channel to 255 in your Texture Packer the resulting specular image will encode to DXT1... If I just set it back to 254 then the resulting image is encoded to DXT5...

Thanks for that input! I think that makes sense in terms of unity trying to optimize the export format, as when all alpha values are 255, the texture certainly isn't transparent, thus not needing an alpha channel, thus unity deciding to actually use a format that doesn't have an alpha channel. Will check this and try to update the docs accordingly in the future. Given that assumption is true, it may be better to recommend to force the right format via overrules in that case. Although your solution also works. But seems to be something other users may hit too, so seems worth noting. (Edit: verified that changing alpha to 255 indeed changes export format). In the end, great you could figure it out!

Edit2: Seems I may have been wrong by assuming diffuse and specular need the same export format!? Can you confirm that diffuse DXT1 (no alpha channel) and "specular" DXT5 (with alpha channel) works?

Edit3: Could you confirm that this setting would also work if you set alpha to 255? image

donjon56 commented 12 months ago

I don't think there is a "specular" option, but using nearly the same options as Diffuse does export DXT5 and seems to work properly. Just a flat 255 on the Alpha channel, or if you set Alpha Source to None, causes DXT1 export format for specular

This setting seems to work fine: Screenshot 2023-12-06 072248

Screenshot 2023-12-06 071820

However, using Lightmap texture type instead of Default seems like it will have unintended consequences as it appears different in AssetStudio even though the settings seems to be the same

Screenshot 2023-12-06 071752

Setting to 255 Alpha, Forcing override to 512 and DXT5 format did work. Specular Texture loaded with no errors and was indeed flat with no reflections

Screenshot 2023-12-06 073719

Screenshot 2023-12-06 073625