Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Making part of model that is in the shadow dissapear?

Discussion in 'General Discussion' started by JovanD, Nov 22, 2015.

  1. JovanD

    JovanD

    Joined:
    Jan 5, 2014
    Posts:
    206
    Atm im messing in Sader Forge trying to make that effect, i think i need to do some thing with light attenuation and connect it to opacity channel, but i just can't get it to work. Can anyone explain to me how to get that effect properly.
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,782
    I can't help explain it, but I recently saw this and thought it might be kind of relevant.
     
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    8,394
    You'll actually run into lots of trouble with that, because it is same kind of problem as casting shadows onto semi-transparent object.

    If you want that to work with dynamic shadows and non-transparent object, that pretty much can't be done automatically due to unity's ridiculous approach to shadows and semi-transparent objects.

    You could try to make a shader no ambient pass AND zwrite-enabled per light pass. In light pass cut off pixels that are far away, but you'll get all kinds of weird effects with it.

    The best idea would be to track some obejct in scene, pass its position into shader, and cut off pixels that are too far away from the object. If you need "dynamic shadows", then you could setup additonal render target, make it act as shadowmap, and cut off pixels based on it.

    If you haven't dealt with shaders in detail, that'll be quite complicated for you.

    ---------

    In general, you can only make this kind of effect to work with object that is lit with single point light. Just implement custom shader with no ambient pass, in per-light pass render without alpha blending AND with zwrite/ztest enabled, and cut off geometry based on shadow value of that light (see shader and surface shader tutorials for details).

    That won't work with primary directional light and won't work well with multiple lights.
     
    Last edited: Nov 23, 2015
unityunity