Rendering foreground elements separately

 

Hi, 

In a non billboard method, what would be the options to offline render foreground elements of the virtual scene separately? In a scenario where I render files out from Aximmetry and make the final composition in Fusion, it would be important to be able to either render any foreground elements separately or to render a mask/matte of the foreground assets. 

In vanilla UE this would be easy, I could just assign any assets to a separate fg layer and render just that layer, is this doable via Aximmetry?

How about render layers like cryptomatte, stencil layers or using something related to object id's? 

Any of those solutions would be great as they would not require any modifications to the UE scene that would not also work for rendering the main render/background. 

If those doesn't work, it might be easy enough to create a second version of the UE scene where the foreground elements had some kind of matte shader that would allow to easily create a mask out of them in Fusion. 

I understand I could export tracking data to fbx, then render in UE and then render that output again in Aximmetry through lens distortion, but that is a little hassle so hope there is a better way. 

Optimal would be if it was possible to simultaneously render the fg layer when rendering all the other files like the basic UE bg, 3D cleanplate, any Aximmetry crops/masks etc..But if it needs a separate round of rendering it's not a too big of a deal either. 

Thank you,


Emil

   Nestruction Studios

 
Profile Image
Eifert@Aximmetry
  -  

Hi Emil,

As of now, you cannot use Unreal Engine's non-real-time rendering capabilities directly from Aximmetry. You have to export the tracking data as an FBX file and use it in, for example, the Movie Render Queue. More details on how to do so can be found here: https://my.aximmetry.com/post/897-camera-tracking-data-fbx-import-fails-on
Note that adding support for Movie Render Queue within Aximmetry is on our request list.

Additionally, you can output lens distortion from Aximmetry as an STMap, which you can use in Fusion to apply lens distortion. To access this feature, locate the STMap compound at [Common]:Compounds\Utilities\STMap_Generator.xcomp.
Here are a couple of ways you can set it up:

  • For live tracking input - simply use a Camera Tracking module:


  • For playback of tracking recording from tracked camera compounds - Use the Record Data collection pin's Lens Distortion key to get the Lens Data:

Note that you should enable the Keep ColorSpace option in the Video Recorder module.
Additionally,
Fusion expects the STMap in 32-bit float format (EXR/32f), which you can set in the Video Recorder module.


Using Only Aximmetry

If you only want to use Aximmetry, then you can record the background and a mask for the billboard to indicate what is in front of or behind the billboard. You could use this mask in Aximmetry to record two videos—one for the foreground and one for the background. Alternatively, you can record the mask and use it in Fusion if possible.

What first you should know, that when when Allow Virtuals is turned off, the camera compound in Aximmetry renders the billboard instead of Unreal.


For this, the Unreal module outputs a mask video (B Mask pin).
Rendering foreground elements separately

For example, the Out video with it's B Mask:


This mask is in the red channel of the video, but you can easily process it to any other color(s). You can use modules like Inverter, Alpha Merger, or Color Composer, or a combination of these to do so. Also, this mask only covers the size (Scale) of your billboard.
Rendering foreground elements separately

You will want to record this Mask, Billboard, and Unreal Rendered Image at a specific point inside the tracked camera compound. This way, you don't have to deal with cropping and other processes. To do this, open the camera compound for editing with the "Edit Compound In-Place" option.
Rendering foreground elements separately
Note, that this compound is part of Aximmetry's package, so you should handle it accordingly: https://aximmetry.com/learn/virtual-production-workflow/preparation-of-the-production-environment-phase-i/scripting-in-aximmetry/flow-editor/compound/#working-with-compounds-from-aximmetry-library

Double click on the camera compound to enter it, and inside find the location where the Masker module uses the mask to hide portions of the Input (Billboard) and where the LightWarp_Layer compound puts the subsequent video over Unreal's rendered image. If you use Aximmetry's Light Warp, you will also probably need to edit this LightWarp_Layer compound.
Use the videos in the connections marked by blue rectangles in the picture below to your liking and create different layers as needed. For example, by using a Masker module not on the Input's video but on the Unreal rendered background video.



