I had quite alot fights with several lighting methods last years :)
I don't know which hardware you are targetting, but despite their static character, lightMaps are still ok these days. I'm working with realtime lightMaps right now (updated ~10 times per second) but if you aim for lower-end hardware and/or good quality, I would go for the pre-calculated lightMaps. Radiosity is quite a complex process indeed. 3D packages such as LightWave often carry a lightMap 'baker'. LightWave needed a couple of hours(!!) for some lightMaps (and no, not very complex maps). But it doesn't matter since you are generating the map offline anyway. Though its hard to be patient sometimes when tweaking the lights.
LightMaps belong to the fastest lighting solutions. Simply because you just apply 1 texture, and that's about it (the most basic type of lightmapping). The only problem might be memory requirements like Ashaman stated. A 2048x2048 RGB texture is already 12 MB. 24 if you make it 16 bit for HDR purposes. In most cases the lightMaps are pretty low quality, meaning that only a few pixels are spend for square meter(s). Outdoor area's can ussually do with even lower detail, as the lighting doesn't vary that much in comparison to indoor area's.
When dealing with really big area's (GTA, Large outdoor terrain, etc.), you can split the huge lightMaps into chunks and load them in the background when approaching the area.
Things get a little bit more difficult if you want normalMapping and/or dynamic lights. Source engine (Halflife2) "Radiosity Normal Mapping" is 1 way to do it. Basically each lightmap gets created 3 times. Each map measures the incoming light for each pixel from another global direction. Based on the pixelNormal, the 3 lightMaps are mixed. The technique on itself isn't that hard. If you know how to generate 1 lightMap, 3 shouldn't be a problem neither. But it takes a longer time to generate, more memory, and also more GPU power of course. Instead of 1 texture read, you do 3 reads and some extra math to combine the 3 pixel colors. Yet its still pretty fast compared to other realtime methods.
What many games do nowadays is combining static lighting (lightMaps) with dynamic lighting. When placing lights, you could tell which are dynamic and which not. All lights that never change color/state/position/direction can be included into the lightMap. Other lights can be manipulated somehow can be rendered later on realtime on top with shadowMapping for example. I think the flashlight from Halflife2 is a good example for this. Also lighting on dynamic objects (tables, barrels, zombies) is often done with realtime lighting & shadowMaps. Halflife 2 uses "ambient cubes" to assign a pre-calculated ambient value to dynamic objects. So when moving, your character searches the most nearby ambi-cube and uses that color as ambient.
Greetings,
Rick
Radiosity for lightmap creation?
Thing is, and I am probably being picky for this, I am working in isometric in an environment with lots of trees and I think it would look pretty dang cool to see the shadows shift around as a bright fireball flies between all the trees lighting up the swamp. From the high iso view, the player would have a nice view of it.
Right now I'm looking at two engines. One that would give me real time dynamic stencil shadows (hard edged though) and diffuse orthogonal distance lights that aren't dynamic, plus projected shadow maps. Another would give me light maps and projected shadow maps, but not realtime shadows.
Gah, selecting an engine is so bothersome!
I just want pretty dynamic soft shadows and lights; I don't even really need bump or specular lighting!
Right now I'm looking at two engines. One that would give me real time dynamic stencil shadows (hard edged though) and diffuse orthogonal distance lights that aren't dynamic, plus projected shadow maps. Another would give me light maps and projected shadow maps, but not realtime shadows.
Gah, selecting an engine is so bothersome!
I just want pretty dynamic soft shadows and lights; I don't even really need bump or specular lighting!
Then I think you are looking for the word "Cascaded Shadowmaps" and "point lights".
Cascaded shadowMaps enhances normal shadowMaps for long range directional lights (such as the sun). Crysis uses this for the sun, for example. The nice thing about it is that you can change the sun whenever you like (perfect for day/night cycle, changing weather, etc.). Downside is that it requires quite some GPU horsepower. Not too bad, as long as you don't use it in combination with dozens of other techniques/lights. A bigger problem might be your target videocard options. Do they support FBO's/Rendertargets/texture array's or 3D texture?
If you don't need dynamic weather/day/night, you can still do with a lightMap. Or try an ambient-occlision map for a little bit more flexibility. This is almost the same as a normalMap, but instead of colors you calculate the 'occlusion' factor per pixel on the "lightMap". If a piece of grass is between lots of trees, it will be occluded from the sun alot more than patches in the open field. A shader can multiply this factor with an overall (weather/day/night) color and even do normalMapping easily, if you like too. Ambient Occlusion maps are excellent for outdoor area's.
Then your great balls of fire. This is a pretty advanced effect. Also for stencil shadows, as your trees probably use lots of transparency in their textures. You can't pre-calculate this kind of stuff, so I think your best bet is Pointlight ShadowMaps or Dual Paraboloid Shadowmaps. For a pointlight, you create a cubeMap with 6 shadowMaps (6 background passes = heavy). Use this for lighting on the terrain on top of your other (ambient) lighting. Dual Paraboloid is the same principle, but potentionally faster as it only requires 2 shadowMap passes instead of 6. Downside is that your world needs a high grade of tesselation (read lots of vertices/polygons).
Both techniques will give you soft-edges shadows, fully dynamic. But again, they are expensive. There are quite alot of tricks to optimize them though. If you always look from above, then don't render the upwards shadowMaps for example. Anyhow, even on modern hardware I wouldn't suggest to use lots of pointslights at the same time. And just as the Cascaded Lightmaps, your videocard needs to support a couple of options. Although there are always work arounds of course.
Greetings,
Rick
Cascaded shadowMaps enhances normal shadowMaps for long range directional lights (such as the sun). Crysis uses this for the sun, for example. The nice thing about it is that you can change the sun whenever you like (perfect for day/night cycle, changing weather, etc.). Downside is that it requires quite some GPU horsepower. Not too bad, as long as you don't use it in combination with dozens of other techniques/lights. A bigger problem might be your target videocard options. Do they support FBO's/Rendertargets/texture array's or 3D texture?
If you don't need dynamic weather/day/night, you can still do with a lightMap. Or try an ambient-occlision map for a little bit more flexibility. This is almost the same as a normalMap, but instead of colors you calculate the 'occlusion' factor per pixel on the "lightMap". If a piece of grass is between lots of trees, it will be occluded from the sun alot more than patches in the open field. A shader can multiply this factor with an overall (weather/day/night) color and even do normalMapping easily, if you like too. Ambient Occlusion maps are excellent for outdoor area's.
Then your great balls of fire. This is a pretty advanced effect. Also for stencil shadows, as your trees probably use lots of transparency in their textures. You can't pre-calculate this kind of stuff, so I think your best bet is Pointlight ShadowMaps or Dual Paraboloid Shadowmaps. For a pointlight, you create a cubeMap with 6 shadowMaps (6 background passes = heavy). Use this for lighting on the terrain on top of your other (ambient) lighting. Dual Paraboloid is the same principle, but potentionally faster as it only requires 2 shadowMap passes instead of 6. Downside is that your world needs a high grade of tesselation (read lots of vertices/polygons).
Both techniques will give you soft-edges shadows, fully dynamic. But again, they are expensive. There are quite alot of tricks to optimize them though. If you always look from above, then don't render the upwards shadowMaps for example. Anyhow, even on modern hardware I wouldn't suggest to use lots of pointslights at the same time. And just as the Cascaded Lightmaps, your videocard needs to support a couple of options. Although there are always work arounds of course.
Greetings,
Rick
Wow, your fireball effect is pretty advanced. Well, I will give you a short overview of lighting and shadowing techniques. Please note, that lighting is much easier than shadowing !
Lighting(without shadow):
- Normalmapping/Specular/Diffuse: Really cheap on nowaday hardware, high value for low price.
- HDR: getting standard now and is quite easy.
- precalculated lightmaps: good visuals, but static and very memory intensive, without specular lighting
- vertex lighting: very cheap, like lightmaps but on a per vertex base.
- Dynamic lights: quite cheap, high number of lights possible (>100).
Shadowing:
- Volumne/stencil shadows: Not very often used in games, high impact on CPU usage and lack of GPU support.
- Shadowmap: excellent GPU support, problems with artifacts, many different approaches cascading/parallel split, variance, soft shadows.
- Point light shadowing: need a cube-map shadow map, that are 6 shadowmaps!, quite expensive !
- (static) ambient occlusion: a static, light indepedent "global illumination shadowing". High value for low price.
- SSAO: screen space ambient occlusion: Approximation of the standard version, done in screen space for complete scene every frame(=>crysis).
You will see a combination of more of these technique in a single game. Take a look at games which uses precalculated light maps, they got tiny levels. If you want good lighting in a large world you need a good dynamic lighting/shadowing approach.
My approach would look like this:
1. start(deferred engine):
- normal mapping
- dynamic lights/sun
- one simple shadowmap for sun
- baked ambient occlusion
2. improve:
- tested other shadowmap techniques to improve quality.
- HDR
3. extend:
- point-light shadows
- SSAO(!)
--
Ashaman
Lighting(without shadow):
- Normalmapping/Specular/Diffuse: Really cheap on nowaday hardware, high value for low price.
- HDR: getting standard now and is quite easy.
- precalculated lightmaps: good visuals, but static and very memory intensive, without specular lighting
- vertex lighting: very cheap, like lightmaps but on a per vertex base.
- Dynamic lights: quite cheap, high number of lights possible (>100).
Shadowing:
- Volumne/stencil shadows: Not very often used in games, high impact on CPU usage and lack of GPU support.
- Shadowmap: excellent GPU support, problems with artifacts, many different approaches cascading/parallel split, variance, soft shadows.
- Point light shadowing: need a cube-map shadow map, that are 6 shadowmaps!, quite expensive !
- (static) ambient occlusion: a static, light indepedent "global illumination shadowing". High value for low price.
- SSAO: screen space ambient occlusion: Approximation of the standard version, done in screen space for complete scene every frame(=>crysis).
You will see a combination of more of these technique in a single game. Take a look at games which uses precalculated light maps, they got tiny levels. If you want good lighting in a large world you need a good dynamic lighting/shadowing approach.
My approach would look like this:
1. start(deferred engine):
- normal mapping
- dynamic lights/sun
- one simple shadowmap for sun
- baked ambient occlusion
2. improve:
- tested other shadowmap techniques to improve quality.
- HDR
3. extend:
- point-light shadows
- SSAO(!)
--
Ashaman
There is a fair number of things on that list that would be near useless to me, unfortunately most are the cheap ones. HDR makes little sense from iso and never viewing the sun, for instance.
A few things though:
• I am in isometric with a fair camera height. This means the GPU is getting loaded with a fair number of models, but simpler ones than in an FPS, more like in an RTS, but fewer units.
• Normal mapping, parallax, and probably even bump mapping are all unnecessary because of the view distance and angle. What water I have is swamp water, its not really shiny stuff any more, rather its dark and gooey so I can get away with no spec if I want as well.
• What I do need is good looking environment lighting and shadowing. I want good shadows coming off all these trees if I can have it. What helps though is that from an Isometric view, I don't need a large view space loaded like an FPS does. I can't see the horizon, only a fairly constrained space, so maybe I can handle these effects by keeping the tree density/scale of things such that there aren't too many to deal with. Light maps and ambient occlusion maps can be paged very heavily.
A few things though:
• I am in isometric with a fair camera height. This means the GPU is getting loaded with a fair number of models, but simpler ones than in an FPS, more like in an RTS, but fewer units.
• Normal mapping, parallax, and probably even bump mapping are all unnecessary because of the view distance and angle. What water I have is swamp water, its not really shiny stuff any more, rather its dark and gooey so I can get away with no spec if I want as well.
• What I do need is good looking environment lighting and shadowing. I want good shadows coming off all these trees if I can have it. What helps though is that from an Isometric view, I don't need a large view space loaded like an FPS does. I can't see the horizon, only a fairly constrained space, so maybe I can handle these effects by keeping the tree density/scale of things such that there aren't too many to deal with. Light maps and ambient occlusion maps can be paged very heavily.
Then how about just using basic shading on the terrain? Eventually per pixel (phong) for smoother details. Shadows from objects such as trees or houses can be fixed textures that are pasted as decals on top of the terrain. Wrap a quad beneath the tree on top of the terrain with multiply-blending to project the shadow on the terrain. The downside is that big hills and such don't cast shadows over objects or the terrain itself, and pre-drawn textures are not correct in case the main lightsource(sun) changes from position. If you really want that effect, I'd still go for Cascaded Shadow Maps, or at least use (small resolution) lightMaps for each patch of terrain.
BTW, Radiosity won't give you that much of extra in an open terrain like this. Radiosity is great for indoor, as it handles bouncing light (light falls in through window, then get scattered all over the place by reflecting on shiny surfaces). You could use lightMaps (or actually 'shadowMaps') with just 1 color channel that only describe how much shadow we have on that point. In your shader the terrain result color would be:
As for the dynamic lightsources (flashlight, explosions, etc.), ask yourself if the shadow-casting needs to be correct. Ifso, I'd go for point- or spotlights with shadowMaps. Besides shadowMaps and stencil shadows, there aren't much other options. If accurate shadow-casting is not that important, you could also go for a defferred lighting approach. Just render everything normally, without dynamic lights. Then on top render light volume shapes (spheres/cones). These shapes use a shader that grabs pixels from the background (the terrain/objects under that volume) and light them with a certain color/attenuation. This won't cast shadows, but its a relative simple and fast solution.
BTW, normalMaps can still be usefull for larger scale details. Your camera is zoomed out so you don't need normalMaps for micro detail. But you can also stretch them and use them on a larger scale such as a bumpy grass landscape or cracks in a rock.
Rick
BTW, Radiosity won't give you that much of extra in an open terrain like this. Radiosity is great for indoor, as it handles bouncing light (light falls in through window, then get scattered all over the place by reflecting on shiny surfaces). You could use lightMaps (or actually 'shadowMaps') with just 1 color channel that only describe how much shadow we have on that point. In your shader the terrain result color would be:
result.rgb = terrainTexture.rgb * shadowMap.x + terrainTexture.rgb * ambientOverallColor; // You could also encode an ambient occlusion map into the second channel: result.rgb = terrainTexture.rgb * shadowMap.x + terrainTexture.rgb * shadowMap.y * ambientOverallColor;
As for the dynamic lightsources (flashlight, explosions, etc.), ask yourself if the shadow-casting needs to be correct. Ifso, I'd go for point- or spotlights with shadowMaps. Besides shadowMaps and stencil shadows, there aren't much other options. If accurate shadow-casting is not that important, you could also go for a defferred lighting approach. Just render everything normally, without dynamic lights. Then on top render light volume shapes (spheres/cones). These shapes use a shader that grabs pixels from the background (the terrain/objects under that volume) and light them with a certain color/attenuation. This won't cast shadows, but its a relative simple and fast solution.
BTW, normalMaps can still be usefull for larger scale details. Your camera is zoomed out so you don't need normalMaps for micro detail. But you can also stretch them and use them on a larger scale such as a bumpy grass landscape or cracks in a rock.
Rick
Hm. that is a point, i could save polygons and effort on my part using normal maps, or even just bump maps to imitate the grasses. Id only need models for the larger knee high and up plants.
And no, i don't ask for accurate shadows, just pretty ones. So i want soft and dynamic, but not always correct.
Terrain doesn't need to shadow as it will be relatively flat. I don't want to have the camera trying to move around hills so I don't plan on any elevation changes as high as the PC's height.
Decal based shadows I think would end up being a lot of effort on my part and I may go with light maps instead. There is just a whole heck of a lot of stuff to make decals for if I did that.
A question for you guys though. Can projected shadow maps be used some how for dynamic character shadows? I wouldn't even mind blob shadows really but I would like the best I can fudge. What about blob shadows that stretch and rotate to approximate an accurate shadows length and direction?
And no, i don't ask for accurate shadows, just pretty ones. So i want soft and dynamic, but not always correct.
Terrain doesn't need to shadow as it will be relatively flat. I don't want to have the camera trying to move around hills so I don't plan on any elevation changes as high as the PC's height.
Decal based shadows I think would end up being a lot of effort on my part and I may go with light maps instead. There is just a whole heck of a lot of stuff to make decals for if I did that.
A question for you guys though. Can projected shadow maps be used some how for dynamic character shadows? I wouldn't even mind blob shadows really but I would like the best I can fudge. What about blob shadows that stretch and rotate to approximate an accurate shadows length and direction?
I think that's how many older games did shadows. Draw a inversed V (2 legs, body) grayscale texture, apply it on a subdivided quad that wraps itself on the terrain and apply multiply-blending on it to darken the terrain. The quad pivots around your feet, depending on the sun position.
With cascaded shadowMaps or stencil shadows you get correct shadows on your characters. You could make an option in your editor which objects cast shadows and which not. Or eventually choose between none/simple(blob)/accurate.
Another method is pretty much similiar to shadowMaps, but on a smaller scale. For each character that is visible on your screen, render a low-res shadowMap.
- From the sunlight point of view, zoom in until character X fills the screen (background buffer / FBO / Render target)
- Render the character in its current pose with black pixels on a white background. Eventually use a low-poly mesh to speed things up. And certainly render it on a small buffer (16x32 for example). Eventually scale it up or apply a blur for soft edges.
- Store this into a small texture, and yet again, draw it on a quad that wraps on the floor at the characters feet with multiply-blending.
Now your character has its own shadowMap. Not truly correct, but simpler and faster than cascaded shadowMaps. Also lower video-card specs required.
OR... and this is something I never tried, but maybe it works... Just render your character twice. One time normally, and then as a flattened mesh. For each vertex, move it to the ground. Imagine sending a ray from your lightsource to each vertex. Then when it interpolates, grab that vertex and let the ray travel it further until it hits the terrain ground. Replace the vertex there. This second pancake model uses a black/transparent texture. It quite simply, although raycasting through lots of vertices might be an issue. And no soft edges here either.
With cascaded shadowMaps or stencil shadows you get correct shadows on your characters. You could make an option in your editor which objects cast shadows and which not. Or eventually choose between none/simple(blob)/accurate.
Another method is pretty much similiar to shadowMaps, but on a smaller scale. For each character that is visible on your screen, render a low-res shadowMap.
- From the sunlight point of view, zoom in until character X fills the screen (background buffer / FBO / Render target)
- Render the character in its current pose with black pixels on a white background. Eventually use a low-poly mesh to speed things up. And certainly render it on a small buffer (16x32 for example). Eventually scale it up or apply a blur for soft edges.
- Store this into a small texture, and yet again, draw it on a quad that wraps on the floor at the characters feet with multiply-blending.
Now your character has its own shadowMap. Not truly correct, but simpler and faster than cascaded shadowMaps. Also lower video-card specs required.
OR... and this is something I never tried, but maybe it works... Just render your character twice. One time normally, and then as a flattened mesh. For each vertex, move it to the ground. Imagine sending a ray from your lightsource to each vertex. Then when it interpolates, grab that vertex and let the ray travel it further until it hits the terrain ground. Replace the vertex there. This second pancake model uses a black/transparent texture. It quite simply, although raycasting through lots of vertices might be an issue. And no soft edges here either.
Quote: Original post by spek
OR... and this is something I never tried, but maybe it works... Just render your character twice. One time normally, and then as a flattened mesh. For each vertex, move it to the ground. Imagine sending a ray from your lightsource to each vertex. Then when it interpolates, grab that vertex and let the ray travel it further until it hits the terrain ground. Replace the vertex there. This second pancake model uses a black/transparent texture. It quite simply, although raycasting through lots of vertices might be an issue. And no soft edges here either.
Isn't that basically stencil shadows though? Anywho, I think after so much discussion on shadows I have a handle on what my options are here. I think I might be able to swing my fireball shadows and still get a degenerate version for low end hard ware. I can't go leaving the casual crowd in the cold afterall.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement