I don’t know why you should want this and I also don’t think that this is possible.
Instead you should define a default light which will be shown everywhere.
To achieve this go in your level, add a post processing volume and set it to “infinite extent (unbound)”. Than choose a grey default texture as cuemap texture (under ambient cubemap). With the values of tint you can than color your scene and with intensity you can define the brightness.
This normally looks better than unlit mode, is more customizable and doesn’t need a workaround.
I recommend you edit the original post with this new information and other important information you have. At the end of the original post, write EDIT and then necessary information below. Surely the answer is out there somewhere. I cannot help you with anything 2D and sprites. Perhaps you can add a Post Process material to the camera, not sure.
In my GameModeBase.cpp I set the ViewModeIndex of the GameViewport to Enum 2 (unlit). The post I linked above has more details on the different modes you can select.
In addition, I disabled tonemappers because they were causing my sprite colours to be too dark. Below is the final GameModebase.cpp:
#include "KioGameMode.h"
#include "Engine/World.h"
#include "Kismet/GameplayStatics.h"
// Called when the game starts or when spawned
void GameModeBase::BeginPlay()
{
Super::BeginPlay();
UGameViewportClient* GameViewport = GetWorld()->GetGameViewport();
GameViewport->ViewModeIndex = 2;
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
// The command being executed.
FString Command = "ShowFlag.Tonemapper 0";
PlayerController->ConsoleCommand(*Command);
// The below commands are for the shipping
// build.
Command = "r.TonemapperGamma 0";
PlayerController->ConsoleCommand(*Command);
Command = "r.TonemapperFilm 0";
PlayerController->ConsoleCommand(*Command);
Command = "r.Tonemapper.Sharpen 0";
PlayerController->ConsoleCommand(*Command);
Command = "r.Tonemapper.GrainQuantization 0";
PlayerController->ConsoleCommand(*Command);
Command = "r.Tonemapper.Quality 0";
PlayerController->ConsoleCommand(*Command);
}
Thanks to those who commented and bumped my topic.
This is great! I might use this as well to get a very controlled flat lighting and shadows in 3D. Thank you for the update and if you can, mark your own reply as a solution for UE users coming here in the future.
Thanks bro it’s helped me a lot. As I tried your solution I want to let you know that diffuse color makes full metallic materials black but BaseColors (lighting or GBuffer) worked well it renders the material as it is in flat shading. Once again thanks.
even with force debug viewmodes set to 1 if engine detects the build type is shipping it wont let you change to unlit mode, is there any workaround for this?