Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Fast Volumetric Blob Shadows

Discussion in 'Assets and Asset Store' started by Pawige, Jan 30, 2020.

  1. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    I've been looking for a good solution for blob shadows in Unity for a long time now, but I've never been able to find one that met all of my needs. I finally decided that I should just figure out how to implement my own, and this is the result!

    All you need to do is drop the material onto a cube or sphere mesh, place it in the world, and adjust the color, sharpness, and intensity as needed. For dynamic objects, you can position it with a simple script or constraint. The shadow volume geometry can be moved, rotated, and scaled. I've used it in situations when full shadows are enabled but a little bit of cheap extra occlusion is desired. It can easily be GPU instanced, but static and dynamic batching do not work, because batching removes transformation information necessary for the shader to function.

    The primary advantage this asset has over the standard Unity projector is that the projector will re-render all of the objects it affects, which can potentially increase the number of draw calls and overall cost of a scene dramatically, especially if there are multiple objects casting shadows on multiple environment objects, or the objects receiving the shadows are large or complex. The FVBS shader doesn't suffer from this issue, and will have the same cost regardless of the complexity of the scene being shadowed.

    Builtin, URP, and HDRP are all supported. Works in forward and deferred pipelines, the only requirement is there must be a depth texture.

    I'm looking to give out a few vouchers to people who're working on a project that would be interested in trying it out and giving me some feedback, especially on mobile or VR. Please let me know if you think it'd be useful for you!

     
    Last edited: Apr 27, 2020
    petey, DavidZobrist and andreiagmu like this.
  2. pietrina

    pietrina

    Joined:
    Aug 22, 2015
    Posts:
    15
    Hi, I testing yours blob shadows in my project... FOG not works with shadows ?
     
  3. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    Hey! Sorry I didn't see this message earlier. The fog not working with the shadows is something I overlooked and am going to fix in the next update. You can edit BlobShadow.shader and remove the word "nofog" from line #24 in BlobShadow.shader, that should fix it!
     
  4. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    V1.1 is now live on the Asset Store! Lots of minor bug fixes (including the fog issue!) and improvements, and major improvements to the smoothness of the square version of the shadow:
     

    Attached Files:

  5. Mehrdad995

    Mehrdad995

    Joined:
    Jul 17, 2013
    Posts:
    46
    Great asset,
    is it besed on depth buffer?
     
  6. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    Yes it is. Needing to enable the depth buffer is the primary cost, the shadows themselves are quite cheap to render.
     
    Mehrdad995 likes this.
  7. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,136
    Hi can they have a direction, not just downwards?
    I guess they do not cast a long way as they are inside the placed volume box?
    Could you use for fake lighting effects too?
     
  8. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    They don't really have a direction, but you can scale them arbitrarily, so you can make them longer as needed. You can use them for fake lighting, the color of the "shadow" is an HDR color so you can make them as bright as you want.
     
  9. Alex_Rendever

    Alex_Rendever

    Joined:
    Mar 9, 2020
    Posts:
    2
    Hi, thanks for this great asset!

    One question, does this asset support single-pass VR?
    We're targeting Quest single-pass, and the shadows are rendering incorrectly.
    Multi-pass works as expected.
     
  10. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    It should work, but with single-pass it's generally a crapshoot. I'm happy to look into that. What version of Unity are you using and what rendering pipeline?
     
    Alex_Rendever likes this.
  11. Alex_Rendever

    Alex_Rendever

    Joined:
    Mar 9, 2020
    Posts:
    2
    Appreciate the help!

    We're using the default renderer pipeline, on 2019.4.11 LTS.
     
  12. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    Okay, I was able to reproduce the problem, and I think I know why it's happening. Looks like the depth textures for the Quest multiview rendering are stacked in a texture array, rather than a doublewide texture. I am now trying to figure out either how to access that array manually so I can pick the index based on the eye, or see why the helper methods Unity provides do not seem to be working correctly.
     
  13. yarsrvenge

    yarsrvenge

    Joined:
    Jun 25, 2019
    Posts:
    87
    I have the same issue with this asset on the quest as well.
     
  14. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    So I haven't been able to make any progress on getting the shadows working in Builtin on Quest with Multiview, and at this point I'm unfortunately not sure I'll be able to find a way to get at the textures I'd need access to in the Builtin pipeline. However, I've done some testing and confirmed that it does work in the URP with Multiview. I'm happy to offer a refund if that isn't a solution that works for either of you.
     
  15. RIPANN

    RIPANN

    Joined:
    Aug 9, 2017
    Posts:
    9
    Hello,

    I have been using FVBS shadow asset for some of the objects in my VR scene.
    The shadows are flickering when I am at far, and as I approach near them at close enough distance they stop flickering.
    The VR camera is moving forward at a constant speed.

    Video Reference for this issue :


    Could you tell me how to solve this flickering ?
     
  16. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    Are you using the URP? There are a couple of depth related issues I've seen show up in older versions of the URP. If you can upgrade to 7.4 or newer and make sure to try using the shader at FastVolumetricBlobShadows\URP\AmplifyBlobShadow.shader it may fix the issue.
     
  17. RIPANN

    RIPANN

    Joined:
    Aug 9, 2017
    Posts:
    9
    I am using Built-in Render pipeline. Is there any solution or suggestion for this issue in Buit-in ?
     
  18. Pattrigue

    Pattrigue

    Joined:
    Nov 24, 2018
    Posts:
    56
    Does this work for mesh shapes too? I would like a shadow beneath my model with the same shape as the model, and I want it to always render directly below the model.

    Here's a clip from F-Zero GX showing what I'm hoping to achieve:
     
  19. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    So it's difficult to tell exactly what might be causing it from the video, but my next guess would be that it's just ordinary aliasing. One trick you could try is just scaling the shadows up a little bit in the Z axis (or whatever axis is forward) when they're far away so they don't alias as bad. Unfortunately, in general aliasing like that can be incredibly difficult to solve.

    It doesn't currently support that but it's a potential use-case I'm interested in. I could send you over a prototype shader to see if it works in your case.
     
  20. Pattrigue

    Pattrigue

    Joined:
    Nov 24, 2018
    Posts:
    56
    Sure, I'd love that! This kind of shadow is a great feature in platformers and arcade races, and it's a shame Unity URP doesn't support it out of the box.
     
  21. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Hello Mr. developer. I have been trying out your asset, and it really works so beautifully! Am very happy to have bought it! Trouble is, whilst the blob shadows work fine in the editor, they do not appear in my mobile devices (both iPhone and android). The enabledepthtexture script has already been added to my camera as well. When i step through the frame debugger on my mobile devices, i notice that the blob shadows are being submitted as draw calls, the depth texture as well. But they just dont appear to be showing on screen. I have attached two screenshots showing this issue. You can see the shadows under the red people in yesshad SS (Editor). but the shadows are not visible in the noshad SS (mobile devices)

    Hope you will be able to assist me in this. Thank you!
     

    Attached Files:

    Last edited: Mar 13, 2021
  22. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    Hmm, that's very strange! Are you using the built-in renderer? What version of Unity are you on? What Android phone are you using? I've tested it pretty extensively on mobile devices with the URP, but not as much with built-in.
     
  23. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Yeap yeap I'm using the built-in renderer. I am also using 2021.1.0b11 unity version.

    I tried to reproduce this issue with a fresh new empty project and I was not able to reproduce the error. Blob shadows work beautifully in the new empty project but not my own project. So it appears there's something else that's causing the blob shadows to not appear in my project. I will have to investigate this on my own. Apologies for the trouble and thank you for responding! :)
     
  24. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    598
    I noticed that "ViewToLocalSpace" has a missing script. Is this file used at all, or is the missing script a problem? It flags in my project when looking for broken links.
     
    DavidZobrist likes this.
  25. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    201
    @dock same issue here, which script should it reference? Is it even required?
    Also I got the Fog issue, where shadows go missing if it gets enabled, we are using the shadergraph version in URP.
     
  26. Pawige

    Pawige

    Joined:
    Nov 26, 2012
    Posts:
    40
    Hey! That missing script was accidentally included, I've been meaning to push an update out to the asset for a long while now and just finally got that done. The broken script will be gone in the next update, and all the URP fog issues should be fully resolved. Feel free to contact me through the support email listed on the asset store, I can get you the fixed version if you need it before it's approved on the store.
     
  27. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    201
    @Pawige
    It is fixed with the newest version!
    Thank you :)
    Great asset!
     
  28. peacefulshade

    peacefulshade

    Joined:
    Jul 25, 2012
    Posts:
    9
    Hello there =)

    Just bought your package but it didn't work on iOS (on Windows, Mac, Linux it worked just fine)

    This is the project:

    http://pixeldynamite.com/tmp/iosIssueProject.zip

    I'm on Unity 2021.2.16f1 on an M1 Max MBP

    Thnx in advance!