Is it possible to globally set the filtering method for lightmaps?

Hi!

I am able to change lightmap sizes globally, but from what I can tell, there doesn’t seem to be any access to globally set properties like the filtering method used. I know that I can do it on each individual lightmap via World Settings>Lightmass>Lightmaps, but that isn’t ideal.

I know it may be odd to want nearest neighbour filtering for lightmaps but it’s a stylistic choice so any help would be much appreciated.

Kind regards,

I think easiest way is to modify shader that read those lightmaps. Go to the LightmapCommon.usf and then search ligthmap sampling code.

very late answer, but for posterity’s sake, here’s how you can do this without editing engine code:

if you look into BaseLightmass.ini in Engine/Config, theres a compilation of useful settings you can tweak. one of them is bUseBilinearFilterLightmaps. when a light map, shadow map, ao mask and sky occlusion get encoded, this flag is used to set the filtering to either default or nearest:

Texture->Filter = GUseBilinearLightmaps ? TF_Default : TF_Nearest;

all you need to do is create a lightmass ini in your config folder (Config/DefaultLightmass.ini), and paste the following:

[DevOptions.StaticLighting]
bUseBilinearFilterLightmaps=False

that should be it!

you can also tweak the Packed Light and Shadow Map in the world settings. be aware that it IS clamped to 512 to 4096. i’m not sure if this is technically a good idea, but if you have access to a source build, you can lower it in WorldSettings.cpp under PostEditChangeProperty:

// Ensure texture size is power of two between 512 and 4096.
PackedLightAndShadowMapTextureSize = FMath::Clamp<uint32>(FMath::RoundUpToPowerOfTwo( PackedLightAndShadowMapTextureSize), 128, 4096);

i believe this is the only place it gets clamped.

whilst you’re in the source code, do a global search for GUseBilinearLightmaps ? TF_Default : TF_Nearest and you’ll find every instance where a map gets encoded. here you can also change texture settings (LOD groups, mip-gen, etc.).

y’know, probably don’t do this, there’s a reason the settings are what they are - but it’s good to have the option. if you need to change something here, it’s a good idea to create new flags in Lightmap.cpp, and set them in StaticLightingSystem.cpp, under BeginLightmassProcess() like how GUseBilinearLightmaps is set:

verify(GConfig->GetBool(TEXT("DevOptions.StaticLighting"), TEXT("bUseBilinearFilterLightmaps"), GUseBilinearLightmaps, GLightmassIni));

this way you’re not globally messing with the lightmap system. good luck!

EDIT:
sorry, i have a fundemental misunderstanding of how PackedLightAndShadowMapTextureSize works, so… uh, skip that part. i think all it’ll do is reduce the size of the maps; since maps are atlased and meshes have individual lightmap resolutions, it’ll just unnecessarily create more maps. whoops! just reduce the lightmap resolution on a mesh-by-mesh basis. there might be a way to reduce texel density, but this works just fine.

1 Like