SourceIO icon indicating copy to clipboard operation
SourceIO copied to clipboard

lights in imported .bsp are way too bright.

Open whynotll83 opened this issue 3 years ago • 13 comments

I made a test map with a light with 200 brightness, blender made it 5779.8 brightness, manually setting the light to 200watts fixed it but I can't manually change each light if there is more than 1 like the half life 2 maps. sun brightness is perfect tho.

whynotll83 avatar Feb 17 '22 21:02 whynotll83

Hm, can you prepare few test maps for me with different light brightness?

REDxEYE avatar Feb 24 '22 21:02 REDxEYE

I made a simple map with rooms where the lights go from 25 brightness to 200, and a light with 1000 brightness. https://mega.nz/file/arZFHS4T#OAjc3czH61le9OrXquk4N2_t0_8vGFtBVqhEg9j219I the map imported made the 25 brightness light into 97.2122 brightness.

whynotll83 avatar Feb 28 '22 06:02 whynotll83

Ye, i can see that lights are abit too bright, I'll see what I can do

REDxEYE avatar Mar 08 '22 11:03 REDxEYE

Also, light values from BSP doesn not map 1 to 1 in blender I need to do a lot of math to convert them

REDxEYE avatar Mar 08 '22 11:03 REDxEYE

https://github.com/DeadZoneLuna/uSource? does a great job of properly importing the lights (in unity), maybe you guys could work something out?

TheMaskedMan00 avatar Apr 03 '22 19:04 TheMaskedMan00

I've updated the lights a bit, should be better now

REDxEYE avatar Jul 21 '22 09:07 REDxEYE

the problem in the latest release is still really bad, lights on portal 1 maps are especially bad, distorting colors in really bad ways

danielah05 avatar Jan 14 '23 02:01 danielah05

the lights are still broken when I use the default world scale. it only looks correct when I change it to 1. I wonder why it would be difficult to tell the addon when a hl2 light has a brightness of 200 it should change the blender light to 200.

whynotll83 avatar Jan 20 '23 11:01 whynotll83

There is more than 1 way to set the brightness in source light, there is no just brightness 200, it can be vec4(RGB, Brighntess), it can be premultiplied (RGB*Brighntess), also, source uses an unknown light value, it's not watts, nor candela, nor flux.

REDxEYE avatar Jan 20 '23 11:01 REDxEYE

well, to me setting the blender watts number to the one last number after the "rgb" values look the exact same to me in game and blender.

whynotll83 avatar Jan 20 '23 11:01 whynotll83

Having the same issue, I have a guess on what's going on here.

When importing a BSP, the addon has a default world scale setting of 0.01905 set. However, I guess, the light power is set based on how it should look with a world scale of 1.

This same issue exists in Blender in general: if you make a scene with a point light, and then scale it down, the light will be too bright, and its value would need to be adjusted in proportion with the scale for the scaled down scene to look the same.

And, indeed, multiplying the light power by 0.01905 makes it look pretty much exactly how it looks in the original map.

I guess this is a bug to adjust in the import process: use the world scale to also scale the power of the lights, except the sun lights lol

Architector4 avatar Feb 06 '23 16:02 Architector4

Also, for reference, while this isn't fixed, you can just open Blender's text editor, make new script, slam this in, and click "Run script" (little play arrow) to fix all your lights from this

import bpy

lights = bpy.data.lights

for l in lights:
    if l.type == 'POINT':
        l.energy = l.energy * 0.01905

Architector4 avatar Feb 06 '23 17:02 Architector4

Map scale is used in light energy calculation, but it does not always work. I'm working on better function to convert power in refactor branch

REDxEYE avatar Feb 06 '23 17:02 REDxEYE