Jump to content
Posted 02 October 2012 - 11:31 PM
Posted 03 October 2012 - 07:48 AM
Posted 03 October 2012 - 09:38 AM
Edited by mv348, 03 October 2012 - 09:40 AM.
Posted 04 October 2012 - 07:21 AM
Adjusting viewport allows you to dynamically change shadow map resolution without reallocating textures. In general you need less pixels for small/distant lights.
Can you give me a little more detail about that kind of approach? Are you talking about deferred shadows? Also, why would you go through the trouble of using an enlarged viewport instead of a texture array? Are texture arrays undesirable for any reason?
Posted 04 October 2012 - 07:55 AM
Yes, with deferred shadows you collect lighting information into a full screen buffer (sometimes called a shadow collector), which is later used by the lighting shaders.
Are you talking about deferred shadows?
As Lauris mentioned above, you can dynamically resize your viewports to have different resolution shadow maps. e.g. a 2048^2 texture could hold 4*1024^2 maps, or 1*1536^2 plus 7*512^2 maps.
Also, why would you go through the trouble of using an enlarged viewport instead of a texture array? Are texture arrays undesirable for any reason?
Edited by Hodgman, 04 October 2012 - 08:01 AM.
Posted 04 October 2012 - 10:12 PM
Besides "deferred shadows", regular deferred shading can be implemented in the same "recycling" manner without making use of a full-screen shadow collector. Instead you simply render the shadow map(s) for a light, and then perform the deferred light accumulation for that light, then goto next light, etc...
for each light: render all objects from lights point of view (depth only) into shadow map render all objects from cameras point of view (depth only) testing for shadows. if it is in the shadow, set the full screen texture pixel to 1. blur the shadow texture render all objects, darkening each pixel if the texture element is 1.
Edited by mv348, 04 October 2012 - 10:12 PM.
Posted 04 October 2012 - 11:30 PM
Yes that would work. Usually though you render 0 for 'in shadow' and 1 for 'no shadow', so then when lighting you can just multiply the light value against this texture.
I'd just like to verify that i understand the idea of (ordinary) deferred shadows properly. Here's my current understanding ( I admit some of this is based off intuition)
Of course, objects not in view of the light can be culled out. Is this the right idea?
render all objects from cameras point of view writing out depth only. for each light: render all objects from lights point of view (depth only) into shadow map render a fullscreen quad, which reconstructs each pixel's position from it's depth, and tests that position for shadows. write out shadow result (0/1) blur the shadow texture render all objects, multiplying lighting values with shadow values
With deferred shading, you've got your G-buffer pass, where you collect all the attributes of each pixel by rendering all the objects. Then you switch to your 'lighting buffer', and either clear it to black, or initialize it with ambient lighting. Then for each light, you additively blend that light's results into the lighting buffer. Before you render each light, you can calculate the shadow map for that light (into a recycled shadow map resource).
I'm a little puzzled about what you said here: ... Keep in mind that I only have a rough idea of how deferred shading works at present, though (as you can see from my other thread) I'm strongly considering that route. So are you saying deferred-shading makes the usual deferred shadows technique unecessary, and there's a simpler way to do it?
render all objects from cameras point of view writing out G-buffer attributes (position/depth, colour, normal, etc) render a fullscreen quad, which writes out ambient lighting (by reading G-Buffer attributes) for each light: render all objects from lights point of view (depth only) into shadow map render a fullscreen quad (or geometry that covers the bounding volume of the light), which tests for shadows and calculates diffuse/specular lighting (using the shadow map and G-Buffer attributes) write out light contribution using additive blending
Posted 05 October 2012 - 12:06 PM