REDxEYE / SourceIO

SourceIO is an Blender(3.4+) addon for importing source engine textures/models/maps
https://discord.gg/XJvhzaXZf3
MIT License
611 stars 54 forks source link

lights in imported .bsp are way too bright. #125

Open whynotll83 opened 2 years ago

whynotll83 commented 2 years ago

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.

REDxEYE commented 2 years ago

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

whynotll83 commented 2 years ago

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.

REDxEYE commented 2 years ago

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

REDxEYE commented 2 years ago

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

TheMaskedMan00 commented 2 years ago

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

REDxEYE commented 2 years ago

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

danielah05 commented 1 year ago

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

whynotll83 commented 1 year ago

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.

REDxEYE commented 1 year ago

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.

whynotll83 commented 1 year ago

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.

Architector4 commented 1 year ago

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 commented 1 year ago

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
REDxEYE commented 1 year ago

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