What am I missing in my Billboard material? (Per instance billboard material UE5)

I’ve been experimenting with different techniques to make a billboard material that always faces the camera. My goal is to fake a forest using billboards with trees textures displayed on a 2D plane These billboards will be foliage types that can be instanced using Unreal’s foliage tools so that the planes don’t have to be manually placed (There are more reasons for avoiding the placement of single static meshes on the scene for the billboards, but that’s not the main focus).

This is the plane I’m using, it faces the x axis:

The first technique I tried is commonly used for particle effects, which is very useful. However, it only works when I use translucent blend mode in the material. If I use another blend mode, the material, to put it simply, explodes :pensive:. This is problematic because a translucent billboard isn’t what I want, and overlapping planes produce noticeable artifacts. The following image shows the function I used for rotating the plane towards the camera:

Edit: To clarify, the output of this material function goes into the world position offset input from the material (Not sure if that needed clarifying)

These are the artifacts, and there’s also a lot of flickering when the planes are far away. This clearly shows why the translucent mode is not useful in this case:

The second technique works only with single static meshes, the idea is to fix the Z axis and calculate the direction in which the plane has to rotate to face the camera. The problem is I can’t figure out how to get the position from each plane instance instead of the InstancedFoliageActor position, this is my progress so far:

I hope someone can help me with this. I would greatly appreciate any suggestions or recommendations for a solution to this problem. Thank you in advance!

I’m proudly answering my own question here.

After spending some time debugging and testing, I finally figured out how to get the absolute position of each instance of the foliage and also their vertex positions. I’m so happy I could work this out and I hope this solution helps someone.

Important note: If you’re gonna use this same setup, make sure your InstanceFoliageActor position is set to (0, 0, 0) and Nanite is disabled on the mesh (For some reason this only works without Nanite). Also turn off “Random yaw” and “Align to normal” in the foliage type settings, otherwise you’ll have some strange rotations result.

Magic recipe:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.