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?
hi people who know c++, because i don’t
can you tell me how i can make EXACTLY this blueprint as c++ and have it be UNLIT ?
my game is ready to be shipped i just need to make it unlit and i read this but don’t know how to do it.
please give me a reply and tell me exactly where to just copy paste it to make this work.
#if UE_BUILD_TEST || UE_BUILD_SHIPPING
Ar.Logf(TEXT("Debug viewmodes not allowed in Test or Shipping builds."));
ViewModeIndex = VMI_Lit;
#else
So it just forcefully sets the view mode to lit in shipping build no matter what option you choose. So, what do we do? Well, one way is to create our own console command that actually works in all builds. Or just replicate the behavior of this Unreal function and put it in a blueprint library and call it from C++ or blueprints respectively. That’s what I intend to do now.
Here’s the solution that actually works:
In your C++ blueprint function library(create one if you don’t already have one):
Header:
To make the textures look like they look when they’re created. Also better performance in 2D games. A good engine should have switches on and off for everything, so that people can configure and get the best out of it. It’s a good development approach and is known as a “feature flag”.
It is possible.
Well, this will change how the textures look and they won’t look like they are when they were created. It’s very important for 2D games to preserve the original look of how it looked when they were created in image editing software.
Not really. It looks more different to the original look, so it’s not better, just different. Which is worse for 2D games.
Is there a way to make this work with post-processing? I’ve tried bypassing it and enabling post-processing in the engine flags, but it just turns it back to lit mode.
If you want to disable some specific features and leave the others, you can try switching engine flags yourself. Here’s a function to disables everything:
But be aware, this disables everything, the whole rendering F.Rendering = false. You won’t see anything. So only use and disable the ones that you want to disable. There are some flags here for the lights, that might be what you want without disabling all the post processing functions.
I see that everyone has a very good answer to the above problem. I have wondered for a long time. Thanks to everyone’s answers, I have the answer to my problem.