Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shadows of transparent objects

Discussion in 'Unity 5 Pre-order Beta' started by remoteplayfreak, Nov 7, 2014.

  1. remoteplayfreak

    remoteplayfreak

    Joined:
    Jan 4, 2013
    Posts:
    20
    Objects with the Standard Shader set to transparent cast a shadow that consists of a dotted pattern which creates a really off-putting look. Is this normal behaviour?

     
  2. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    It's by design as far as I can tell. If you enable PCF 5x5 in the Quality settings and then set your light to Soft Shadow, it will smooth out the dither pattern a bit and make them look somewhat transparent.
     
  3. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    So you are suggesting that by design, shadows from transparent materials will have polka dots when using hard shadows? That's dubious at best!
     
    shkar-noori likes this.
  4. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    What I'm saying is that shadows from transparent Standard materials are dithered. When combined with PCF filtering, it produces an effect resembling semitransparent shadows.
    You can always disable shadow casting on the object in question, of course.
     
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,625
    I believe it's a general issue with full deferred rendering. I think it's also an issue with other engines like unreal.
     
  6. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    As far as I can tell, there's no code in there for different shadow intensity, so as a kind of hackish (but appreciated) workaround it just casts a shadow with holes in it, and when PCF filtered it ends up looking like a less intense shadow. If you want the old behavior (transparent objects can't cast shadows), just set it to non-shadow casting, but at least we have the option of getting shadowing now even if it's not ideal.
     
  7. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    It's actually just an issue with how shadow mapping works in general, not with deferred rendering. A point is either in shadow or it's not in shadow - there is no in between.
     
  8. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    That's easily solved with an offset (bias) and really only applies to the shadowing end of things not the shadowed upon.

    Non-soft shadow's shouldn't look like this, regardless of shadowing method. It's not a feature. There's no situation where this would be desirable. Therefore it's either a bug or a limitation, so just report it as a bug and see what happens.

    if it's a limitation then transparency should be disabled on hard shadows so that everything just either has or doesn't have a shadow and that's all there is to it. At least then it will be useable.
     
  9. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    I think reporting this as a bug is not productive. It's clearly not a bug.
    It's better to request a feature or a change to this feature.

    For instance, I think a good solution would be to include this in the Quality settings. Maybe a checkbox for "Dithered Shadows". So on higher quality settings with PCF soft shadows you could also enable shadow dithering.
     
  10. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    How is this clearly not a bug?

    Clearly it is a bug. There is no situation under which this would be an acceptable output except perhaps in a pixel-art game. It's not "dithered", it's simply in error. Shadowmaps are not rocket science, if you're going to support transparency and "hard" shadow maps then either do it right or don't do it at all.
     
    Metron likes this.
  11. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Well, Unity 4.x did not have shadows from alpha-blended objects at all.

    Doing the "dithered alpha shadows" was something that could be done easily & without a massive time investment. When you do enable 5x5 PCF filtering, they don't look that bad.

    That said, if they are totally useless, we can always take them out and get back to 4.x state of "no shadows from alpha objects"; until at some point we'll implement "proper" semitransparent shadowing system.
     
    shkar-noori likes this.
  12. remoteplayfreak

    remoteplayfreak

    Joined:
    Jan 4, 2013
    Posts:
    20
    That's all I wanted to know. It's a feature, a bug report would be counter-productive. As Aras said, there were no realtime shadows for transparent objects at all in 4.x, so I'm happy that there's at least something. And soft shadows with 5x5 PCF filtering does actually not look half bad!

    Thanks, Aras.
     
    shkar-noori likes this.
  13. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    Make it optional on the light-source, a checkbox. For soft shadows I agree it's good. For "hard" shadows though I would rather have the option of just having a solid shadow or threshold/no shadow.
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I actually just want shadows to cast on these things properly using cg/frag/vert
     
  15. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    It's way, way more involved than "just add a checkbox", you know :)

    Doing proper semitransparent shadows: in addition to the depth buffer, you also need a color buffer. Also a new set of shaders to render into the shadowmap (since now shaders only output depth). For both of these, you can either do that for "everything" (which makes shadows much slower & use more memory, even for only-opaque case - so not good), or add options somewhere, and add more shader variants, etc. etc. Also you need to sort the shadow casters back-to-front. And then you also have a problem on platforms that don't have "native depth buffer" - now you need to render both the depth & the semitransparent color into the color buffer(s).

    All in all, I'd say between one week and one month of work for someone. The problem is, for 5.0 everyone even remotely related to graphics already is 150% busy.

    Someday! But not in 5.0.
     
    Ostwind and shkar-noori like this.
  16. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    maybe you should add some of the ~100 R&D developers to the actual ~10 developers and this should make you some time for awesome feature to arrive in time
     
  17. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Hire the Jove 2.0 guy - he's implemented it in his renderer :)
     
  18. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    I'm not suggesting implementing proper deep shadowmaps at this point, simply on/off solid/dithered for the whole light. i.e. a switch to legacy hard shadows if you will. You don't need to sort, you don't need to add a color or even grey channel to the shadowmap, you don't lose any speed or memory.
     
  19. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    I don't think this would make the process any easier, he would have to learn the unity way of doing thing first, which would take time that we don't have for 5.0 release