CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Sensor
RTLensEngineAdapter.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include "
Carla/Util/CameraModelUtil.h
"
10
11
#include <util/ue-header-guard-begin.h>
12
#include "Engine/Scene.h"
13
#include <util/ue-header-guard-end.h>
14
15
// Adapter seam between ASceneCaptureCamera_RayTracedLens and the engine's
16
// path-tracer lens-model mechanism: FPostProcessSettings::PathTracingLens*
17
// (PathTracingLensModel / PathTracingLensFocal / PathTracingLensCoeffs01 /
18
// PathTracingLensCoeffs23 / PathTracingLensThetaMax / PathTracingLensCAScale,
19
// see Engine/Classes/Engine/Scene.h) landed by rt-lens-engine. These fields
20
// are genuine per-view, non-interpolated state, so multiple simultaneous
21
// rt_lens cameras with different lens configurations do not interfere with
22
// each other (this replaces an earlier CVar-based mechanism, which was
23
// process-global and did not support that).
24
//
25
// Kept as a seam (rather than writing PostProcessSettings fields directly
26
// from the sensor) so a further engine-side change only needs to update this
27
// file's body; call sites do not change.
28
namespace
RTLensEngineAdapter
29
{
30
// Writes Descriptor into PostProcessSettings' PathTracingLens* fields and
31
// sets their bOverride_ flags. Call whenever the descriptor changes (e.g.
32
// from ASceneCaptureCamera_RayTracedLens::Set()); these are per-view
33
// settings, not a per-tick push -- the renderer only invalidates
34
// path-tracer accumulation when a value actually changes.
35
void
ApplyLensModel
(FPostProcessSettings &PostProcessSettings,
const
FLensModelDescriptor &Descriptor);
36
37
// Ray tracing material pipeline completeness.
38
//
39
// Every path-traced capture binds one ray tracing pipeline state (RTPSO)
40
// holding the closest-hit shader of every loaded ray tracing material. When
41
// that set changes -- a vehicle or walker blueprint whose materials the
42
// scene has not rendered before finishes compiling its shaders -- the
43
// renderer needs a new RTPSO. With the engine default
44
// r.RayTracing.NonBlockingPipelineCreation=1 that RTPSO compiles in the
45
// background and, until it is ready, the frame renders with the previous
46
// pipeline: every mesh segment whose material is not in it is bound to
47
// PathTracingDefaultOpaqueCHS instead (Renderer/Private/RayTracing/
48
// RayTracingMaterialHitShaders.cpp, CreateMaterialRayTracingMaterialPipeline
49
// and SetupMaterialRayTracingHitGroupBindings; the shader is
50
// Shaders/Private/PathTracing/PathTracingDefaultHitShader.usf). That shader
51
// shades opaque black and never calls SetCarlaTag, so the new actor is black
52
// in rt_lens and tagged 0 in rt_lens_instance -- absent from both -- for as
53
// long as the compile takes (measured: 5-6 ticks after the material shaders
54
// land, with the actor's already-known materials, e.g. glass or tyres,
55
// showing normally in between). The distance AOV still sees it, because the
56
// fallback shader does report its hit distance.
57
//
58
// A synchronous-mode frame has to be the complete render of its tick, so the
59
// sensor asks the renderer to wait for the pipeline instead (the engine's
60
// documented meaning of r.RayTracing.NonBlockingPipelineCreation=0:
61
// "rendering will always use correct requested material"; offline renders
62
// get the same treatment through FSceneView::bIsOfflineRender). The wait is
63
// one deferred RHI dispatch per NEW material set -- measured 90-200 ms once,
64
// then never again for those materials -- and zero on every other frame. In
65
// asynchronous mode the game thread must never stall behind a sensor, so the
66
// previous value is restored and the engine's fallback is accepted.
67
//
68
// The cvar is ECVF_RenderThreadSafe: FConsoleVariableRef::Set copies the new
69
// value to the render thread through a render command, so a value written
70
// before CaptureScene() is what that capture's render sees. A value forced
71
// from the console (-ExecCmds / console_command, SetByConsole) outranks
72
// SetByCode and is left alone, with one warning.
73
void
SetBlockingRayTracingPipelineCreation
(
bool
bBlocking);
74
}
CameraModelUtil.h
RTLensEngineAdapter
Definition
RTLensEngineAdapter.cpp:15
RTLensEngineAdapter::SetBlockingRayTracingPipelineCreation
void SetBlockingRayTracingPipelineCreation(bool bBlocking)
Definition
RTLensEngineAdapter.cpp:17
RTLensEngineAdapter::ApplyLensModel
void ApplyLensModel(FPostProcessSettings &PostProcessSettings, const FLensModelDescriptor &Descriptor)
Definition
RTLensEngineAdapter.cpp:74
Generated by
1.18.0