Announcement

Collapse
No announcement yet.

Bake shadow without light

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • started a topic Bake shadow without light

    Bake shadow without light

    Hi everyone,

    In our games we have a level in which player must enable lights to lit the world and progress. For the moment we are using stationnary lights but the limit for overlapping stationnary lights don't allow us to lit as we would want (we have huge attenuation radius), and dynamic shadows are too expensive.

    So my idea was to have a copy of a light and bake only its shadows (I don't want the lightmap, just the shadow map). So the player enable a dynamic light with cast shadow disabled and I should have a reasonnable performance cost.
    I don't need to hide shadowmaps at runtime, I can have them showed from start, as the sky light intensity is very low the shadow should not be a problem when not lit.

    The problem is I have no idea on how to cast shadows without lighting. Using negative intensity on lights doesn't cast any shadow :/

    Any idea ?

    Thanks a lot for any help.

  • replied
    So it must be because we have large rooms and large light radius. We already use level streaming for the lights to avoid lighting rooms that are not visible. I will try to limit lights radius or light numbers. Thanks for your advices.

    Leave a comment:


  • replied
    Originally posted by Moonycat Ent View Post
    I am testing this in a blank level with only cubes, indeed shadow depth has a very low performance cost. But now I have performance issues on ShadowProjectionOnOpaque, it takes between 1 and 2 ms per light when I am in fullscreen mode (no problem in viewport). I think I can't ask ask my lights to consume less they can do ^^
    Set them visibility to false when they are not supposed to light the scene. Cost is related to amount of pixels they cover. Smaller radius is cheaper light.

    Leave a comment:


  • replied
    You can still turn on/off a static light if that's what you are looking for. You can use a static light and set its visibility to off at the beginning, the shadow map depends on the light's visibility.
    I need to progressively increase the light radius, turning on/off a static light would cause popping.

    Leave a comment:


  • replied
    You can still turn on/off a static light if that's what you are looking for. You can use a static light and set its visibility to off at the beginning, the shadow map depends on the light's visibility.

    Leave a comment:


  • replied
    I am testing this in a blank level with only cubes, indeed shadow depth has a very low performance cost. But now I have performance issues on ShadowProjectionOnOpaque, it takes between 1 and 2 ms per light when I am in fullscreen mode (no problem in viewport). I think I can't ask ask my lights to consume less they can do ^^

    Leave a comment:


  • replied
    New: Shadow Map Caching for Movable Lights

    When a point or spot light is not moving, we can store off the shadow map for that light and reuse it next frame. This is now done automatically and makes shadow casting movable point and spot lights much more affordable in games where the environment is often not moving.

    image alt text

    The above image shows 33 dynamic shadow-casting point lights, with very minimal overhead:

    Performance results on a 970 GTX at 1920x1200

    33 shadow casting point lights without caching: 14.89ms to render Shadow Depths.

    With cached shadow maps: .9ms (about 16 times faster!)

    Note that it still costs 2ms to render the contributions of the 33 point lights, which can be optimized in other ways but is not affected by this change.

    Memory used by the cache can be seen under ‘Stat ShadowRendering’ and was 25.6Mb in this scene.

    Max memory used by the cache can be controlled with ‘r.Shadow.WholeSceneShadowCacheMb’

    Limitations

    By default, caching can only happen when:

    Primitives have mobility set to Static or Stationary

    Materials used do not use World Position Offset

    Light is point or spot, shadow casting, and mobility set to Movable but not currently moving

    Materials that use an animating Tessellation or Pixel Depth Offset can cause artifacts as their shadow depths are cached.
    Use Movable lights. Don't move them. Caching should make it plenty fast if most of the geometry is static/stationary.

    Leave a comment:


  • replied
    The caching seems to be performed, there must be a problem with my level, I spend 4.9 ms for shadow depth with 4 lights. May be some merge actors to perform, or too high trion meshes.

    Leave a comment:


  • replied
    [MENTION=37019]Kalle-H[/MENTION]: when you talk about shadow map caching, you mean shadow map caching for stationary light with dynamic shadow or is it now available for movable light ?

    Edit: If you talk about this https://www.unrealengine.com/en-US/b...-4-13-released, I believed it was for stationary lights, it looks very interesting. I need to find why my movable point lights are not chaching shadow, they take a lot of performance to compute shadow each frame, it would not.

    Thanks for your advice, I will work on this.

    Leave a comment:


  • replied
    Stationary shadow maps are not subtracted from lightmaps. Lightmap has all indirect light from stationary lights and all lights from static lights. Stationary lights calculate direct portion of light at runtime and that is multiplier with shadow map data.

    Just use Dynamic shadowing it should be pretty fast with new shadow map caching mechanic.
    The problem is we can't use stationary lights to make what we want, because we can have only 4 overlapping lights (we need more for our level design, we use high attenuation radius), and we can't use dynamic shadow on movable light (too expensive).

    Leave a comment:


  • replied
    Originally posted by Moonycat Ent View Post
    This solution is not a solution at all ^^

    Shadow maps are just subtracted from lightmaps, so a static shadow is just an unlit area on the lightmap. No possibility to have shadow only. May be using a custom shader model would allow us to use lightmaps to darken these "unlit" area. I'll take a look on this.
    Stationary shadow maps are not subtracted from lightmaps. Lightmap has all indirect light from stationary lights and all lights from static lights. Stationary lights calculate direct portion of light at runtime and that is multiplier with shadow map data.

    Just use Dynamic shadowing it should be pretty fast with new shadow map caching mechanic.

    Leave a comment:


  • replied
    This solution is not a solution at all ^^

    Shadow maps are just subtracted from lightmaps, so a static shadow is just an unlit area on the lightmap. No possibility to have shadow only. May be using a custom shader model would allow us to use lightmaps to darken these "unlit" area. I'll take a look on this.

    Leave a comment:


  • replied
    That's what I immagined :/

    The last solution seems to be modifying Lightmass source code and editor source code to process only shadow mappings for specific lights, but I think lighting in Lightmass is not performed light per light, it may get all light data and process all of this in a custom logic ...

    I will check if I can found any clue on this in the source code.

    If anybody has any clue on this don't hesitate.

    Thanks

    Leave a comment:


  • replied
    There's no way to do that and shadow maps have the same limitation has lightmaps for stationary lights

    Leave a comment:

Working...
X