How to increase mobile Max Moveable Spotlight / Point Lights?

As the question suggests, I’m wondering if there is anyway to force an increase to the Maximum number of Moveable Spotlight / Point Lights on mobile beyond the default allowed in the project settings. In the project settings you don’t seem to be able to increase the number beyond 4. I plan to use these lights without shadows, so I would think it wouldn’t be a performance problem to have more than 4 in the scene. Any thoughts are greatly appreciated, thank you!

332269-screen-shot-2021-03-12-at-90158-am.png

1 Like

did you find an answer to this?

Sorry for bumping, but I was looking for the same thing and found the solution.

It requires you to modify engine source files. Il post the file name followed by modified code lines:

\Engine\Source\Runtime\Engine\Classes\Engine\RendererSettings.h

ConsoleVariable = “r.MobileNumDynamicPointLights”, DisplayName = “Max Movable Spotlights / Point Lights”, ClampMax = 100,


\Engine\Source\Runtime\Renderer\Private\MobileBasePassRendering.cpp

static_assert(MAX_BASEPASS_DYNAMIC_POINT_LIGHTS == 100, “If you change MAX_BASEPASS_DYNAMIC_POINT_LIGHTS, you need to add shader types below”);

here below you should an option for 100 like its said in the comment above, like its added below
IMPLEMENT_MOBILE_SHADING_BASEPASS_LIGHTMAPPED_PIXEL_SHADER_TYPE(LightMapPolicyType, LightMapPolicyName, 2)
IMPLEMENT_MOBILE_SHADING_BASEPASS_LIGHTMAPPED_PIXEL_SHADER_TYPE(LightMapPolicyType, LightMapPolicyName, 3)
IMPLEMENT_MOBILE_SHADING_BASEPASS_LIGHTMAPPED_PIXEL_SHADER_TYPE(LightMapPolicyType, LightMapPolicyName, 4)
IMPLEMENT_MOBILE_SHADING_BASEPASS_LIGHTMAPPED_PIXEL_SHADER_TYPE(LightMapPolicyType, LightMapPolicyName, 100)
IMPLEMENT_MOBILE_SHADING_BASEPASS_LIGHTMAPPED_PIXEL_SHADER_TYPE(LightMapPolicyType, LightMapPolicyName, INT32_MAX)


\Engine\Source\Runtime\Renderer\Private\MobileBasePassRendering.h

#define MAX_BASEPASS_DYNAMIC_POINT_LIGHTS 100


Also in your project set max movable spotlights to 100 - I have not tested what it would be if you set it to 5-99, may be a problem there.

So far I have tested with 8 point lights - all working fine, no fps drop.

2 Likes

Hello, I did as you said. I can indeed adjust the maximum number of lights in the engine, but in reality, only 4 lights are actually in effect. Why is that

You missing the Case Switch in Function ‘bool MobileBasePass::GetShaders()’ for 8 or the number of lights you planning to use.

Go to file “Engine\Source\Runtime\Renderer\Private\MobileBasePass.cpp” and find the above function and add the case your missing.

I added the case switch as you suggested, but it didn’t work. In fact, I successfully expanded the lighting to 6 lights in the past two days, but once the hard coding of lights exceeds 6, it will crash

Fatal error: [File:D:/UE4.27Html/4.27/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp] [Line: 3443]
Failed to compile default material /Engine/EngineMaterials/WorldGridMaterial.WorldGridMaterial!
0x00007ff9d7a35369 KERNELBASE.dll!UnknownFunction
0x00007ff94e464b96 UE4Editor-Core.dll!ReportAssert() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Core\Private\Windows\WindowsPlatformCrashContext.cpp:1644]
0x00007ff94e468c58 UE4Editor-Core.dll!FWindowsErrorOutputDevice::Serialize() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Core\Private\Windows\WindowsErrorOutputDevice.cpp:78]
0x00007ff94e1789bd UE4Editor-Core.dll!FOutputDevice::LogfImpl() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Core\Private\Misc\OutputDevice.cpp:61]
0x00007ff94a2cb54d UE4Editor-Engine.dll!FShaderCompilingManager::ProcessCompiledShaderMaps() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Engine\Private\ShaderCompiler\ShaderCompiler.cpp:3443]
0x00007ff94a2a92c4 UE4Editor-Engine.dll!FShaderCompilingManager::FinishCompilation() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Engine\Private\ShaderCompiler\ShaderCompiler.cpp:3934]
0x00007ff949ddcb0c UE4Editor-Engine.dll!FMaterialShaderMap::Compile() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Engine\Private\Materials\MaterialShader.cpp:1809]
0x00007ff949dd581e UE4Editor-Engine.dll!FMaterial::BeginCompileShaderMap() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Engine\Private\Materials\MaterialShared.cpp:2304]
0x00007ff949dd7391 UE4Editor-Engine.dll!FMaterial::CacheShaders() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Engine\Private\Materials\MaterialShared.cpp:2197]
0x00007ff949dd78c2 UE4Editor-Engine.dll!FMaterial::CacheShaders() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Engine\Private\Materials\MaterialShared.cpp:2049]
0x00007ff949d3c45a UE4Editor-Engine.dll!UMaterial::CacheShadersForResources() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Engine\Private\Materials\Material.cpp:3097]
0x00007ff949d3bd37 UE4Editor-Engine.dll!UMaterial::CacheResourceShadersForRendering() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Engine\Private\Materials\Material.cpp:2978]
0x00007ff949d384c1 UE4Editor-Engine.dll!UMaterial::AllMaterialsCacheResourceShadersForRendering() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Engine\Private\Materials\Material.cpp:5605]
0x00007ff9471efe1b UE4Editor-UnrealEd.dll!UEditorEngine::SetPreviewPlatform() [D:\UE4.27Html\4.27\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:7744]
0x00007ff9471d97ef UE4Editor-UnrealEd.dll!UEditorEngine::LoadEditorFeatureLevel() [D:\UE4.27Html\4.27\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:7857]
0x00007ff9471d4b01 UE4Editor-UnrealEd.dll!UEditorEngine::Init() [D:\UE4.27Html\4.27\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:982]
0x00007ff947acf5c2 UE4Editor-UnrealEd.dll!UUnrealEdEngine::Init() [D:\UE4.27Html\4.27\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:80]
0x00007ff726b42f55 UE4Editor.exe!FEngineLoop::Init() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4019]
0x00007ff947aa4bec UE4Editor-UnrealEd.dll!EditorInit() [D:\UE4.27Html\4.27\Engine\Source\Editor\UnrealEd\Private\UnrealEdGlobals.cpp:94]
0x00007ff726b60e7c UE4Editor.exe!GuardedMain() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Launch\Private\Launch.cpp:154]
0x00007ff726b610fa UE4Editor.exe!GuardedMainWrapper() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:137]
0x00007ff726b6411d UE4Editor.exe!LaunchWindowsStartup() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:273]
0x00007ff726b754b4 UE4Editor.exe!WinMain() [D:\UE4.27Html\4.27\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:320]
0x00007ff726b78046 UE4Editor.exe!__scrt_common_main_seh() [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
0x00007ff9d9df7374 KERNEL32.DLL!UnknownFunction
0x00007ff9da0dcc91 ntdll.dll!UnknownFunction