# Trying to export faithfully my segmentation mask from a blueprint graph - synthetic dataset for detection using segmentation masks  

**URL:** <https://forums.unrealengine.com/t/trying-to-export-faithfully-my-segmentation-mask-from-a-blueprint-graph-synthetic-dataset-for-detection-using-segmentation-masks/2732785>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint\
**Created:** [July 1, 2026, 2:52pm UTC](https://forums.unrealengine.com/t/trying-to-export-faithfully-my-segmentation-mask-from-a-blueprint-graph-synthetic-dataset-for-detection-using-segmentation-masks/2732785 "2026-07-01T14:52:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yopegassiyo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@yopegassiyo](https://forums.unrealengine.com/u/yopegassiyo)\
**Post date:** [July 1, 2026, 2:52pm UTC](https://forums.unrealengine.com/t/trying-to-export-faithfully-my-segmentation-mask-from-a-blueprint-graph-synthetic-dataset-for-detection-using-segmentation-masks/2732785/1 "2026-07-01T14:52:02Z")

</div>

## UE 5.7.4 Bug Report – SceneCapture2D Post Process RenderTarget exports incorrect image

## Summary

I am generating a synthetic dataset (RGB + segmentation mask) using two `SceneCaptureComponent2Ds. The mask of my vehicle is taking into account the objects occluding it. Thus, the expected shape is not perfectly regular but occluded where other objects stand. I use CustomDepth, SceneDepth and CustomStencil. The resulting mask works as expected. However, once exported it is not rendered at all, or corrupted, or wrong. I did not implement a blueprint loop as I first want to ensure one iteration works well. I therefore want an automated generation->capture->export process (see all details below, I tried numerous settings/configs). Thanks in advance!!`

 ![Screenshot 2026-07-01 130842](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/d/c/adcadc4fbcc12d8f2578e13665132b590e73fe90.png)

 ![Screenshot 2026-07-01 130618](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/7/5/4756e14a0fc78b439ad85d4969161ecc82835ec8.png)

The RGB capture exports correctly.

The mask capture renders correctly inside Unreal Engine (TextureRenderTarget preview), but exporting the RenderTarget produces either:

- the RGB image instead of the mask,

- an empty/corrupted image,

- or an unreadable file,

depending on the SceneCapture settings.

This prevents generation of synchronized RGB/mask datasets.

* * *

# Engine version

Unreal Engine **5.7.4**

* * *

# Goal

I have two SceneCapture2D components:

- RGB SceneCapture

- Mask SceneCapture

Both share the same transform and therefore should produce perfectly aligned images.

The mask SceneCapture uses a Post Process Material to generate a binary segmentation mask while preserving occlusions.

* * *

# RGB SceneCapture settings

- Capture Source:

- Texture Target:

- Post Process Material:

- Primitive Render Mode:

- Composite Mode:

RGB exports correctly.

* * *

# Mask SceneCapture settings

- Capture Source:

- Texture Target:

- Primitive Render Mode:

- Composite Mode:

- Post Process Blend Weight:

- Post Process Material:

- Project Settings

* * *

# Post Process Material

Material Domain:

Post Process

Blendable Location:

Scene Color After Tonemap

Material outputs only through Emissive.

Logic:

1. Read CustomDepth

2. Read SceneDepth

3. Compare both depths to determine visibility/occlusion

4. Read CustomStencil

5. Keep only stencil == 1

6. Multiply visibility by stencil

7. Output to Emissive

The material correctly produces a binary mask inside the RenderTarget preview.

* * *

# Expected behavior

The exported PNG should exactly match the TextureRenderTarget preview.

* * *

# Actual behavior

## Case 1

Capture Every Frame = ON

Always Persist Rendering State = OFF

TextureRenderTarget preview:

Correct binary mask.

Export:

RGB image (identical to RGB SceneCapture).

* * *

## Case 2

Capture Every Frame = OFF

Always Persist Rendering State = OFF

TextureRenderTarget preview:

RGB image (same as RGB capture).

Export:

RGB image.

* * *

## Case 3

Capture Every Frame = OFF

Always Persist Rendering State = ON

TextureRenderTarget preview:

Correct binary segmentation mask.

Export:

Empty/corrupted/unreadable PNG.

File sizes vary around:

- approximately 30 KB

- approximately 2 MB

depending on capture source.

The exported file cannot be opened.

* * *

# Additional experiments

## Constant color material

The complete segmentation material was replaced by:

Material Domain = Post Process

Constant3Vector(1,0,0)

connected directly to Emissive.

Result:

TextureRenderTarget preview:

Solid red.

Export:

Empty/corrupted image.

Therefore the issue does not appear to originate from CustomDepth or CustomStencil.

* * *

## Material simplification

The following were tested independently:

- CustomStencil only

- CustomDepth only

- SceneDepth only

No change.

* * *

## Capture Source tests

Tested:

- Final Color (LDR)

- SceneColor HDR

- SceneColor HDR + SceneDepth

- Final Color HDR Linear Working Color Space

No configuration solved the issue.

* * *

## Primitive Render Mode

Tested:

- Render Scene Primitives (Legacy)

- Render Scene Primitives

No difference.

* * *

## Ray Tracing

Use Ray Tracing If Enabled:

Tested ON and OFF.

No difference.

* * *

## Support UAV

Enabled and disabled.

No difference.

* * *

## Composite Mode

Overwrite.

No difference.

* * *

## Post Process Blend Weight

1.0

No difference.

* * *

## Capture timing

Tested:

- CaptureScene

- Delay Until Next Tick

- 1 second delays

- Capturing RGB first

- Capturing Mask first

- Multiple CaptureScene calls

No change.

* * *

## Export methods

Tested:

- Export To Disk

- Export Render Target

Both produce the same issue.

* * *

## Texture Target

1024 × 1024

RTF\_RGBA8

Target Gamma tested at:

- 0.0

- 2.2

Changing gamma only affects RGB brightness.

It does not affect the mask export problem.

* * *

# Observations

The key observation is:

The TextureRenderTarget preview consistently displays the correct segmentation mask while the exported file does not correspond to the displayed RenderTarget.

This suggests that either:

- ExportRenderTarget / ExportToDisk is reading a different GPU resource than the RenderTarget preview,

or

- SceneCapture2D post-process output is not correctly resolved before export.

* * *

# Why I believe this is a rendering issue

The problem persists after eliminating:

- timing issues

- asynchronous image writing

- capture ordering

- CustomDepth logic

- CustomStencil logic

- SceneDepth logic

- Capture Source

- RenderTarget format

- Primitive Render Mode

- Ray tracing

- UAV support

Replacing the entire segmentation material with a constant red output still results in a red RenderTarget preview but an invalid exported image.

This suggests that the RenderTarget itself is being rendered correctly but the exported image is not reading the same rendered contents.

* * *

---

<div class="post-metadata">

**Author:** ![yopegassiyo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@yopegassiyo](https://forums.unrealengine.com/u/yopegassiyo)\
**Post date:** [July 6, 2026, 10:24pm UTC](https://forums.unrealengine.com/t/trying-to-export-faithfully-my-segmentation-mask-from-a-blueprint-graph-synthetic-dataset-for-detection-using-segmentation-masks/2732785/2 "2026-07-06T22:24:58Z")

</div>

good evening, could someone help me please??
