I wanted to take some time and consolidate my findings on the problems related to Ray Tracing and Foliage painted instances. This is important to me since I have released several foliage Asset Packs on the Marketplace and I want to be clear for users on the limitations when using the nvidia RTX technologies with Foliage placed assets. There are numerous forum posts on the issues but it takes some time to sort through them and figure out what's really going on and what choices you have as a developer to get the best results.
All the differences that really matter involve shadows and the Sub-Surface properties of the Two Sided Foliage shader. There are some key differences, not just when using Ray Tracing vs. Cascading Shadow Maps (CSM), but even between the Ray Tracing options in 4.26 vs, earlier releases.
To start with, at this time, the best shading results with large, foliage painted scenes where the Foliage Instances are using the Two-Sided Foliage Shader are with old school CSMs, .....depending on how picky you are. This involves disabling Ray Tracing Shadows altogether on your primary Directional Light source, globally for the whole scene. Obviously not the solution most of us want to hear. But until Unreal can create a solution for the limitations in Ray Tracing and the Two Sided Foliage Shader, this is the only option I have found.
For the purposes below, I am assuming a generic setup as you would get by starting a new level, creating a landscape and painting some foliage onto it. In addition, the primary Directional Light has been set to "Movable" as is the recommended workflow for a large environment. I am not dealing with a Static Light source, trying to bake foliage shadows into a large environment scene.
Sub Surface Issues:
Lets take a look at 2 renders, one using CSM and one using Ray Tracing Shadows. Note that the 2 are currently mutually exclusive. If you have Ray-Tracing Shadows enabled, adjusting CSM properties makes no difference. They are not being used. The material assigned to the low poly Aspen tree model is of course a Material Instance and the Master Material has "Cast Ray Traced Shadows" enabled and is using the Two Sided Foliage shading model.
Aspen Tree Render, Ray Tracing Shadows enabled |
As you can see in the above rendering, the Sub Surface attributes of the Two Sided Foliage shader are not being computed when using Ray Traced Shadows.
Now the exact same shot, but with Ray Traced Shadows disabled:
with Ray Traced Shadows disabled, shadows are computed using Cascading Shadow Maps and now we see the Sub Surface properties of the Two Sided Foliage Shader. |
Obviously the look with Sub Surface properties rendered is more what we want and expect. Rendering Sub Surface properties with Ray Traced Shadows enabled is not currently possible up to version 4.26. I refer to this forum post for the explanation where Epic Staff member YuriyODonnell writes on 4/24/20 in version 4.25 at the time:
"In general, there are some limits to how ray tracing works with subsurface scattering. Shadow maps are currently required for certain effects (such as transmission) to work correctly. This is because ray traced shadows work by starting a ray at the receiving surface and tracing it toward the light. Shadow maps do the opposite: start from light and "trace" towards scene. Shadow maps therefore allow us to approximate object thickness.
My gut feeling is that a shadow map will be required to achieve the subsurface look you are after (i.e. shadow maps would still need to be rendered even when RT shadows are on, but only used for SSS). Perhaps a specialized path can be also implemented using ray tracing, but no work has been done on this specifically so far."
One possible solution that comes to mind is to disable the "Cast Ray Traced Shadows" option on the material itself. Then perhaps as we've seen with the the Scene light option, the foliage will now use CSMs for its shadows:
"Cast Ray Traced Shadows" disabled on the material
At first glance in this render that seems to work:
Ray Traced shadows disabled on the material but enabled for the scene light
Unfortunately this currently results in the foliage casting no shadows whatsoever:
Ray Traced Shadows disabled on the Material but enabled in the scene results in no shadows at all for objects with that material.
As in the above forum post response, perhaps a separate path could be used in the future such that objects with materials using SSS will be rendered using CSM while all others would still use Ray Tracing if enabled.
Cascading Shadow Maps only for the scene light, no Ray Tracing.
As it stands, you will have to decide whether the benefits of Ray Tracing for your scene outweigh the benefits of Sub Surface rendering on your foliage. The foliage still renders OK with ray tracing, but granted, the look is not as realistic. Let's hope for a good solution in the future.
One major problem I had with my scenes when transitioning to Ray Tracing versions of Unreal Engine versus the earlier versions prior to RTX was somewhat common, but with one critical omission from any of the forum posts I could find. I'm guessing this problem is a little too new with 4.26 being a relatively recent release and developers having already solved their shadow problems based on the above issues.
My scene renders as expected in in 4.25 except that the shadows only go so far into my foliage before they disappear. This has been a known issue discussed on several forum posts. I will be referring to this post in particular regarding Ray Traced Shadows on Foliage actors in 4.24. But this issue is valid in 4.25 as well as 4.26 as I will discuss.
In release 4.25 below is a render from a scene built in 4.18 (no RTX) but opened in 4.25 with Ray Tracing enabled:
Ray Traced Shadows enabled but "Culled" by default
The simple solution to this problem is to invoke a CVAR that disables the Culling of the Ray Traced Shadows. Open a command console type-in field and enter this:
The results here:
Ray Traced Shadows on Foliage painted actors in UE 4.26 with default settings |
What I get here is even more bizarre, with random actors casting shadows and in fact, as I navigate about the scene the shadows come and go with seemingly no rationale. Sometimes as I get closer the shadows vanish on a tree. Sometimes vanishing as I orbit or even just pan. The shadows come and go on seemingly random trees having nothing to do with culling distance.
So the Solution! Let's invoke the CVAR from above: "r.RayTracing.InstancedStaticMeshes.Culling 0"
UE 4.26 with CVAR: "r.RayTracing.InstancedStaticMeshes.Culling 0" |