Jump to content

Clustered Forward Rendering - Fun with Light Types


Josh

2,604 views

 Share

By modifying the spotlight cone attenuation equation I created an area light, with shadow.

1872820577_arealight.thumb.jpg.b10d08c3403633e2631f7902eae990e0.jpg

And here is a working box light The difference here is the box light uses orthographic projection and doesn't have any fading on the edges, since these are only meant to shine into windows.

boxlight2.thumb.png.566e158f7dabc140ad74df9b6d8e6e51.png

If I scale the box light up and place it up in the sky, it kind of looks like a directional light. And it kind of is, expect a directional light would either use 3-4 different box lights set at radiating distances from the camera position (cascaded shadow maps) or maybe something different. We have a system now that can handle a large number of different lights so I can really arrange a bunch of box lights in any way I want to cover the ground and give good usage of the available texels.

boxlight.thumb.jpg.52fe6f349bafbce9129e41cae5a85855.jpg

Here I have created three box lights which are lighting the entire courtyard with good resolution.

Image1.thumb.jpg.5081f2f6f298d65319d6da880a4ed2d0.jpg

My idea is to create something like the image on the right. It may not look more efficient, but in reality the majority of pixels in cascaded shadow maps are wasted space because the FOV is typically between 70-90 degrees and the stages have to be square. This would also allow the directional light to act more like a point or spot light. Only areas of the scene that move have to be updated instead of drawing the whole scene three extra times every frame. This would also allow the engine to skip areas that don't have any shadow casters in them, like a big empty terrain (when terrain shadows are disabled at least).

Image1.png.f70ce9466d059b2d4b64df06737ad642.png

Spot, and area lights are just the same basic formula of a 2D shadowmap rendered from a point in space with some direction. I am trying to make a generic texture coordinate calculation by multiplying the global pixel position by the shadow map projection matrix times the inverse light matrix, but so far everything I have tried is failing. If I can get that working, then the light calculation in the shader will only have two possible light types, one for pointlights which use a cube shadowmap lookup, and another branch for lights that use a 2D shadowmap.

  • Like 3
 Share

2 Comments


Recommended Comments

I got the shadowmap matrix multiplication thing solved in the box light routine so I should be able to merge it with the spotlight, and internally the shader will just have two light types, with a bunch of options.

Link to comment

Using an angle of 70 degrees, we get a better idea of just how wasteful cascaded shadow maps area.

csm.jpg.6fbe50a479af2f40063000fe8765e4bb.jpg

And keep in mind, the camera frustum almost never looks like the nice neat picture above. Usually it's something like this (not drawn with a realistic angle):

Image3.jpg.52fb9e21a75939af953773bef3d56b40.jpg

Link to comment
Guest
Add a comment...

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

×
×
  • Create New...