Jump to content

  • Log In with Google      Sign In   
  • Create Account


Point light clipping


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 solenoidz   Members   -  Reputation: 527

Like
0Likes
Like

Posted 11 November 2012 - 10:05 AM

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.

Attached Thumbnails

  • room.jpg
  • room1.jpg


Sponsor:

#2 MrDaaark   Members   -  Reputation: 3551

Like
1Likes
Like

Posted 11 November 2012 - 10:55 AM

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.

#3 Ohforf sake   Members   -  Reputation: 1798

Like
3Likes
Like

Posted 11 November 2012 - 11:30 AM

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.

#4 solenoidz   Members   -  Reputation: 527

Like
0Likes
Like

Posted 12 November 2012 - 05:27 AM

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.

#5 Ashaman73   Crossbones+   -  Reputation: 7134

Like
0Likes
Like

Posted 12 November 2012 - 06:24 AM

I have a similar issue. It somewhat depends on your engine. None spherical bounding volumes for point lights bear the danger of clipping wanted 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.

#6 solenoidz   Members   -  Reputation: 527

Like
0Likes
Like

Posted 14 November 2012 - 12:30 AM

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 Posted Image

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

#7 Ashaman73   Crossbones+   -  Reputation: 7134

Like
1Likes
Like

Posted 14 November 2012 - 12:46 AM

What about 2D attenuation maps, or even 3D cube maps ?

Really close Posted Image 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).

#8 solenoidz   Members   -  Reputation: 527

Like
0Likes
Like

Posted 14 November 2012 - 02:58 AM

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..

#9 Ashaman73   Crossbones+   -  Reputation: 7134

Like
0Likes
Like

Posted 14 November 2012 - 05:00 AM

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..

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.

#10 solenoidz   Members   -  Reputation: 527

Like
0Likes
Like

Posted 14 November 2012 - 09:09 AM

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.

#11 Ohforf sake   Members   -  Reputation: 1798

Like
0Likes
Like

Posted 14 November 2012 - 12:51 PM

For future reference, this is the presentation I meant:
http://advances.realtimerendering.com/s2010/Kaplanyan-CryEngine3(SIGGRAPH%202010%20Advanced%20RealTime%20Rendering%20Course).pdf

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

Edit: Fixed broken link.

Edited by Ohforf sake, 14 November 2012 - 12:56 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS