Jump to content


Photo

Feature request: emissive materials/volumetric lights

emissive postprocess effects

207 replies to this topic

#26 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 25 September 2018 - 02:50 PM

*
POPULAR

That should do.

 

Here's what I got in a first attempt.

https://github.com/d...b69f325693dbeb7

 

It's lacking the depth test and distance to light - that's for the next time.

Attached Thumbnails

  • Untitled.jpg

  • Bikerdude, Judith, HMart and 5 others like this

#27 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 25 September 2018 - 03:14 PM

*
POPULAR

Distance to light

 

Attached Thumbnails

  • Untitled.jpg

  • Bikerdude, HMart, SiyahParsomen and 3 others like this

#28 RPGista

RPGista

    Advanced Member

  • Member
  • PipPipPip
  • 1595 posts

Posted 25 September 2018 - 05:35 PM

Thats awesome. Really fast work, man. I checked out the original test file and thats a pretty cool look, gives quite the sense of atmosphere with this simple light effect. This will look specially cool on street lights, with a bit of fog... Let me see if I get this right, is this volumetric light a real light (does it cast shadows like the example with the balls bouncing around, on that shader site)? So we could get real light shafts that light things dynamically?

Edited by RPGista, 25 September 2018 - 05:38 PM.


#29 HMart

HMart

    Advanced Member

  • Member
  • PipPipPip
  • 747 posts

Posted 25 September 2018 - 06:41 PM

Man that was fast and is a nice start! Now if i may, you could make it so the effect is stronger near the flame and gets softer as it gets way and perhaps implement some faint lens flares effect  (optional) and imo it will be perfect!

 

https://1yearframes....andle-light.jpg minus the lens flare.

Btw sorry for the physics lesson :P but because duzenko "asked", light halos is not 100% caused by volumetric lighting but some of it is, light halos or flares are also caused by light refracting inside your eye's, and spooks imo sun shafts or god rays is volumetric lighting, at least in real life it is, they are caused by the same thing, light dispersing around and illuminating small particulates (dust, ice, etc) in the air.

 

The always "trustworthy" wikipedia... ;P

 

https://en.wikipedia...metric_lighting

 

 

 It allows the viewer to see beams of light shining through the environment; seeing sunbeams streaming through an open window is an example of volumetric lighting, also known as crepuscular rays.

In volumetric lighting, the light cone emitted by a light source is modeled as a transparent object and considered as a container of a "volume": as a result, light has the capability to give the effect of passing through an actual three-dimensional medium (such as fogdustsmoke, or steam) that is inside its volume, just like in the real world.


Edited by HMart, 25 September 2018 - 06:43 PM.


#30 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 26 September 2018 - 12:57 AM

Looks cool, so you kind of achieved the light bloom with volumetric light. The problem with that is we often need light source in a different place than the light model, so it's no too close to a wall for example. I assume we'd need to use a non-shadow casting light source for this effect + another light that would be a "proper" light source with shadows. That's at the cost of 2 overlapping lights hitting the same model, so I wouldn't use it like this. That example from wikipedia with light coming through a window might be a better test case.



#31 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 26 September 2018 - 02:29 AM

Thanks

 

 

Thats awesome. Really fast work, man. I checked out the original test file and thats a pretty cool look, gives quite the sense of atmosphere with this simple light effect. This will look specially cool on street lights, with a bit of fog... Let me see if I get this right, is this volumetric light a real light (does it cast shadows like the example with the balls bouncing around, on that shader site)? So we could get real light shafts that light things dynamically?

The halo on the screenshots is indeed drawn on top of each light, using that light's position. The lights are "regular", i.e. in this case it's the Closemouthed Shadow mission.

Now the halo here is a sphere just to start with something. For a shaft we would need to bind the light's falloff and projection. That's where it's starting to get costly but we should be let the user to turn it off depending on his GPU speed.

Technically it's possible to add shadows, but ATM I only know how to that with shadow maps. The stencil shadows only work with fragments that write to depth buffer (i.e. solid geometry) AFAIK.

 

 

Man that was fast and is a nice start! Now if i may, you could make it so the effect is stronger near the flame and gets softer as it gets way and perhaps implement some faint lens flares effect  (optional) and imo it will be perfect!

 

https://1yearframes....andle-light.jpg minus the lens flare.

Btw sorry for the physics lesson :P but because duzenko "asked", light halos is not 100% caused by volumetric lighting but some of it is, light halos or flares are also caused by light refracting inside your eye's, and spooks imo sun shafts or god rays is volumetric lighting, at least in real life it is, they are caused by the same thing, light dispersing around and illuminating small particulates (dust, ice, etc) in the air.

 

The always "trustworthy" wikipedia... ;P

 

