Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

How do I cast shadows in ARCore?

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

  1. tomicz

    tomicz

    Joined:
    Mar 16, 2015
    Posts:
    115
    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:
    60
    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:

    asa989, Privateer and robrtoprz like this.
  3. tomicz

    tomicz

    Joined:
    Mar 16, 2015
    Posts:
    115
    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:
    60
    Try to decrease shadow distance under quality settings
     
    ted537 likes this.
  5. Privateer

    Privateer

    Joined:
    Jun 5, 2016
    Posts:
    7
    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:
    8