source-sdk-2013 icon indicating copy to clipboard operation
source-sdk-2013 copied to clipboard

Overlay's LightmapTexcoordOffset doesn't consider Padding for Bicubic

Open WhiteRedDragons opened this issue 11 months ago • 0 comments

There is currently no Shader that actually utilises this, let me elaborate on that. Overlays receive a LightmapTexcoordOffset for Bumped Lightmaps, but apparently this is sent as a float1 and not a float2. All Stock Shaders interpret the LightmapTexcoordOffset as a float2 So when you try to use LightmappedGeneric on an Overlay with a $BumpMap, this will happen: Image

This is more or less a side issue, getting this fixed would mean Stock Shaders (LightmappedGeneric) can also do Bumpmapping on Overlays. Custom Shaders ( for now ) can resolve this issue by interpreting the vertex stream properly. ( as a float 1 ) and only adding the offset to the .x of the LightmapUV This worked flawlessly in the previous SDK.

However here is the crux of this Issue. Due to how Lightmaps are handled in the Lightmap Page, Bicubic Filtering by default samples over the border of its Lightmap, into other Lightmaps. The new SDK hacks a solution for this by adding Padding to Lightmap, the Code for making the LightmapTexcoordOffset on Overlays has not been adapted to consider the padding and is subsequently broken. BTW, it would be very appreciated if the padding was actually documented somewhere, outside of the single comment we have, in a random headerfile, that implies laziness was involved in its creation.. But I digress.

This is what the previously working Code will look like on the current SDK Image

I manually determined the size of the hack-padding, its 2 pixels. For Custom Shaders, you can fix this ( and get bumped overlays ) simply by adding 2.0f * (1.0f / 1024.0f) or 0.001953125f to the LightmapTexcoordOffset.x on Overlays. I don't think there is currently a way to detect whether the current geometry is an overlay, so you will have to figure that part out by yourself. ( make a shader dedicated for overlays or add a parameter to enable the behaviour )

Here are the Results, from the LUX_Lightmappedgeneric_Decal Shader: First Image Unbumped, Second Image Bumped Overlays Image Image

WhiteRedDragons avatar Mar 17 '25 20:03 WhiteRedDragons