Search Unity

Shadowcaster Optimizer

Discussion in 'Assets and Asset Store' started by chassets, Jul 3, 2019.

  1. chassets

    chassets

    Joined:
    Nov 27, 2013
    Posts:
    310
    Hi!

    I've been working on a litte tool to reduce shadowcaster count in a scene when using a realtime light or realtime shadows near the player in a baked scene - you can precompute this with the click of a button, or alter the settings to your liking.

    I've done some real-world test with some of my scenes now, and most of the time the number of shadowcasters can be reduced significantly, depending on the scene layout of course. Here's a comparison screenshot:

    before.png

    Before it has 773 shadowcasters, afterwards 381 - so it saved roughly 50% in this scene:

    after.png

    You can alter the accuracy values for each light type, so that you can further remove shadowcaster count by ignoring small meshes' shadows that don't contribute much to the overall visuals.
    This works for directional, point and spot lights.

    If this is of any interest to anyone, I'm going to release it in the asset store.
    If you have any input or questions, I'd be glad to hear it.

    Thanks and have a nice day,
    CH
     
    mgear and Neviah like this.
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,620
    How does it work? :)
     
  3. chassets

    chassets

    Joined:
    Nov 27, 2013
    Posts:
    310
    It simply precomputes which renderers will be lit by the lights in your scene, without being in the shadow of other renderers (completely).

    If you move your lights though, you'd need to recalculate again - but the precomputation works pretty fast as far as I can tell from my scenes ( I've used my own 3d art packs for testing purposes: https://assetstore.unity.com/packages/3d/environments/landscapes/lowpoly-style-ultra-pack-108275). But you wouldn't do that every frame of course :D

    But most of the time in my projects I have a static directional sun and use either realtime shadows or baked shadows with realtime shadows near my player, so I guess this will help a fair bit.
     
    Last edited: Jul 3, 2019
    Peter77 likes this.
  4. chassets

    chassets

    Joined:
    Nov 27, 2013
    Posts:
    310
    debugmode.PNG

    I've added a debug visualisation for each light type - in this example, the flower circled in red casts a shadow, but the flowers in the blue are in the shadow of the stone and thus their shadow is set to none.
     
    Peter77 likes this.
  5. chassets

    chassets

    Joined:
    Nov 27, 2013
    Posts:
    310
    Made another test with my biggest 3d asset (huge scene, lots and lots of 3d objects) - also turned shadow distance far up.
    before2.PNG

    This time 2999 versus 1514 shadowcasters, so again 50% less.
    after2.PNG
    If I drag the accuracy slider a bit down, I can get easily down to ~1k shadowcasters without being very noticable.

    after2_2.PNG
    I'll improve the UI a bit, but I think afterwards I'll be ready to release this.
     
  6. chassets

    chassets

    Joined:
    Nov 27, 2013
    Posts:
    310
    • I've added an important feature: you can choose to only precalculate static objects.

    For example: If you have a spaceship that is controlled by your player in an asteroid field, this ship will not affect shadowcaster optimization calculations - the asteroids in the ships' shadow will still cast shadows - the ship is invisible to the lighting precalculation.

    • Also you can now choose to only calculate the optimization for specific objects that you have selected.
    • You can either use all shadowcasting lights in the scene or only those lights you choose.
     
  7. Milanis

    Milanis

    Joined:
    Apr 6, 2018
    Posts:
    55
    Hello @chassets ! Do you have made any progress on this one or would it be available? We're looking to a solution to lower the amount of shadowcasters and this looks like it could work quite nice.
     
  8. chassets

    chassets

    Joined:
    Nov 27, 2013
    Posts:
    310
    Hi!
    Unity asset store sadly rejected it for whatever reason, but I could provide it directly.

    Best, CH
     
  9. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    have 3rd party models ?
    try again, seems like a good asset
     
  10. chassets

    chassets

    Joined:
    Nov 27, 2013
    Posts:
    310
    No, just my own stuff. I think you are right, I should submit again, maybe another reviewer will get what it's for. Thanks for the interest, anyways.
    Best,
    CH
     
  11. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hi, I guess this didn't make it on the Asset store
    Is there any way to get this tool? I'm interested to test it
    Can't PM you on this forum apparently
     
  12. SOSolacex

    SOSolacex

    Joined:
    Jan 10, 2018
    Posts:
    121
    I too would love a tool like this. Please send it to m
    Hey, I too would love this asset if possible.
    I am unable to send you a private message as you limited who can see you on the forum. Cheers
     
  13. lapislazino

    lapislazino

    Joined:
    Aug 31, 2018
    Posts:
    4
    Hi,
    im also interested in trying out this asset...