https://en.wikipedia...metric_lighting

 

Yeah, about the three physical effects (as far as I understand them)

  • Lens flare. Honestly, not sure how that fits the medieval first-person-look setting. Anticipating negative feedback - want some formal discussion first.
  • In-eye refraction. I must have experienced that myself, but can't remember what it looked like. And I'm not sure about the math behind that.
  • The air dust/fog. That's what I am focusing on with this shader.

The god-rays is all mumbo-jumbo for me. Something to make fun in the context of game-makers and nVidia marketing buzz. Consider me backward in that department.

 

 

Looks cool, so you kind of achieved the light bloom with volumetric light. The problem with that is we often need light source in a different place than the light model, so it's no too close to a wall for example. I assume we'd need to use a non-shadow casting light source for this effect + another light that would be a "proper" light source with shadows. That's at the cost of 2 overlapping lights hitting the same model, so I wouldn't use it like this. That example from wikipedia with light coming through a window might be a better test case.

The good thing is we can add the required position offset to volumetric center via light material parameters.

We should be able to use the same light for volumetric and everything else. In fact, if we want the shadows to be taken into consideration, I would go with single light for everything.

Now the approach I am following here does not duplicate on model interactions. It's using the light frustum triangles (12 in total). That's costly on the fillrate, but should not be a problem for proud GTX 1070+ owners (yet).

 

Could you add a custom-projection light to the test map? Something like the barn-window lights in Reap As You Sow. Using a custom light material as well.

https://www.istockph...51658-138368127


  • Judith, SiyahParsomen and RPGista like this

#32 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 26 September 2018 - 02:34 AM

Sure, I'll whip up something when I get back from work. Btw. I just checked the cost of a "glow non shadow casting light" + regular light source. That shouldn't be much of a problem. At least in the test scene the cost was just a few triangles more + one drawcall.



#33 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 26 September 2018 - 02:39 AM

Btw. this is how UE does god rays / light shafts: https://docs.unreale...ows/LightShafts

 

And volumetric lights (lightmaps): https://docs.unreale...metricLightmaps



#34 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 26 September 2018 - 09:30 AM

There you go: https://we.tl/t-MXHnEiCrNx

 

I used _nofalloff instead of light falloff image for simplicity.



#35 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 26 September 2018 - 09:48 AM

There you go: https://we.tl/t-MXHnEiCrNx

 

I used _nofalloff instead of light falloff image for simplicity.

Oh no, the lamps are gone...

 

I can see 6 lights total in that room (well, 5 plus the ambient)

Do we want to add volume to all of them? Aslo, the projected floor light has a big gap before the window - should it be touching the window?



#36 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 26 September 2018 - 09:56 AM

Try this one, open the layers window (Ctrl+L), and uncheck the other_lights layer. You should see only the ambient_world and projection light. Other lights are non-shadows and they're there to fake light bounces a bit. I hid them, but I forgot that reloading the map unhides them ;)

 

https://we.tl/t-bSDmy2DoUU



#37 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 26 September 2018 - 10:54 AM

I can use r_singleLight for now

 

Here's how it looks with projection texture.

 

TODO: depth check.

Attached Thumbnails

  • Untitled.jpg

  • Bikerdude, HMart, nbohr1more and 1 other like this

#38 RPGista

RPGista

    Advanced Member

  • Member
  • PipPipPip
  • 1595 posts

Posted 26 September 2018 - 01:29 PM

Incredible, very cool... I see interesting differences in the density along the light beam, giving it shape. Its funny that the project light used in the scene doesnt work now that you see the body of the light beam, we would need a proper light shaft that has the shape of the window's shilouette for it to work perfectly.

 

I wonder if the volumetric light/fog could be animated like in this other concept from that humus gentleman, it looks pretty cool: http://www.humus.nam...p?page=3D&ID=70 . Is that something your shader would allow? Really liking where this is going.


Edited by RPGista, 26 September 2018 - 01:30 PM.


#39 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 26 September 2018 - 01:38 PM

Incredible, very cool... I see interesting differences in the density along the light beam, giving it shape. Its funny that the project light used in the scene doesnt work now that you see the body of the light beam, we would need a proper light shaft that has the shape of the window's shilouette for it to work perfectly.

 

I wonder if the volumetric light/fog could be animated like in this other concept from that humus gentleman, it looks pretty cool: http://www.humus.nam...p?page=3D&ID=70 . Is that something your shader would allow? Really liking where this is going.

I'm walking about the same path, so it should allow that sort of animation at some point



#40 Bikerdude

Bikerdude

    Mod hero

  • Member
  • PipPipPipPipPip
  • 20281 posts

Posted 26 September 2018 - 04:20 PM

