How can I dynamically update a Skylight?

SkyLight allows input from a UTextureCube: a cubemap texture. But if I render to a cubemap, that’s a UTextureRenderTargetCube. But UTextureRenderTargetCube does not derive from UTextureCube.
I can generate a UTextureCube from a UTextureRenderTargetCube, but that’s a one-off, expensive operation.
How can I dynamically update a SkyLight - using a cubemap rendertarget or otherwise?

There are a few methods for changing a sky light in game:

  • Call RecaptureSky on the SkyLightComponent from a blueprint. This will recapture the scene which will cause a hitch.
  • Use SetCubemapBlend to blend between two pre-captured cubemaps, this will not hitch.
  • Keep the cubemap constant and change the tint color

There’s no path for a skylight to reference a UTextureRenderTargetCube at the moment, but that would not be too hard to add. You would still have to call RecaptureSky on the skylight to re-process the source cubemap (build mips) which would cause a hitch.

I’ve implemented TrueSkyLight, derived from SkyLight to solve this. It amortizes the cubemap faces over frames (for reflections), and also updates the spherical harmonics coefficients (for ambient lighting). Most of the calculation is internal to TrueSky however, so it needs the plugin.

Thanks TJ, Much appreciated.

I’ve been able to modify SkyLightComponent to use either a Cubemap or a Render Target Cube. How do I submit a pull request for this?
Also, using SetCubemapBlend, if skies are dynamic, seems to mean a hitch at the changeover. Is there any way to amortize the processing over the course of the blend?
Or is there some way I can completely replace the FTexture* OutProcessedTexture and the FSHVectorRGB3 OutIrradianceEnvironmentMap, and do my own amortization?

How do I submit a pull request for this?

I haven’t done this before myself, but there seems to be some documentation here:
https://help.github.com/articles/creating-a-pull-request/

Is there any way to amortize the processing over the course of the blend?

The hitch comes from blocking the CPU during readback from the GPU, so it can’t be amortized. It can be changed to do the readback async, although that would require some refactoring of the code into two phases.

Or is there some way I can completely replace the FTexture* OutProcessedTexture and the FSHVectorRGB3 OutIrradianceEnvironmentMap, and do my own amortization?

Not out of the box, but you could write code to do it.