Jump to content

  • Log In with Google      Sign In   
  • Create Account

lights, shadowmaps and render count

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

#1 Ichi   Members   -  Reputation: 159


Posted 30 July 2014 - 05:20 PM



im about creating shadowmaps, having multiple lights of different types. If you have a look on following page


at Example 12-1. Pseudocode for the Omnidirectional Shadow-Mapping Algorithm

you notice that they tell to render the scene 2 times for every light.

Ok, fine that maaay be much if i have much lights but its fine because i only need a single shadowmap texture.

Now i have a problem when it comes to point lights. for the shadow cubemaps i need 6 shadow maps. should i render the scene 2 times for every of the 6 faces (12 renders per point light) or have 6 shadow maps laying in vram(waste of ram kinda). 


the next problem is if i want to use things like motion blur or depth of field, mirrors or whatever, i need to render my scene multiple times per frame. that number is multiplied with the renders(shadow maps) i need for one full render and i dont want a scene so lowpoly that it could be rendered about 100 times each frame.


Do you have any advice for shadow maps? i kinda hate them, but they are also nice in some way. Also i need dynamic lighting

Thanks smile.png



EDIT: also i have no idea about accessing shadow cubemap data with direction vectors. would be nice if someone could explain that. smile.png Thanks

EDIT2: just found out opengl supports cubemaps :s. ill have a look on that tomorrow

Edited by Ichi, 30 July 2014 - 08:18 PM.


#2 Ashaman73   Crossbones+   -  Reputation: 7198


Posted 30 July 2014 - 11:49 PM

it could be rendered about 100 times each frame.

Well, yes, and this is the problem...


Do you have any advice for shadow maps?

Use shadowmaps really rarely,especially omnidirectional shadow maps. There are some (nasty/ugly) tricks, but eventually many shadowmaps in modern scene complexetiy is still a problem which has not been solved in a nice and elegant way. If you want to go the brute force way (render the scene multiple times), then you will run in performance issues really quickly (depends on scene complexity).


Take a look at modern games and watch them really carefully, you will see, that most games have one major shadow map (sun) and at times some extra shadow maps, almost never an omnidirection one, on the other hand they have lot of (shadowless) lights.

#3 Ohforf sake   Members   -  Reputation: 1814


Posted 31 July 2014 - 12:34 AM

You need to render once for every shadow map that you create, that is true, but you do not need to render once per light source. That is a severe oversimplification of forward rendering. Modern rendering methods like deferred and tiles/clustered forward can get away with less.

Also note, that rendering your scene is usually dominated by evaluating complex shaders, and writing to fat buffers with lots of bytes per pixel. None of which you have to do when you render the shadow map. Also, you only need to render those objects into the shadow map, that are actually within the range of that light, so rendering a shadowmap is not as expensive as your ordinary render pass.

#4 BlueSpud   Members   -  Reputation: 421


Posted 10 August 2014 - 08:53 AM

I myself have been thinking about this problem for quite a long time now, just in the back of my head without really reading anything on it. If you really needed to have several shadow maps, obviously drawing a scene with 300,000 polygons several times is going to be slow. If your scene is static besides the camera, you only need to render the shadow map once, and then your all good, since none of the geometry is changing. I've also heard that VBO's can be instanced to reduce the cost of rendering the same object multiple times, but Im not sure if it can be used for shadow maps, but I'd still look into it. If you need dynamic objects, such as a player's shadow, I would think it could be cheaper to do a frustum culling-type algorithm for each light on dynamic objects. If there is at least one object in the light's view, update the shadow map. Also then preform frustum culling and maybe a bit of occlusion culling to see if the camera can see the light. If it can't, why render the shadow map? I haven't tried anything, and they'll probably be fairly complex to implement, but Im sure that you'll see that these are a lot better than the brute force method. Good luck.