Friday, February 17, 2023

Export FBX w/LODs for Unreal Engine

 If you have multiple LOD groups prepared with Max’s Level of Detail utility, the best resource I've found for easy export is this excellent macroscript by Anders K. Nielsen:

“Mass Export FBX to UE4.mcr” http://www.mcgreed.dk/maxscripts.html



The process is simple and though the script has several important options, here are the basic steps:

1. Set a file path where the FBX exported content will go.

2. Select all the entities in your max scene that you want to export then press “Get fileset” on the script.

3. Make sure and uncheck the option to move parents to world zero unless you're exporting props or other entities that will be animated or placed within Unreal.

When you press “export” the standard FBX export dialog will appear for you to choose your settings and options. This will only happen once upon initial export. Of course you need to choose the “Animation” option for objects with LOD’s.

I have exported dozens of LOD groups out of a single Max scene with this script. A real time saver.

I have created a simple maxscript (.ms) version without the macro headers so you can run it directly without the macro setup in max. You'll find it over in the Tools section of the website as well as a link below.

AKN_Mass_Export_FBX_NonMacro.zip

Anders has several other maxscripts at his site worth exploring. Thanks!!

Sunday, January 1, 2023

Pre-Multiplied Alpha Channel in Adobe Premiere

 One of those annoying things I always forget how to setup. If you've rendered out an animation to frames with an alpha channel, like old Targa format, and used a pre-multiplied alpha channel you need to make a change when compositing in Adobe Premiere. Years ago, Premiere could not handle pre-multiplied alpha channels. I did my compositing back then in old school Combustion. Anyone remember that? Loved that program but I guess Autodesk decided they couldn't compete with After Effects after a few years. Anyway, I was putting together some old frame sequences and just couldn't remember how to get Premiere to recognize my pre-multiplied alpha. You know, you get that black halo around your composited sequence. In Premiere, select the clip, then go to the "Clip/Modify/Interpret Footage" option and under "Alpha Channel" choose "Conform" and check the box for Premultiplied Alpha as shown below:


During my search on the topic online I came across this nice post on the subject by Dennis Koeppl. Thanks.

Saturday, December 3, 2022

WSP Inc. USA, design visualization for the city of Paris

 Before I retired in 2019 I had the privilege of being part of the visualization team at WSP creating interactive versions of the area around the Eiffel Tower. Though many folks contributed to the project, the real-time work was done in Unreal Engine 4.15 -4.18 largely by myself and my brilliant colleague Tracey White. With the tight deadlines and frequently revised goals, we never did get the finished product we would have wished for but nonetheless, I'm proud of the work we completed and I wanted to share some of it.

At it's core, the project was to create a detailed, real-time version of the existing environment around the tower, approximately 2.4 km, large enough to encompass nearby Metro stops, landmarks and areas of concern. The city was hosting a competition for the remodel of this entire area. We would then be tasked with inserting each finalist's revisions into the existing plan. The original goals were quickly revised to include a VR ready version but in the end, due to time constraints and to highlight each finalist's design in an equal manor, a pre-rendered fly-through of each design was created.

Below are some links to read up further on the project, plus a link to download a version of 3D real-time model.

As I mentioned, the project was very collaborative, including all the design team members from the finalists in several different countries, but I must include special thanks to some other 3D specialists at WSP including Kevin Gilson, Mark Kauffman, Glen Loyd, Mathew Kaltman, Eric Martens, Josh Jones, Scarlet Burns and Randy Burton. Mark Kauffman was critical as the Autodesk Infraworks specialist creating much of the core terrain and plan the rest of us worked with.

A screen capture from UE4 showing the 
Paris Eiffel Tower scene created at WSP in Denver, Colorado


Announcement of the competition winner and general overview of the project at Informedinfrastructure.com with links to videos of the designs of the 4 finalists:

https://informedinfrastructure.com/48189/city-of-paris-names-winning-design-team-to-reimagine-the-eiffel-tower-landscape-using-bim-2/

More overview of the project from the Autodesk Blogs including a link to download WSP's core, real-time Paris model (VR and Desktop versions):

https://blogs.autodesk.com/infrastructure-reimagined/eiffel-tower-experience-site-3d/

A tour through the core model created by WSP:

https://vimeopro.com/projectviz/paris-interactive/video/311519755

Some other videos of the project including GPB’s winning bid:

https://vimeopro.com/projectviz/paris-interactive

Online UE Blueprints resource

I came across this wonderful place online where users looking for a way to solve a problem can share their solutions and blueprint code snippets to assist the rest of us. These bits of blueprint can even be downloaded directly from the website. A great resource!

Unreal Engine: Overcome the 16 Texture Sample limit.

I mentioned in my previous post very briefly about overcoming the 16 Texture Samples limit in your typical UE Material. This is frankly old news. There have been other posts around the internet forums about this. It's how I learned about the Sampler Source option. I just thought I'd chime in since it seemed like an important topic.

