Sign in to follow this  

Point light clipping

This topic is 1890 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.
I'm building a simple indoor level that is lit using point lights. The renderer uses deferred lighting. I have problems with point light placed near walls and corners to that influence/illuminate the next room/wall. I need a point light placed in a room to only illumunate the room it belongs to.
How can I achieve such thing in a matter of speed and simplicity ? Do I need to send some kind of "influence box" corners to the pixel shader and clip lit pixels aganst it in the shader ?
Thank you in advance.

Share this post


Link to post
Share on other sites
Easy solution is not to place point lights close enough to bleed into other rooms. A few games have used that as their solution.

Or you can have the point lights be attached to each room model, and then draw each room as a separate model with only it's own lights.

Share this post


Link to post
Share on other sites
Cryengine allows you to define custom light geometry to solve exactly that problem. I don't remember the details, so you will have to look it up, but I think you create a custom mesh for those lights which is rendered with depth test enabled and which writes a stencil mask. The stencil mask is then used in the pass where you render the light source to restrict the light source's influence. I believe the exact stencil modes depend on whether or not the camera is in the mesh.
So if you have a light source next to a wall, the custom light mesh would be half a sphere with a disc closing the sphere to the wall.

As I said, my memory is a bit foggy on this, but if you look over crytek's major presentations/papers you should find it.

Share this post


Link to post
Share on other sites
Thank you.
I'll try to stay away from additional meshes for now. I implemented simple axis aligned boxes that enclose light areas and it works almost fine, but since they are axis aligned, the rooms in the level should be also axis aligned if the need to be lit with such lights. Probably I should transform the boxes later on, and pass the matrix to the pixel shader to transform the world position of the pixel being lit to the space of that transformation matrix.

Share this post


Link to post
Share on other sites
I have a similar issue. It somewhat depends on your engine. None spherical bounding volumes for point lights bear the danger of clipping [i]wanted [/i]light bleeding,ie think of a door connecting the both rooms in your example. So, Daaarks sugguestions has the best price-value ratio.

My engine is capable of rendering lot of light visible sources (>100), in this case I use it to assign several point lights to a logical light source. I.e. instead of one strong point light for a torch, I use 1 main point light with limited radius to avoid most of the light bleeding and a few fill lights, with an offset reaching into the room to give it an ambient light distribution. The fill lights don't affect the specular component to prevent multiple hi-lights, only the diffuse.

Share this post


Link to post
Share on other sites
Thanks
I don't wanna use Daaark suggestion because my level geometry won't let me. I can't break the level to separate rooms, based on lamps they have placed into.
Right now I use lights clipped against axis aligned boxes, that are properties of the lights. When I need the light to bleed into another room from a door or something, I use cube shadowed light or spot light with shadows.That way light won't bleed from a closed door etc..
Ashaman73, as I understand it, you are modeling some kind of "area" light with small point lights. That is sure a good idea - my engine is also deferred light count isn't that crucial.
I'm thinking about these things. :

1.Use geometry to simulate "area" lights. For example, a box encloses the lights influence to the boundary of the room, and another small box reaches from the open door to illuminate the corridor. At the time of rendering, render those boxes that belong to the light in question.
In the pixel shader, sample the G-Buffers with the screen position of the pixel being processed. Use lights usual attenuation. Gotta try this one. It is pretty close to what @Ohforf sake suggested about crytek.

2.Use light attenuation maps/textures. Right now I use 1D attenuation map to make the lights attenuation flexible and to avoid complex and expensive function in the shader. What about 2D attenuation maps, or even 3D cube maps ? Light propagate only where the 2D map ( for example in X/Z plane) allows. Want the room light to also illuminate the corridor without illuminating the next room, just draw it [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

What do you think. Am I missing something that would render those methods unpractical ?

Share this post


Link to post
Share on other sites
[quote name='solenoidz' timestamp='1352874648' post='5000807']
What about 2D attenuation maps, or even 3D cube maps ?
[/quote]
Really close [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Attenuation describes the light intensity depending on the distance, you should keep this. But many games uses projective light maps, which are masking out the light, similar to shadow maps. The cheapest light projection is done for spotlights (a simple 2d alpha texture), but you could although use cube maps for omnilights or parabolid texture mapping. It is kind of shadow mapping with static shadows(shadow maps do a depth comparision, whereas a projective light map is just a alpha mask).

Share this post


Link to post
Share on other sites
Hmr, ok.. I support those kind of projective lights so it won't be a big deal to try out how it comes along.
But man, with all those dynamic and per pixel lightings and stuff, sometimes I'm missing the light maps from the past..and the nice and fast illumination they offer..

Share this post


Link to post
Share on other sites
[quote name='solenoidz' timestamp='1352883523' post='5000832']
But man, with all those dynamic and per pixel lightings and stuff, sometimes I'm missing the light maps from the past..and the nice and fast illumination they offer..
[/quote]
Lightmaps are still often used in current gen (e.g. UDK,Source), though the next generation of engines (and hopefully consoles) will start to support dynamic global illumination.
Lightmaps are almost the optimal solution if you have a small,static scenes, performance and qualtiy wise, but once you start to use dynamic scenes, lightmaps get really quickly clumpsy. As said, I've similar issues with my game and I'm still looking for some good (fake) solutions.

Share this post


Link to post
Share on other sites
Yeah, I've also heard games are still using lightmaps. Unfortunately lightmaps won't work well for me because
1. I have a WYSIWYG editor and they need slow preprocessing.
2.I need dynamics scenes with physics objects, including light properties animation( flicker, color cycle etc.) and dynamic shadows.
3.I use geometry instancing and in other words reuse mesh data and render an instance in several places. I'm not sure how a light map could be made to cope with a city in which any other building is a mesh reference or instance.
4. I need outdoor scenes with trees, sunlight and shadows. I'm not sure if a single lightmap could cope with a big scene and shadow and overall lighting quality.
5.Lighting quality is seems to be per-texel, not per pixel and I will probably need big lightmap textures and lots of vid RAM for big scenes.

Share this post


Link to post
Share on other sites
For future reference, this is the presentation I meant:
[url="http://advances.realtimerendering.com/s2010/Kaplanyan-CryEngine3(SIGGRAPH%202010%20Advanced%20RealTime%20Rendering%20Course).pdf"]http://advances.realtimerendering.com/s2010/Kaplanyan-CryEngine3(SIGGRAPH%202010%20Advanced%20RealTime%20Rendering%20Course).pdf[/url]

They call it "Clip Volumes" (see slides 68 - 74).

Edit: Fixed broken link. Edited by Ohforf sake

Share this post


Link to post
Share on other sites
Sign in to follow this