Timeline for Mipmaps and LOD Behavior in Skybox Shaders
Current License: CC BY-SA 4.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 15 at 8:42 | vote | accept | Ahmed Dyaa | ||
| Aug 14 at 16:35 | comment | added | DMGregory♦ | No, Unity doesn't select the mipmap level that gets sampled. Unity uploads to the GPU the full mip chain up to some maximum size (set by your quality settings / streaming if you're using it). The GPU selects which mipmap level to use for each individual texture fetch (per pixel), based on screenspace derivatives. With a 512x512 cubemap, that means it's probably going to be reading the highest resolution mip at all times, unless your screen/window/render target is quite small. | |
| Aug 14 at 13:47 | comment | added | Ahmed Dyaa | But how will mipmaps work with a texture in the skybox? In other words, Unity chooses the appropriate mipmap level based on: The distance between the camera and the mesh that carries the texture, The viewing angle or the size of the texture on the screen. So, how does this apply to a texture in the skybox? | |
| Aug 14 at 13:47 | comment | added | Ahmed Dyaa | Thank you, I followed your method, adjusted the image, set the cubemap resolution to 512x512, and measured the performance. I found a slight performance improvement for the cubemap compared to a 2D texture. | |
| Aug 14 at 11:34 | comment | added | DMGregory♦ | Why would you need to unwrap it? Just call texCube to sample it with your direction vector, or beter yet, use one of the built-in skybox shaders that already works with cubemaps out of the box. If you mean "How can I use an image that's just the top half of a sky?" (a sky dome), then you can open that image in a photo editor, double its height, and fill the bottom half with colour or stretch the row of pixels at the horizon over the rest. Then you can import it as a normal full sphere, not a dome. This cuts into the memory advantage but you keep the sampling benefits. | |
| Aug 14 at 10:06 | comment | added | Ahmed Dyaa | How can I unwrap a cubemap the same way I do with a Texture2D in the code I’m using? | |
| Aug 13 at 20:39 | comment | added | DMGregory♦ | What leads you to believe that a cubemap would have a higher memory footprint than a texture2D? Let's say you have a 1024x512 panorama. A cubemap with sides 256x256 uses only 3/4 as much memory, and still gives better worst-case angular resolution. Have you measured the performance impact of this alternative? | |
| Aug 13 at 19:25 | comment | added | Ahmed Dyaa | Thank you for the clear answer. The reason I’m using a Texture 2D instead of a Cubemap is that I’m targeting mid-range phones, and a Cubemap would cost me more than a Texture 2D and require more memory. If there’s a way to use a Cubemap without a performance loss, I will certainly follow it. | |
| Aug 13 at 19:13 | history | edited | DMGregory♦ | CC BY-SA 4.0 | Elaborating |
| Aug 13 at 16:33 | history | answered | DMGregory♦ | CC BY-SA 4.0 |