With your Texture Sample selected in your material graph, in the "Details" panel, set the "Material Expression" "Sampler Source" to "Shared: Wrap". See below.


Credit for the image to poster "Numbat" on the Unreal Engine Dev Community forums. The discussion can be found here



Sunday, November 27, 2022

Dave's Editor Utility Blueprints (Blutilities) for Unreal Engine

I've been creating these as I needed for some projects. Thought about uploading them for sale on UE Marketplace but decided I'd make them available here. They are included in a little sample scene for testing. Once in the project, you'll find them in the content folder called "Blueprints":

https://1drv.ms/u/s!AvcZU7fMMWrohEf-VCJMVO5FJNqO?e=fbDY88 (~70 MB .zip)

Note these won’t work in anything BEFORE 4.24. I have found them to be compatible with UE5. These are provided as is. Use at your own risk. I warrant nothing.

Bulk Texture Replacer
Bulk Asset Renamer
Bulk Material Instance Parameter adjustment (vector and scalar)
Bulk Material Assignment (Assets and Actors)

A help file is included (pdf) and you’ll need it for at least the Texture Replacer and the Renamer which have specific instructions. If you want to view the help documentation and see specifics about each utility you can check out the pdf here:

Dave's Blutilities, Help File (PDF)

If you need some basic help on using Editor Utility Blueprints, please consult the Unreal Engine documentation.

I know there are several other utilities out there from other artists that perform some similar functions and you might find those more to your liking. It's up to you of course. I hope these help you in your work. 

Thursday, December 31, 2020

Ray Tracing Shadows for Foliage in Unreal Engine 4.25 & 4.26

 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.

Of course if we disable Ray Traced Shadows again on the light source, we now default back to CSM calculation and we get the traditional shadows as we would have seen in versions prior to Ray Tracing:

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.




4.25 vs. 4.26, Culling and Console Commands

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:

"r.RayTracing.InstancedStaticMeshes.Culling 0"

The results here:


There are indeed a series of commands related to controlling the ray traced shadows on Instanced Static Meshes, kindly documented in the above forum post by contributor Duongngochieu on 03-24-2020

Problem Solved Right?? Not so fast. Now let's try opening the scene in 4.26. Without any adjustments we get this:

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"

So the results are not what we expect. Actually, no change at all. This console command does not appear to be working to solve the problem. After a lot of research, trying other commands and fiddling with ray tracing settings for days I discovered that the console commands for Ray Tracing on Instanced Static Meshes have changed in 4.26. I have found no specific documentation on this but it works if you invoke the same console command constructed this way:
"r.RayTracing.Geometry.InstancedStaticMeshes.Culling 0"



In fact, all commands related to Ray tracing Instanced Static Meshes in 4.26 need this new declaration structure with the insertion of the word "Geometry" into the command.


Below are most of the related commands as they are implemented in 4.25, again, courtesy of forum contributor Duongngochieu from his above linked post:

Whether to include Instanced Static Meshes in BVH:
r.RayTracing.InstancedStaticMeshes [0|1]

Whether to enable culling of instance data:
r.RayTracing.InstancedStaticMeshes.Culling [0|1]

Scale factor on how large clusters are. Number represents a scale against the size of instances. 
5.0 means that clusters are 5x the size of the largest instance object:
r.RayTracing.InstancedStaticMeshes.CullClusterMaxRadiusMultiplier

Distance at which to cull a cluster: 
r.RayTracing.InstancedStaticMeshes.CullClusterRadius 

Threshold for when an object is considered small: 
r.RayTracing.InstancedStaticMeshes.LowScaleRadiusThreshold

Distance at which to cull small objects: 
r.RayTracing.InstancedStaticMeshes.LowScaleCullRadius

I'm assuming all these commands will work in 4.26 SO LONG AS you insert "Geometry" between "r.RayTracing." and ".InstancedStaticMeshes". It seems "InstancedStaticMeshes" are now parented by "Geometry" in the code.
I came upon this almost by accident in my research when watching this video by nvidia developer Richard Cowgill. It's well worth checking out. He is discussing new options for dealing with WPO offset animations in your foliage and lists the new commands which strongly resemble the formatting of the other rayTracing commands I had been working with. Near the end he mentions that simply removing the word "Geometry" from the new commands would make them work in UE 4.25. That would also make them follow the currently known formatting for the other commands related to RayTracing InstancedStaticMeshes in 4.25. Seemed a logical extension to try out the old CVAR's with this new formatting, inserting the word "Geometry" and sure enough, things start behaving in 4.26 as they do in 4.25.

I leave other settings related to Ray Traced Shadows up to you to evaluate and implement as you see fit for best results in your own scenes. I did however want to take the time to clearly (I hope) explain some of these most critical issues in a single post. And great thanks as always to the courageous forum posters putting themselves out there and allowing all of us to benefit from the wisdom and experience of others.

David Sparks