I there a way to allow a custom depth to foliage in unreal 4

I am still learning a lot with unreal and I would like to know if there is anyway I can get my foliage to react the same way my other objects act in the zone. I created a toon shader post processing volume and I want the foliage to shade the same way. The only I can get it to work is when I activate apply custom depth to the object but I cant seem to do that for foliage. If anyone might have a solution I would greatly appreciate it.

1 Like

Thankyou! I’m still trying to find a way to get it to work!

Hi Zeoger2000,

I have entered a feature request to expose the “Render Custom Depth” parameter to foliage actors as UE-6061. I do not have a timeframe of if or when this will be made available in the engine.

Is this still in the works?

Hi Nobody,

This is currently backlogged as our resources are dedicated elsewhere. While it still may be addressed, I would not expect this feature to be implemented any time in the near future.

Has there been any progress made on this?

This feature is desperately needed for scenes that rely on custom depth for post process effects.

I just checked in a change exposing CustomDepth properties to Foliage for 4.16.

If you can’t wait, it is a very simple code addition to expose the bRenderCustomDepth flag to foliage. The properties bRenderCustomDepth and CustomDepthStencilValue need to be copied from the UPrimitiveComponent class to the UFoliageType class. Then the FFoliageMeshInfo::UpdateComponentSettings function needs to be modified to copy these properties to the component when they are updated.

Cheers
Jack

You can create Blueprint subclassing FoliageInstancedStaticMeshComponent and set CustomDepth and stencil there, that’s how I did (check the images)

134051-rockfoliage3.jpg

1 Like

is this possible with landscape grass types? if so what are the steps to doing this?

Hi homebrata,

Could you please explain this a bit further? Specifically, what do you mean by subclassing?

For example, in my environment, I have InstancedFoliageActor as shown on the image below.

What should I do?

Thanks!

Ok, I’ve managed to find a solution.

Please see this screenshot. It seems you can select ‘Instanced foliage’ in the Get All Actors of Class node and after some conversions and casting you can get static mesh component reference.

The blueprint

The custom stencil

1 Like

On your screenshot, what is on the left and right of all of the nodes you showed, mitjaprelovsek ?

I don’t have the original blueprint in front of me, but on the left, I think there was more or less just OnBeginPlay node and on the right, there was the node that sets the custom stencil of the instanced mesh to a Random Integer in Range between 10-50.

Best answer. The right last node that cannot be seen is “SetCustomDepthStencilValue”