Generating Ray-Traced Caustic Effects in Unreal Engine 4, Part 1

Originally published at: https://developer.nvidia.com/blog/generating-ray-traced-caustic-effects-in-unreal-engine-4-part-1/

Caustics are common optical phenomenon in the real world. From the sloshing sparkles by water surfaces to the curved highlights in the backlight of clear glass, they are everywhere. However, simulating accurate caustic in 3D graphics is not an easy job. For those who have been involved in creating ray tracers, you might know that…

  • If you get a 404 error when visiting the github NVRTX_Caustics repo, please ensure that you have signed in github and registered your github account at UE official page:

It will grant you the access to Epic’s official UE4 repos and NVIDIA’s folks.

  • The NVRTX_Caustics branch of UE4 is based on the UE4.25.3 NVRTX branch. The upgrade for 4.25.4 and 4.26 will be available soon.

  • The sample scenes used in this post can be found at the following places:

Executable demos: Tech_Demos - Google Drive

Assets and projects: Demo_Projects - Google Drive

If you have any question on the algorithms, source, performance and usages of mesh caustics, please ask here.

3 Likes

Do you have any plans to fix the bug that translucent objects are displayed incorrectly in reflections?
And what about ray tracing subsurface scattering?
Looking forward to your reply. Thx!

To show translucent objects in reflections, you can use the following command lines to enable full binary tree of reflection+refraction bounces, which allow the refractions to be seen in reflections:

  • r.RayTracing.Reflections.ReflectedTranslucencyMode - Sets the method to render the reflected translucent objects (default 0)
    • 0 - emissive only
    • 1 - enable shading
    • 2 - enable shading & refraction
    • 3 - enable shading, refraction & absorption
  • r.RayTracing.Reflections.ReflectedTranslucencyMaxBounces - Sets the maximum number of ray traced translucency bounces (default 8)
  • r.RayTracing.Reflections.ReflectedTranslucencyTransmissionThreshold - Stops ray traced translucency process if the accumulated transmission is lower than this threshlod (default 0.1)

Ray tracing subsurface scattering is still under researching stage. We are working behind it now.

1 Like

Has anyone seen this make error before with the NvRTX_Caustics-4.26 branch?

What could be the fix?

[2/613] Compile Module.Engine.35_of_48.cpp
In file included from /mnt/2.26/Engine/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/Engine/Module.Engine.11_of_48.cpp:11:
/mnt/2.26/Engine/Source/Runtime/Engine/Private/Components/LightComponent.cpp:321:4: error: field ‘bTiledDeferredLightingSupported’ will be initialized after field ‘bAffectWaterCaustics’ [-Werror,-Wreorder-ctor]
, bTiledDeferredLightingSupported(false)
^

Ubunbtu Linux Kernel 5.4.0-66-generic
NVIDIA Driver Version: 460.73.01
CUDA Version: 11.2, and an RTX 3090

Thanks in advance,
Gregory

Reporting back that building on Windows with different hardware produces the exact same errors. I wonder how people are successfully building this?

This error message is indicating that the field ‘bTiledDeferredLightingSupported’ is being initialized after the field ‘bAffectWaterCaustics’, which is causing a reordering of the constructor initialization list.

A possible fix for this issue would be to reorder the fields in the constructor initialization list so that ‘bAffectWaterCaustics’ is initialized before ‘bTiledDeferredLightingSupported’.

Here’s an example of how the constructor could look after making this change:

LightComponent::LightComponent(const FObjectInitializer& ObjectInitializer)
    : Super(ObjectInitializer)
    , bAffectWaterCaustics(false)
    , bTiledDeferredLightingSupported(false)
{
}

I downloaded NvRTX_Caustics-5.1 source code and Ran Setup.bat.
Then It showed below error.

Checking dependencies…
Updating dependencies: 0% (0/97588)…
Unhandled exception. System.PlatformNotSupportedException: Thread abort is not supported on this platform.
at System.Threading.Thread.Abort()
at GitDependencies.Program.DownloadDependencies(String RootPath, IEnumerable1 RequiredFiles, IEnumerable1 Blobs, IEnumerable1 Packs, Int32 NumThreads, Int32 MaxRetries, Uri Proxy, String CachePath) at GitDependencies.Program.UpdateWorkingTree(Boolean bDryRun, String RootPath, HashSet1 ExcludeFolders, Int32 NumThreads, Int32 MaxRetries, Uri Proxy, OverwriteMode Overwrite, String CachePath, Single CacheSizeMultiplier, Int32 CacheDays)
at GitDependencies.Program.Main(String Args)

I tried this,but it didn’t work.

What should i do?

by the way,
In the NvRTX_Caustics-4.27, It showed below error.

Failed to download ': The remote server returned an error: (403) Forbidden. (WebException)

1 Like

Getting exact same error. Is there a solution?

@yaobino @jwitsoe :
Are there any plans to integrate this functionality in more recent Unreal Engine versions? It would be amazing if it was put in a plugin, like DLSS. :):):)

Or, I guess another question is: Did any of this functionality make it into the new NvRTX 5.2.0-1?

There are caustic versions up to 5.2 at the moment. Go to the GitHub page and use the drop down on the upper left to select the type and version. ie I got the 5.1 version here, NvRTX/UnrealEngine at NvRTX_Caustics-5.1 (github.com)