Search Unity

How do I cast shadows in ARCore?

Discussion in 'AR' started by tomicz, Mar 24, 2018.

  1. tomicz

    tomicz

    Joined:
    Mar 16, 2015
    Posts:
    152
    Hello there,

    I can't find a way to cast shadows in ARCore, is there some solution to this? I tried with planes and shadow shader that I use in Vuforia, but it does not work with ARCore.
     
  2. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    Shadow casting is something you have to make yourself on top of ARCore. You need to add a light source with shadow casting enabled, you need to add a plane that receives shadows (and that plane need to be aligned with the tracking plane), and you need to use objects that have cast shadows enabled.

    The plane that receives the shadows need to have a transparent material that receives shadows, in order to make it look like the shadows are cast onto the "real world". Such a shader isn't included in the ARCore package, but I've attached one here. It's made in Amplify Shader Editor, but you should be able to use it without Amplify.
     

    Attached Files:

  3. tomicz

    tomicz

    Joined:
    Mar 16, 2015
    Posts:
    152
    But what about the size, I need to make my targets small, but shadows are pixalated, because ARCore is using real life measurements, like 0.1f is 10cm. Can I make 1f equal 10cm? I need larger objects for better quality shadows.
     
  4. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    Try to decrease shadow distance under quality settings
     
    ted537 likes this.
  5. Privateer

    Privateer

    Joined:
    Jun 5, 2016
    Posts:
    23
    I've tried this shader. Thank you, by the way.
    But it renders the ground plane opaque grey.
     
  6. Shunaev

    Shunaev

    Joined:
    Mar 4, 2015
    Posts:
    9