Download

Remove clamping from cubemap for textures?

So I was trying to create a custom skybox from a cubemap (DDS format) and driving myself up the wall because UE was stretching my texture when I applied it to my sphere. Also, I don’t think it would be easier to procedurally generate it because of the type of sky I want and also because I can’t find any sort of tutorial on that at the one procedurally generated sky in the Content Example isn’t what I’m looking for so it’s hard to learn by imitation in this case as well. Plus, if we do limit skyboxes to procedurally generated ones, what about custom-drawn skies or real-life photos?

I ran across this thread:

Where halfway down someone mentioned the 512x512 resolution UE forces on any textures during the import process as well as how to change it. So I dug into my .cpp file and found the function:

static int32 ComputeLongLatCubemapExtents(const FImage& SrcImage, const int32 MaxCubemapTextureResolution)
{
return FMath::Clamp(1 << FMath::FloorLog2(SrcImage.SizeX / 2), 32, MaxCubemapTextureResolution);
}

As you can see, it’s not hard-coded to 512 anymore, however, I’m still getting the same problem (namely stretching of the texture). It was 2AM and I (APPARENTLY CAN’T READ CODE HALF-ASLEEP edit) The size is being passed in as an input now, but I’m still getting the same stretching problem as before and I have not dug deep enough to figure out where the function gets called in the compression process to actually see how that input parameter is generated. My actual texture isn’t that big (1087x543 according to the editor). The dimensions are a bit odd since I exported it directly from the cubemap generator, but the other person I was talking to in the thread below had a 2048x1024 image that had the same issue.

We’ve been trying to figure it out over here:

https://answers.unrealengine.com/questions/222093/skybox-stretching-texture.html

For the time being I’m just going to hard-code it to 2048 and hope that solves the issue but does anyone know if this was actually fixed? And if it was, is there something we have to do in the material/texture editor to get it to take effect. From what I can see, UE imports the DDS/HDR file just fine as a texture (it doesn’t lose much resolution) and it even looks good in the material editor preview. Just not in-game.

EDIT: I am an idiot who cannot read code. Also my change to the code does not seem to have done anything. The problem is with the DDS format it seems since imported a random PNG image and the Max In-Game size was 1024x576 while the DDS one was stuck at 512x512. Unfortunately I don’t have an HDR map so I could just convert it to a 2048x1024 JPG image but I’m going to start looking for a way

MaxCubemapTextureResolution must be coming from elsewhere in the code.

FWIW, you can open the texture properties and expand “Compression” and then type a “maximum texture size” value there. It will unfortunately still clamp to 2048 but that is better than 512.

So part of it was probably me not using a power of two, but thank you for telling me about where I could set maximum texture size. That worked!

Also, it might have been a problem with Nvidia since I uninstalled and reinstalled the plugin and finally the larger files weren’t being clamped. I didn’t change anything else though (used the same image to create a cubemap) so that was odd. Importing the DDS file took forever though (20 minute!).

The cubemapgenerator I was using is still being forcibly clamped until I change it in the editor, but that solves all my issues for now. Thanks again.