Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
137 stars 2 forks source link

Cubemap creator doesn't generate mipmaps - causes mirror-like reflections #830

Open BlueCyro opened 10 months ago

BlueCyro commented 10 months ago

Describe the bug?

When creating cubemaps via the cubemap creator from Create New -> Cubemap Creator, mipmaps are evidently not generated properly for the resulting cubemap. When the resulting cubemap is used in a reflection probe, the probe can't utilize any MIP levels to respect the roughness of the material, causing everything to appear extremely smooth and shiny.

To Reproduce

Use the attached 6 images (or any 6 images) in a cubemap creator and wait for the cubemap to finish loading. Then use the resulting cubemap in a reflection probe, and note that all reflections are shiny due to the lack of mipmaps on the cubemap.

Furthermore, you can confirm this by sliding around the MIP bias or attempting to change the filtering mode on the cubemap. Observing the cubemap on an inverted sphere at harsh angles will also reveal the lack of mipmaps.

Expected behavior

The cubemap creator should generate mipmaps to the same level as the source material.

Screenshots

Pictured here is a perfectly rough, non-metallic torus inside of the influence of the reflection probe with the resulting cubemap.

2023-12-01 21 45 15

Pictured here is a close-up of the inverted UV sphere's edge, where you can notice absolutely no blurring typical of mipmapped textures.

image

Resonite Version Number

2023.11.28.1365

What Platforms does this occur on?

Windows

What headset if any do you use?

Desktop, Vive Pro Eye, Quest 2

Log Files

The following is a log file of me booting up the game, spawning a cubemap creator, importing the images, and creating the cubemap that results in no mipmaps.

DESKTOP-6C2UJFB - 2023.11.28.1365 - 2023-12-01 15_49_32.log

Additional Context

Attached here are the 6 images used in this case, as well as the cubemap file itself which I've provided for inspection. (Note that the individual images will all have proper mipmaps on their own)

Cubemap faces.zip Cubemap.zip

Reporters

Cyro, Gareth48

BlueCyro commented 10 months ago

So a little update on this after some digging: It appears in the "Create()" method on the cubemap creator that the "GetOriginalTextureData()" method that's called on the assets to retrieve each face's original bitmap data calls "GatherTextureDataAndLoad()", which then calls "DecodeFile" and passes the forceMips parameter as "false", which causes any texture returned to not have any mipmap data.

Upon setting forceMips to true (that is, only when the cubemap creator calls it), the cubemaps generated appear to gain mipmap data, albeit weirdly. Even now with the cubemaps registering their mipmaps, the problem only seems to have reduced in severity and is not entirely solved.

Pictured below is another completely dielectric & rough torus with the newly-mipped cubemap that results from the change I outlined:

image

As you can see, the torus still appears shiny, but doesn't have that mirror-like finish due to the new mipmaps taking some of the sharpness out. It seems like though the mipmaps are generated, they're generated wrongly somehow and don't crunch down far enough to match the roughness level of the torus. It appears that simply ticking the boolean I outlined won't be enough, but is most likely part of the solution to this issue. I've also attached the newly-mipped cubemap here:

The mipped cubemap is larger than github allows, so here's the resdb link for it instead (forceMips parameter = true): resdb:///9a39e0fdd08c7c0bf5749736fbdf9075d6accf00b12859f2b249bf8da3a6ac4f.cubemap

shiftyscales commented 6 months ago

Seeking input from @Geenz.