One more thing: if on the billboard the Render To Depth is turned on, a billboard will still be rendered by Unreal in the output of the Unreal module.
Rendering foreground elements separately
This is necessary for certain reflection types: https://aximmetry.com/learn/virtual-production-workflow/preparation-of-the-production-environment-phase-i/green-screen-production/aximmetry-de-scene-setup-green-screen/#reflections-in-unreal-engine
However, in most cases, this isn’t a problem because the billboard rendered by Aximmetry will completely overlap it.


Using only Aximmetry with Green + AR camera compound

If you have a specific need to render only some foreground elements separately, the above solution will probably not work. In that case, you could use the Green + AR camera (tracked, 1-3 billboards) compound, where the AR part would only render the foreground objects. More on this compound and AR in Unreal here: https://aximmetry.com/learn/virtual-production-workflow/preparation-of-the-production-environment-phase-i/ar-production/aximmetry-de-scene-setup-ar/#ar-in-green-and-led-wall-projects
This would actually enable you to modify the foreground rendered (AR) objects even in live productions.


Lastly, all of this can be done in post-production using non-real-time rendering. This allows you to render at higher quality settings and resolutions as desired. This is mentioned in the page about recording here: https://aximmetry.com/learn/virtual-production-workflow/preparation-of-the-production-environment-phase-i/setting-up-inputs-outputs-for-virtual-production/video/recording/how-to-record-camera-tracking-data/#offline-rendering

Warmest regards,


 
Profile Image
Het Nieuwe Kader
  -  

" Additionally, you can output lens distortion from Aximmetry as an STMap, which you can use in Fusion to apply lens distortion. To access this feature, locate the STMap compound at [Common]:Compounds\Utilities\STMap_Generator.xcomp." 

Can you show how to do this? I cant manage to replicate the Lens Distortion in Fusion this way.. Its my final piece of the puzzle in the post workflow, please help me <3

 
Profile Image
Eifert@Aximmetry
  -  

Hi,

Are you using the STMap node in Fusion? For additional information on it, you can refer to this: https://learn.foundry.com/nuke/content/reference_guide/transform_nodes/stmap.html

As a starting point, consider experimenting with a static image instead of a video. Additionally, capture an image with visible lens distortion, which is usually most noticeable when you zoom out fully. This will allow you to observe the impact of lens distortion more effectively.

Warmest regards,

 
Profile Image
Het Nieuwe Kader
  -  

Hi Eifert,


Yes I am using STMapper in Fusion, but it doesnt give me any good results with the STMAP aimage recorded in Aximmetry.

I would really appreciate a short explanation video or some test files <3

Thanks!!!

 
Profile Image
Het Nieuwe Kader
  -  

I figured it out! I recorded the STMAPS as 32 bit EXR files and I had to set them to sRGB in Resolve, by default they import as linear of course.

By the way, the STMAP generatror xcomp file has the lens data unplugged inside, I had to break it open and plug it in manually.

Not a super big deal but could be something to fix in a future version.

Thanks! <3


 
Profile Image
Eifert@Aximmetry
  -  

Hi,

We are glad to hear that you managed to get it working!

It seems likely that the lens data connections got disconnected because you are using the STMap_Generator in an earlier version of Aximmetry than the one in which it was created. Because some versions ago, the Lens Data pin was named differently in the Lens Distorter module.

Yes, Fusion expects the STMap in 32-bit float format (EXR/32f).
Additionally, I forgot to mention that you should enable the Keep ColorSpace option in the Video Recorder.

This should address the need to switch between sRGB and Linear color spaces in Resolve.

I updated my first comment with this information.

Warmest regards,

 
Profile Image
Nestruction Studios
  -  

Thanks Eifert! It works perfectly! I always do the comp outside of the tracked cam compound so didn't realize the UE modules B mask output gave the foreground mask like on a silver platter right in the root when "Allow virtuals" is off. Perfect! When recording it or using outside of the tracked cam compound it is just necessary to apply the lens distortion to it but that's easy to copy from elsewhere. Didn't have a chance to experiment with the AR option yet, but at least this gave perfect mask for the foreground that worked flawlessly in Fusion. And ino additional rounds of rendering needed and no setup! Of course when it is the position of the billboard that determines what is concidered FG and what BG it needs to be set carefully, but then for a lot of scenarios it can be way faster than having to manually tag each actor as FG. And it can be changed so fast right in Aximmetry! Thrilled about this 🤩

Emil

;