Jump to content
The Dark Mod Forums

Supporting bulb scale (minimum radius) for lights


Recommended Posts

Though this is related to PBR as a component in getting it done right (like reflection probes) I thought it's an improvement of its own that's worth discussing. I don't know if this is implemented or estimated in some form, but working with light entities in my own FM's I haven't seen any spawnargs for it so I presume it's not.

At the moment lights in TDM act as zero-scale points, light sources have no actual radius. I know what you might be thinking: Of course lights have a radius, it's the box that decides how far a light shines and what it affects! What I'm referring to is not the range but the emission radius, representing the scale of the bulb itself: Think of it as a minimum radius... at the moment lights only have a maximum radius, the minimum is currently a point. In modern engines this affects both specularity and shadow softness as well as how the light is distributed.

Like most engines we shouldn't need anything more than a float describing the size of the bulb, a simple sphere ought to be enough... given we already work with radius boxes, we could instead use a separate box which would give us better control with unevenly shaped bulbs. Every default light entity should of course be updated to use this: Torches / candles would set it to the average size of their flame particles, gas / electric lamps should have it represent the scale of the light bulb or the lamp head.

If done right this can greatly improve our graphics and add more realism, but as with most things it's not going to be that simple. Also this would create changes to the lightgem in all FM's but very minuscule ones that shouldn't even be detectable. There's 3 different components I presume we have to tackle independently.

  1. Soft shadows: Shadowmap softness is probably the easiest, just add the average bulb radius to their value.
  2. Specularity: At the moment all lights seem to produce specular orbs of the same fuzziness on shiny surfaces. What we probably want is for lights that keep their min radius 0 to produce a fully sharp orb or dot, softness is added to each light's ball based on this radius.
  3. Light projection: The biggest aspect is changing how light is distributed, the projection texture / falloff material would emanate very differently. Everything inside the bulb would shine at the intensity of the center pixel and should start fading from the min radius toward the max, the projection texture would get slightly inflated like a balloon. The best solution (which also accounts for blur) seems like a 2D shader that copies the light texture onto itself at slightly different offsets to make it fuzzy: There's already a blur filter that does just that when you're underwater for example, we could to get away with doing the same thing to light textures using the min radius as the offset parameter. As lights typically don't change scale, this should be possible to do only once at map start rather than every frame including for moving lights like torches, this way we should have no performance loss.
Link to comment
Share on other sites

As reference, here's a few Blender renders showing how light radius works there... for accuracy it's the Eevee engine which uses the same lighting technology as OpenGL (no raytracing). 0, 0.25, 0.5 in order:


This shows what it's doing better, though like I said we could use another box like for the standard radius.


I believe Eevee simulates the light source at a random position within the sphere for every sample. Obviously this would murder our performance, hence why I'd use a shader to emulate this behavior in 2D on the light texture itself.

Link to comment
Share on other sites

That indeed sounds useful, but those Eevee renders do seem to be more advanced than what TDM can do, like those reflections and shadows, seem to be way ahead, is that really simple OpenGL lighting? Seems more like some kind of modern PBR system.

Edited by HMart
Link to comment
Share on other sites

12 minutes ago, HMart said:

That indeed sounds useful, but those Eevee renders do seem to be more advanced than what TDM can do, like those reflections and shadows, seem to be way ahead, is that really simple OpenGL lighting? Seems more like some kind of modern PBR system.

True: They're only meant to be representative, just a view of how big (non-zero-point) lights generally work. Lots of things TDM lighting can't do compared to a render engine, totally different system. Would be a nice part to have in some form and give us more realistic light: For instance the flame of a torch will be less sharp than that of a candle... if you're aware of this limitation and look closely at the two to compare them, you can see they both act as a dot of light and only the radius differs.

  • Like 1
Link to comment
Share on other sites

There was a TDM branch where "r_softShadowsRadius" was an entity arg. It was never added to core because there were still so many other issues with soft shadows behavior.

Please visit TDM's IndieDB site and help promote the mod:




(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • The Black Arrow

      Happy birthday to me!
      Yes, today's my birthday and as much as I want to play The Dark Mod, I won't until it's late Autumn, where it should be a bit chilly in my place and there's some wind too.
      For now, it's time to enjoy my birthday, if any of you want to play a great fan mission in my honour...Well that's asking too much, just play the mission because it's fun, not because of me, enjoy it yourself! 💪
      · 4 replies
    • nbohr1more

      New texture wiki article created: https://wiki.thedarkmod.com/index.php?title=Creating_textures_from_Ornate_Photos
      · 2 replies
    • Xolvix

      Took a break from TDM until I got my backlog under control. It's been months and it's still not "under control". Damnit.
      · 4 replies
    • Ansome

      I sleep well at night knowing the player will never see the absolute nightmare that is my sealing brushwork outside the playable area. Only the pointfile can judge me now.
      · 4 replies
    • JackFarmer

      Somehow I admire the fact that the material from Dune has now been filmed for the third time. Personally, I could never do much with the material, but as a child of the 80s, I of course know the David Lynch movie...and that movie was at least funny!
      · 2 replies
  • Create New...