Hi Everyone. I am currently using UE 5.2 precompiled version from epic games launcher. I noticed that the ‘r.Nanite.Builder.Imposters’ cvar did not show up because there is a C++ macro NANITE_IMPOSTERS_SUPPORTED was defined to 0 which means I could not use the imposter functionality when Nanite instances become tiny instances. So why disable Nanite Imposters and how can I use them? Many thanks !!!
I’m bumping this thread because I’ve just discovered Nanite impostors and noticed that the feature is disabled by default. In NaniteDefinitions.h
, the flag NANITE_IMPOSTERS_SUPPORTED
is hard-coded to 0, which effectively prevents us from using impostor generation in our project since we’re not building from the open-source engine. Has anyone figured out a way to enable Nanite impostors without rebuilding the entire engine from source?
EDIT1: Five minutes - and one existential crisis - later, I discovered I can actually flip the switch in my .Build.cs
, like this:
public class MyGame : ModuleRules
{
public MyGame(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDefinitions.Add("NANITE_IMPOSTERS_SUPPORTED=1");
PublicDependencyModuleNames.AddRange(new string[]
{
"Core",
...
It should work after rebuilding the project.
EDIT2: Next, let’s enable the console variable r.Nanite.Builder.Imposters
, which is declared (when NANITE_IMPOSTERS_SUPPORTED
is true) in NaniteBuilder.cpp
like this:
#if NANITE_IMPOSTERS_SUPPORTED
static TAutoConsoleVariable<bool> CVarBuildImposters(
TEXT("r.Nanite.Builder.Imposters"),
false,
TEXT("Build imposters for small or distant objects. "
"Imposters can improve performance in scenes with many small or faraway meshes, "
"at the cost of additional memory and disk usage."),
ECVF_ReadOnly
);
#endif
By default this variable is set to false
. And it is ECVF_ReadOnly
so it needs to be set via .ini
file. So I attempted to override it in DefaultEngine.ini
:
[/Script/Engine.RendererSettings]
r.Nanite.Builder.Imposters=1
On startup, however, the log reports:
LogConfig: CVar [[r.Nanite.Builder.Imposters:1]] deferred – dummy variable created
This indicates the console variable isn’t being registered, which suggests NANITE_IMPOSTERS_SUPPORTED
remains disabled at compile time. There’s still a missing piece to make this take effect.
EDIT3: Surprisingly, a simple check in my code reports that imposters are enabled:
#if NANITE_IMPOSTERS_SUPPORTED
UE_LOG(LogTemp, Warning, TEXT("Nanite Imposters are supported!"));
#else
UE_LOG(LogTemp, Warning, TEXT("Nanite Imposters are NOT supported"));
#endif
And the output is: LogTemp: Warning: Nanite Imposters are supported!
. This confirms the define is active, even though the console variable never registers at runtime.
EDIT4: I tried setting the define in editor module’s Build.cs
instead of game one, and pulling in the NaniteBuilder
module:
public class MyEditorModule : ModuleRules
{
public MyEditorModule(ReadOnlyTargetRules Target) : base(Target)
{
...
PublicDefinitions.Add("NANITE_IMPOSTERS_SUPPORTED=1");
PublicDependencyModuleNames.AddRange(new string[]
{
"NaniteBuilder"
});
...
No dice - the console variable still never registers. At this point I’m pretty sure I have to edit the #define NANITE_IMPOSTERS_SUPPORTED 0
in the engine’s source directly. I’ll spin up a fresh source-based project soon, patch that line, and report back on whether it finally activates the feature.