Incredible, very cool... I see interesting differences in the density along the light beam, giving it shape.

Yes that and the gaps in the shader line-up with the shadows, very very cool!



#41 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 27 September 2018 - 01:44 AM

I can use r_singleLight for now

 

Here's how it looks with projection texture.

 

TODO: depth check.

 

Hmm, so using it like that doesn't make much sense. The projection image + volumetric light won't look good because of the shape and position of the projection light. Projection fakes the effect. To get best results, you'd have to make regular light and window with physical bars.



#42 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 27 September 2018 - 01:51 AM

 

Hmm, so using it like that doesn't make much sense. The projection image + volumetric light won't look good because of the shape and position of the projection light. Projection fakes the effect. To get best results, you'd have to make regular light and window with physical bars.

Right.

Or, you could fix the light frustum - resize and reposition.



#43 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 27 September 2018 - 02:02 AM

That in turn will make the projection image too skewed. Projection looks better when the light is pointed down almost vertically. And if you want to make the light shaft look good, you'd have to position the light behind the window, so it's lined up with it.



#44 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 27 September 2018 - 08:11 AM

you'd have to position the light behind the window, so it's lined up with it.

Can we try that?

Also, can you set different light materials to lights you want to show up a volumetric? Right now they all seem to use the lights/glowtest/window01 material.

Use the new "volumetric" keyword on that light material.



#45 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 27 September 2018 - 08:24 AM

I think this will be a better idea:

obraz.png

 

I made a quick model that has physical bars and I put a spotlight behind it, without any fake projections. This way it casts real shadows and it should look better with your current solution. If you resolved the depth problem, it should look almost perfect, I'd say :)

 

Here's the next version: https://we.tl/t-PKqElRhXo3



#46 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 27 September 2018 - 08:30 AM

I think this will be a better idea:

 

 

I made a quick model that has physical bars and I put a spotlight behind it, without any fake projections. This way it casts real shadows and it should look better with your current solution. If you resolved the depth problem, it should look almost perfect, I'd say :)

 

Here's the next version: https://we.tl/t-PKqElRhXo3

That could work, however hurtful for performance.

Please see the material remarks from post #44



#47 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 27 September 2018 - 08:45 AM

At which stage should I put the keyword?
 

lights/glowtest/light_shaft

{    
    volumetric
    {
        forceHighQuality
        map    lights/falloff_exp2
        colored
        zeroClamp
    }
}

Or:
 

lights/glowtest/light_shaft

{    
   
    {
        volumetric
        forceHighQuality
        map    lights/falloff_exp2
        colored
        zeroClamp
    }
}


Edited by Judith, 27 September 2018 - 08:46 AM.


#48 RPGista

RPGista

    Advanced Member

  • Member
  • PipPipPip
  • 1595 posts

Posted 27 September 2018 - 09:14 AM

Indeed. Real shadow projections are ideal, but very costly. Light projections are used exactly to simulate real projections in a much cheaper way. It is a bit of a head scratcher, because we dont really have a parallel light that has shapes (that we could contain in a "shaft"), and the spotlight trick usually works because you have the spotlight projecting the texture on the floor (with quite an angle since there usually isnt much space available), a second point light close by lighting the area to fake bounced light (optional), and often a patch model with a translucent texture coming from the window, to fake the volumetric light effect. At least thats the setup I think Ive seen done a few times in maps. 

 

Would it be possible to apply this volumetric shader to patches/models? If yes, it would be possible to create patch/mesh shapes for any window, with the angle you want. But I have no clue if this is actually how this would be solved.


Edited by RPGista, 27 September 2018 - 09:21 AM.


#49 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 27 September 2018 - 09:15 AM

At which stage should I put the keyword?
 

Or:
 

In the beginning, before the stages (option 1)

If you put it in a stage, it would mean making the stage volumetric (and I think we're not ready for per-stage processing)



#50 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 27 September 2018 - 09:30 AM

In the beginning, before the stages (option 1)

If you put it in a stage, it would mean making the stage volumetric (and I think we're not ready for per-stage processing)

 

Ok, I made the change, only the spot light uses the light_shaft material now, other lights use stock falloff_exp2. https://we.tl/t-lGvhXwFaYI

 

As for the performance, the window is 338 tris, shadow tris in that scene take up around 500. It's easier to use a physical model right now, as you don't have to line up things. Fake projection it will be a PITA anyway, since you'll have to make a window noshadows, carve some space behind to line up the light with projection etc. IMO the order of testing should be: 1) a physical model, 2) a plane with alphatest transparency, 3) a light with projection texture.


Edited by Judith, 27 September 2018 - 09:47 AM.




Reply to this topic



  



Also tagged with one or more of these keywords: emissive, postprocess, effects

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users