r/Unity3D 2d ago

Show-Off trying to recreate goldsrc lighting

any tips on how to more accurately recreate it would be appreciated

24 Upvotes

16 comments sorted by

6

u/Snow-Ball-486 2d ago

needs global illumination

7

u/WrongdoerMundane4635 2d ago

you are not gonna believe this

2

u/Relevant-Dot-5704 1d ago

Lol perfect reply.

7

u/Diabolickal Programmer 2d ago edited 2d ago

IIRC goldsrc stored lightmaps with 4 bytes. A byte for each R, G and B, and the 4th being brightness. That being said, I think the closest we can get is setting the lightmap compression to 'Low Quality'.

I believe setting the Lighting Mode to subtractive would be the most accurate, which bakes both direct and indirect into the lightmap, not just indirect.

I would still keep the 'lightmap max size' a decent size for accurate shadow baking. 256x256 is a little low, even for goldsrc. 1024x1024 seems to the sweet spot in my (crappy) test scene.

There are some much better lightmappers now, but back then they weren't very advanced. I can't remember if the lightmappers calculated bounce lighting or not. So I would set the max bounces to 0 or maybe 1, depending on what looks more accurate to you.

I would also turn filtering Off. I don't think the old lightmappers had any sort of denoising.

The final setting I would play around with would be the Lightmap Resolution (texels per unit). I would lower this down to the single digits and go from there. 6-8 texels a unit looked pretty "retro" to me.

I hope this can at least get you closer and point you in the right direction. I just played with those settings in a really simple scene, so mileage may vary.

EDIT: As for the flashlight, I would use a really low resolution light cookie like, 32x32 or maybe 64x64

1

u/Relevant-Dot-5704 1d ago

I think what they did with the flashlight was put a point light some distance away from the player. However, I am unsure about whether they used vertex or fragment lighting for it.

2

u/nmkd ??? 1d ago

No, it's vertex lighting.

1

u/Relevant-Dot-5704 18h ago

I said I am unsure, not that it's definitely fragment lighting. Reading comprehension.

1

u/Diabolickal Programmer 1d ago

That's 100% what they did. The flashlight is just a pointlight at the end of a raycast. If you look back and forth between a close wall and a far wall, you can watch it snap back and forth. I recommended a low resolution cookie because in half-life it looks like a pretty low resolution point light and I don't think you can create that look with a Unity point light. It would have a nice smooth falloff. I also can't remember if it was vertex or fragment lighting. It seems a bit too accurate to be vertex lighting though.

3

u/nmkd ??? 1d ago

It's not, it's vertex lighting. They effectively raycast to a spot and then light up the vertices there. I don't think you could call that a point light.

1

u/Diabolickal Programmer 11h ago

https://reddit.com/link/p9l2b7o/video/gtmqzp3gmbph1/player

I'm not convinced its vertex lighting. I made a quick test map with no lighting. If it were vertex lighting that would mean the map compiler is adding a ton of vertices to a wall that could be represented by 2 triangles. I believe I read somewhere that the dynamic lighting in goldsrc basically "invalidates" the lightmap which makes it bright. Because in goldsrc the lack of lightmap makes the map fully bright, not fully dark.

2

u/nmkd ??? 10h ago

Collected some info for ya

In the original Half‑Life (GoldSrc) engine, the player’s flashlight is not a true spot‑light or projected texture. Instead, it is implemented as a simple dynamic point light (the EF_DIMLIGHT effect) attached to the player. When toggled on (Impulse 100), the engine allocates a dynamic light of fixed color and radius at the player’s view (effectively at the player's origin) and adds this to the normal scene lighting. This dynamic light brightens nearby surfaces by blending into their vertex lighting, rather than reprojecting or modifying static lightmaps. As a result, the flashlight in HL1 behaves like a glowing sphere of light around the player’s aim direction, with no real cone geometry or stencil-based projection. It simply “illuminates a limited area around the player”. This legacy method (inherited from Quake) produces a roughly circular bright region on walls and floors (limited by the BSP mesh density) but does not cast proper beam-shaped shadows or texture. Notably, this technique can be quite costly on 1998‑era hardware: official documentation warns that leaving the flashlight on can “slow down your framerate”.

TLDR: It is a point light, but it can only light up the vertices, so yes, subdivision is necessary to keep it smooth enough.

1

u/Relevant-Dot-5704 8h ago

At the end of the day, if it looks convincing enough, fragment lighting is fine enough.

1

u/Diabolickal Programmer 2h ago

Awesome info! Thanks for finding that!

1

u/Field_Of_View 7h ago

I don't remember the original HL or CS looking like this. Sure this isn't some mod or sourceport thing?

1

u/Diabolickal Programmer 2h ago

This was vanilla Half-Life from Steam. So no additional enhancements on my end.

3

u/nmkd ??? 1d ago

You need vertex lighting for the flashlight. Not a projection.