r.SetNearClipPlane

r.SetNearClipPlane

#Overview

name: r.SetNearClipPlane

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SetNearClipPlane is to set the near clipping plane distance for the camera in the Unreal Engine rendering system. This setting controls how close objects can be to the camera before they’re clipped (not rendered).

This setting variable is primarily used in the Unreal Engine’s rendering system. It’s referenced in the core Engine module and is also recognized by plugins such as ConsoleVariablesEditor and DisplayClusterLaunch.

The value of this variable is set through a console command. It’s defined as an FAutoConsoleCommand in UnrealEngine.cpp, which means it can be invoked from the game console or through code.

While there aren’t direct interactions with other variables shown in the provided code, it’s part of the broader camera and rendering settings in Unreal Engine. It likely interacts with other camera-related settings and rendering parameters.

Developers should be aware that:

  1. This is a runtime-modifiable setting, allowing for dynamic adjustments to the near clip plane.
  2. The value is set in centimeters, as indicated by the command description.
  3. Changing this value can affect rendering performance and visual quality, especially for objects very close to the camera.

Best practices when using this variable include:

  1. Use it judiciously, as very small values can cause z-fighting (visual artifacts) for objects close to the camera.
  2. Consider the scale of your game world when setting this value.
  3. Test thoroughly after changes, especially in VR applications where proper depth perception is crucial.
  4. Be cautious when allowing this to be changed during gameplay, as it could potentially cause visual discontinuities.
  5. Document any non-default values used in your project for easier maintenance and debugging.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:17563

Scope: file

Source code excerpt:


}
FAutoConsoleCommand GSetNearClipPlaneCmd(TEXT("r.SetNearClipPlane"),TEXT("Set the near clipping plane (in cm)"),FConsoleCommandWithArgsDelegate::CreateStatic(SetNearClipPlane));

static TAutoConsoleVariable<int32> CVarAllowHighQualityLightMaps(
	TEXT("r.HighQualityLightMaps"),
	1,
	TEXT("If set to 1, allow high quality lightmaps which don't bake in direct lighting of stationary lights"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly);

#Loc: <Workspace>/Engine/Plugins/Editor/ConsoleVariablesEditor/Source/ConsoleVariablesEditor/Private/Views/List/SConsoleVariablesEditorList.cpp:972

Scope (from outer to inner):

file
function     TSharedRef<SWidget> SConsoleVariablesEditorList::BuildShowOptionsMenu

Source code excerpt:

		ShowOptionsMenuBuilder.AddMenuEntry(
			LOCTEXT("TrackAllVariableChanges", "Track All Variable Changes"),
			LOCTEXT("ConsoleVariablesEditorList_TrackAllVariableChanges_Tooltip", "When variables are changed outside the Console Variables Editor, this option will add the variables to the current preset. Does not apply to console commands like 'r.SetNearClipPlane' or 'stat fps'."),
			FSlateIcon(),
			FUIAction(
				FExecuteAction::CreateLambda([]()
				{
					if (UConsoleVariablesEditorProjectSettings* ProjectSettingsPtr =
						GetMutableDefault<UConsoleVariablesEditorProjectSettings>())

#Loc: <Workspace>/Engine/Plugins/Editor/ConsoleVariablesEditor/Source/ConsoleVariablesEditor/Public/ConsoleVariablesEditorCommandInfo.h:17

Scope (from outer to inner):

file
function     struct CONSOLEVARIABLESEDITOR_API FConsoleVariablesEditorCommandInfo { enum class EConsoleObjectType { // A console command that has no associated console object but is parsed externally, e.g. 'st

Source code excerpt:

		// A console command that has no associated console object but is parsed externally, e.g. 'stat unit'
		NullObject,
		// A console command with an associated console object, like 'r.SetNearClipPlane'
		Command,
		// A console variable such as 'r.ScreenPercentage'
		Variable
	};
	
	struct FStaticConsoleVariableFlagInfo

#Loc: <Workspace>/Engine/Plugins/Editor/ConsoleVariablesEditor/Source/ConsoleVariablesEditor/Public/ConsoleVariablesEditorProjectSettings.h:40

Scope (from outer to inner):

file
function     class CONSOLEVARIABLESEDITOR_API UConsoleVariablesEditorProjectSettings : public UObject { GENERATED_BODY

Source code excerpt:

	/**
	 *When variables are changed outside the Console Variables Editor, this option will add the variables to the current preset.
	 *Does not apply to console commands like 'r.SetNearClipPlane' or 'stat fps'
	 */
	UPROPERTY(Config, EditAnywhere, Category="Console Variables Editor")
	bool bAddAllChangedConsoleVariablesToCurrentPreset;

	/**
	 * If bAddAllChangedConsoleVariablesToCurrentPreset is true, this list will filter out any matching variables
	 * changed outside of the Console Variables Editor so they won't be added to the current preset.
	 * Matching variables explicitly added inside the Console Variables Editor will not be filtered.
	 */

#Loc: <Workspace>/Engine/Plugins/Editor/DisplayClusterLaunch/Source/DisplayClusterLaunchEditor/Public/DisplayClusterLaunchEditorProjectSettings.h:122

Scope (from outer to inner):

file
function     class DISPLAYCLUSTERLAUNCHEDITOR_API UDisplayClusterLaunchEditorProjectSettings : public UObject { GENERATED_BODY

Source code excerpt:

	 * You can specify additional console commands here to be executed after those of the Console Variable Preset are executed.
	 * This is useful for overriding commands in your defined Console Variables Asset.
	 * Console Commands generally have a name and no value (i.e. 'stat unit') though some have a value too (i.e. "r.SetNearClipPlane 500")
	 */
	UPROPERTY(Config, EditAnywhere, Category="nDisplay Launch Settings|Console")
	TSet<FString> AdditionalConsoleCommands;

	/**
	 * A list of command line arguments to append to the Switchboard command (e.g. messaging, fullscreen, handleensurepercent=0)
	 * Do not include the dash ("-") as this will be automatically added for you when calling the command.
	 * Parameters for arguments are supported, such as "handleensurepercent=0".
	 */
	UPROPERTY(Config, EditAnywhere, Category="nDisplay Launch Settings|Console")