Jump to content
The Dark Mod Forums

Supporting bulb scale (minimum radius) for lights


MirceaKitsune

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:

0.png.83d18ef43d0d2dd0c1058fb7b3a3a958.png1.png.8571357db176c722b9f78ec1f183ed9f.png2.png.1751d4606eef90e75d9fcc3333d000c2.png

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

Screenshot_20230705_230305.jpg.846117746b02fe0c59841d58424ff7df.jpg

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:

 

http://www.indiedb.com/mods/the-dark-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.

Guest
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

    • taaaki

      Apologies for the unplanned downtime. A routine upgrade did not go to plan, and the rollback had its own issues
      · 2 replies
    • freyk

      Got tdm 2.12 running on my android phone. For more info, read the latest post in the topic on subforum techsupport.
      · 2 replies
    • snatcher

      TDM Modpack v4.5 released!
      Introducing... The Loop
      · 1 reply
    • Ansome

      Taking a break to alleviate burnout. In retrospect, I probably shouldn't have jumped into a map-making contest so quickly after just finishing another project and especially with my busy schedule, but I do believe I have something that the community will enjoy. No clue if I'll be able to finish it on time for the competition if I factor in a break, but I'd rather take my time and deliver something of quality rather than engage in development crunch or lose part of the map's soul to burnout.
      · 1 reply
    • Skaruts

      Working on an update for my mission By The Cookbook. If anyone that played it has any further bugs to report, please let me know.
      I posted more details about the update in the mission thread.
      · 1 reply
×
×
  • Create New...