Rendering a dynamic moon texture on skybox.

So, I’ve previously attempted to create a moon texture added to the skybox, and this worked nicely, as long as the moon does not move. I had it set up to deal with occlusion correctly (clouds > moon > stars), and it provided lighting in the scene. Now, I’d like to create a blueprint and material that allows two separate directional lights, one for the moon, one for the sun, and create the sky material to match. The sun disc is easy, as that’s just a simple circle projected onto the skybox, and already built into the standard skybox (which I’m using as a base). The moon disc, however, is more complex. I’m not just creating a bright circle, but a textured object (for my purposes, I can’t just use a circle, either). I’ve managed to get this texture to follow the directional light, but because it’s projected onto a sphere, I can’t seem to keep a consistent shape and size.

I’ve seen people produce skyboxes with moon discs everywhere, and it’s such a commonly needed feature that I can’t help but think I must be doing something wrong. How can I render a texture onto the sky sphere such that:

  1. It remains a consistent shape and reasonably consistent size regardless of position
  2. I can move it around at will be changing the direction vector parameter
  3. It will occlude stars, and be correctly occluded by clouds (this rules out using a decal or 3D shape)

I can’t seem to get a system that allows all three at once. I’ve produced systems that give me any two of these, but I really need one that allows all 3. Can someone help?

Aha! I’ve finally worked it out. I was trying to do this all manually, but as it turns out, there’s a “SkyboxImage” material function, which correctly maps a texture to the skybox, at a given direction vector. This proved relatively straightforward to work with after that.

Do you care to explain your solution here? I’m having a similar problem.

Using the SkyboxImage node (which correctly renders an image onto the skydome, under the condition it stays in the top half of the done), and trial and error based around the code in the built-in skybox sun rendering, I managed to create the correct set of UVs to draw the image where I wanted it. Primarily, it involves making a copy of the sun script, and replacing the circle with a SkyboxImage.

I tried that approach myself, but it always seemed to be displaced from where I expected my vector (based on a directional light) to be. I think I found something that works though. I made these changes to the ImageVectorInput on the SkyboxImage function and it seems to align properly now.

I’ve tried your both solutions but the texture of the moon always moves. I think my UVs are wrong. Can you help ?

I tested a method to add a moon to skysphere with a texture and texture doesn’t move with the time of day system in place. I made a small video to show the process, coz its easier to showing than explaining in text