NearClipPlane
NearClipPlane
#Overview
name: NearClipPlane
The value of this variable can be defined or overridden in .ini config files. 2
.ini config files referencing this setting variable.
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of NearClipPlane is to define the distance of the camera’s near clipping plane in Unreal Engine 5. This setting is crucial for the rendering system, particularly in determining how close objects can be to the camera before they are clipped from view.
The NearClipPlane variable is primarily used in the Engine module, but it also has implications for various subsystems and plugins, including:
- The MoviePipelineMaskRenderPass plugin, which uses it for scene view calculations in panoramic rendering.
- The VREditor module, which modifies the near clip plane for VR editing scenarios.
- The Renderer module, which uses it in light rendering calculations.
The value of this variable is typically set in the Engine configuration, as evidenced by the UPROPERTY declaration in the UEngine class. It can also be modified programmatically, as seen in the VREditor code.
Other variables that interact with NearClipPlane include:
- GNearClippingPlane: A global variable that seems to be used alongside NearClipPlane.
- WorldToMetersScale: Used in VR editing to adjust the near clip plane based on the world scale.
Developers should be aware of the following when using this variable:
- Modifying the near clip plane can significantly impact rendering performance and visual quality.
- In VR scenarios, the near clip plane may need to be adjusted to prevent clipping issues when users scale themselves to be very small.
- Extreme values (too small or too large) can cause rendering artifacts or performance issues.
Best practices when using this variable include:
- Use the default value unless there’s a specific need to change it.
- When modifying, test thoroughly across different scenarios to ensure no unintended side effects.
- In VR or other specialized rendering contexts, consider dynamically adjusting the near clip plane based on the current view or world scale.
- Be cautious when setting very small values, as this can lead to z-fighting and other rendering artifacts.
- Coordinate changes to this variable with other rendering settings to maintain visual consistency and performance.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEngine.ini:323, section: [/Script/Engine.Engine]
- INI Section:
/Script/Engine.Engine
- Raw value:
10.0
- Is Array:
False
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:30, section: [/Script/Engine.Engine]
- INI Section:
/Script/Engine.Engine
- Raw value:
3.000000
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/MovieScene/MoviePipelineMaskRenderPass/Source/MoviePipelineMaskRenderPass/Private/MoviePipelinePanoramicPass.cpp:282
Scope (from outer to inner):
file
function FSceneView* UMoviePipelinePanoramicPass::GetSceneViewForSampleState
Source code excerpt:
if (LocalPlayerController && LocalPlayerController->PlayerCameraManager)
{
float NearClipPlane = LocalPlayerController->PlayerCameraManager->GetCameraCacheView().PerspectiveNearClipPlane;
MinZ = NearClipPlane > 0 ? NearClipPlane : MinZ;
}
PanoPane->NearClippingPlane = MinZ;
const float MaxZ = MinZ;
// Avoid zero ViewFOV's which cause divide by zero's in projection matrix
const float MatrixFOV = FMath::Max(0.001f, ViewFOV) * (float)PI / 360.0f;
// ToDo: I think this is a FMath::DegreesToRadians, easier to read that way than PI/360
#Loc: <Workspace>/Engine/Source/Editor/VREditor/Private/VREditorModeBase.cpp:150
Scope (from outer to inner):
file
function void UVREditorModeBase::StartViewport
Source code excerpt:
// Force tiny near clip plane distance, because user can scale themselves to be very small.
SavedEditorState.NearClipPlane = GNearClippingPlane;
SetNearClipPlaneGlobals(VREd::DefaultVRNearClipPlane->GetFloat());
SavedEditorState.bOnScreenMessages = GAreScreenMessagesEnabled;
GAreScreenMessagesEnabled = false;
#Loc: <Workspace>/Engine/Source/Editor/VREditor/Private/VREditorModeBase.cpp:227
Scope (from outer to inner):
file
function void UVREditorModeBase::CloseViewport
Source code excerpt:
VRViewportClient.SetRealtime(SavedEditorState.bRealTime);
SetNearClipPlaneGlobals(SavedEditorState.NearClipPlane);
GAreScreenMessagesEnabled = SavedEditorState.bOnScreenMessages;
if (bActuallyUsingVR)
{
GEngine->XRSystem->SetTrackingOrigin(SavedEditorState.TrackingOrigin);
#Loc: <Workspace>/Engine/Source/Editor/VREditor/Private/VREditorPlacement.cpp:102
Scope (from outer to inner):
file
function void UVREditorPlacement::UpdateNearClipPlaneOnScaleChange
Source code excerpt:
const float DefaultWorldToMetersScale = VRMode->GetSavedEditorState().WorldToMetersScale;
SetNearClipPlaneGlobals(FMath::Min((VRMode->GetDefaultVRNearClipPlane()) * (NewWorldToMetersScale / DefaultWorldToMetersScale), VRMode->GetSavedEditorState().NearClipPlane));
}
#undef LOCTEXT_NAMESPACE
#Loc: <Workspace>/Engine/Source/Editor/VREditor/Public/VREditorModeBase.h:95
Scope (from outer to inner):
file
class class UVREditorModeBase : public UEditorWorldExtension
Source code excerpt:
bool bLockedPitch = false;
bool bAlwaysShowModeWidgetAfterSelectionChanges = false;
float NearClipPlane = 0.0f;
bool bRealTime = false;
bool bOnScreenMessages = false;
EHMDTrackingOrigin::Type TrackingOrigin = EHMDTrackingOrigin::Local;
float WorldToMetersScale = 100.0f;
bool bCinematicControlViewport = false;
};
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/Engine.h:1434
Scope (from outer to inner):
file
class class UEngine : public UObject , public FExec
Source code excerpt:
/** The distance of the camera's near clipping plane. */
UPROPERTY(EditAnywhere, config, Category=Settings)
float NearClipPlane;
/** Flag for completely disabling subtitles for localized sounds. */
UPROPERTY(EditAnywhere, config, Category=Subtitles)
uint32 bSubtitlesEnabled:1;
/** Flag for forcibly disabling subtitles even if you try to turn them back on they will be off */
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:2080
Scope (from outer to inner):
file
function void UEngine::Init
Source code excerpt:
FBlueprintCoreDelegates::SetScriptMaximumLoopIterations( GEngine->MaximumLoopIterationCount );
SetNearClipPlaneGlobals(NearClipPlane);
UTextRenderComponent::InitializeMIDCache();
if (GIsEditor)
{
// Create a WorldContext for the editor to use and create an initially empty world.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:2277
Scope (from outer to inner):
file
function static void CalculateLightNearFarDepthFromBounds
Source code excerpt:
NearDepth = NearPoint4Clip.Z / NearPoint4Clip.W;
// negative means behind view, but we use a NearClipPlane==1.f depth
if (NearPoint4Clip.W < 0)
NearDepth = 1;
if (FarPoint4Clip.W < 0)
FarDepth = 1;