Ghislain Girardot Profile picture
Indie Game Developer and Unreal Engine Content Creator. Worked on Spyro: Reignited Trilogy and Shardbound.

Jan 14, 2023, 14 tweets

#UnrealEngine #UE4 #UE5 #UETips
Here's one WPO trick I used to create this night sky.

The challenge was to create subtle per-star lens flares that would always face the camera and remain straight, exactly like billboards. 🧵⬇️

To create star billboards, each star would need to rotate around their own pivot point to face the camera but pivots are all lost once exported to a single mesh... :(

... I could bake pivots in UVs but that'd actually be overkill here! I don't actually care about the precise XYZ position of each star... 🧐

... A direction will do just fine! And because I'm using an unlit additive material, mesh normals served no purpose. So I could actually encode that direction into normals :)

For this I created a simple Blender script that takes each star's position, normalize that position and store the resulting direction into custom normals.

Once that was done, I reset their location back to (0,0,0) and exported that pile of stars all stacked on top of each other.

I also encoded a simple 0 and 1 value in a secondary UVMap to differenciate the star main quad from the lens flare quads to differenciate those two in engine, and sort-of create two shaders in one using a simple boolean mask to drive a few lerps.

A random value was also assigned per-star and stored in the remaining UV channel to drive some shader logic (brightness, tint, size...) and bring character and randomness to the night sky.

Once in engine I could simply scale stars using a multiply because they all were centered at 0,0,0 to begin with :)

I could even scale the lens flare separately using that value encoded in UV to create a mask.

I could then use a simple transform node from view space to world space to turn stars into billboards for two reasons
1) stars were all centered at 0,0,0 so that would make them all pivot around that shared pivot point 👍
2) stars were all made to face negative Z👍

If you're feeling a bit lost with all those WPO tricks, feel free to give my previous YT video a watch:

I then used the direction encoded in their normals to push them far far far away in the desired direction *once* the WPO billboard & scale tricks were applied.

All I needed to do still was to fade those lens flare the straighter we look at those stars...

... and fade them in & out based on sun light's altitude. And voilà!

There's more tricks like that explained in my breakdown video, give it a watch if you will :)



Cheers, enjoy your weekend!

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling