All Projects → jonas-johansson → Arcoreutils

jonas-johansson / Arcoreutils

Licence: unlicense
Unity plugin that adds shadow and collision to ARCore.

Projects that are alternatives of or similar to Arcoreutils

Procamp
A utility shader for adjusting videos.
Stars: ✭ 101 (-1.94%)
Mutual labels:  unity, unity3d
Csharp Eval Unity3d
C# Expression Parser for Unity3D
Stars: ✭ 102 (-0.97%)
Mutual labels:  unity, unity3d
Uia 2e
all the projects from Unity in Action 2nd edition
Stars: ✭ 97 (-5.83%)
Mutual labels:  unity, unity3d
Banditdungeon
Demo project using multi-armed bandit algorithm
Stars: ✭ 94 (-8.74%)
Mutual labels:  unity, unity3d
Unity Platformer
Unity platformer framework: IA, Ladders, Jumps, WallStick, WallJumps, Slopes, MovingPlatforms, OneWayPlatforms/Walls, Ropes and more...
Stars: ✭ 97 (-5.83%)
Mutual labels:  unity, unity3d
Darkconfig
DarkConfig is a configuration library for games which supports fast and expressive iteration
Stars: ✭ 94 (-8.74%)
Mutual labels:  unity, unity3d
Unity Moveable Linerenderer
Unity LineRenderers with the simple turbulence
Stars: ✭ 101 (-1.94%)
Mutual labels:  unity, unity3d
Gpu Planetary Rendering
GPU atmosphertic scattering and planet generation in Unity 3D
Stars: ✭ 92 (-10.68%)
Mutual labels:  unity, unity3d
Gameviewlayouter
A utility script that layouts game views with multiple displays.
Stars: ✭ 97 (-5.83%)
Mutual labels:  unity, unity3d
Smo Shaders
A collection of shaders to replicate those used in Super Mario Odyssey's Snapshot Mode.
Stars: ✭ 97 (-5.83%)
Mutual labels:  unity, unity3d
Vrarmik
Unity Inverse Kinematics solution for arms in VR
Stars: ✭ 94 (-8.74%)
Mutual labels:  unity, unity3d
Succ
Sexy and Utilitarian Code Configuration
Stars: ✭ 100 (-2.91%)
Mutual labels:  unity, unity3d
Trailboids
Just tried making boids with particle trails.
Stars: ✭ 93 (-9.71%)
Mutual labels:  unity, unity3d
Forgenetworkingremastered
In short, Forge Networking is a free and open source multiplayer game (multi-user) networking system that has a very good integration with the Unity game engine. You wanna make a multiplayer game or real time multi-user application? This is the library for you.
Stars: ✭ 1,338 (+1199.03%)
Mutual labels:  unity, unity3d
Unityheapcrawler
Reflection based heap shapshot tool for Unity game engine
Stars: ✭ 91 (-11.65%)
Mutual labels:  unity, unity3d
Candycoded
🍭 Custom Unity Components that are delightful
Stars: ✭ 96 (-6.8%)
Mutual labels:  unity, unity3d
Spriteglow
A sprite glow effect for Unity game engine
Stars: ✭ 1,287 (+1149.51%)
Mutual labels:  unity, unity3d
Unity3d
Syphon Implementation for Unity3D Pro
Stars: ✭ 90 (-12.62%)
Mutual labels:  unity, unity3d
Phoenixsharp
C# Phoenix Channels client. Unity Compatible.
Stars: ✭ 96 (-6.8%)
Mutual labels:  unity, unity3d
Klak
Creative coding library for Unity
Stars: ✭ 1,347 (+1207.77%)
Mutual labels:  unity, unity3d

ARCoreUtils

Unity plugin that makes ARCore trackable planes receive shadows and provide collision.

Getting Started

  • Drag the ARSurfaceManager prefab into the scene.
  • Add a white directional light in the scene, pointing downward.
  • Deploy to device.

Features

Collision

It's helpful to have objects in the virtual scene collide with the ground of the real scene.

The ARCore SDK's trackable planes are essentially identified flat surfaces such as the ground or a tabletop.

ARCoreUtils asks the SDK for a list of points in each trackable plane's boundary polygon (retrieved in clockwise order). A mesh is created for these points via triangulation. With the mesh ready, we create a GameObject and add a MeshCollider component that references it.

Shadows

Casting shadows from objects in the virtual scene helps glue them to the real world.

The only problem with that is that there is no floor in the virtual scene that can receive shadows from the drone. Basically, we need to render an invisible floor that can receive shadow.

From what I know, there's no suitable shader in Unity out-of-the-box, so I decided to create a new one. I'll get back to that shader in a bit, but first: we need a light source that casts shadows. Make sure you have a white directional light in the virtual scene, pointing downward. It's not a perfect representation of the real scene light, of course, but most light come from above, so it'll do for now.

A MeshRenderer and a MeshFilter is created for all trackable planes, using the same mesh we created for the collision previously. The MeshRenderer uses a material with the new shader.

The ARSurface shader

Desired result
  • Final pixel color = real world pixel color (from camera) * virtual light at this pixel (lit/shadowed).
Vertex shader
  • Just pass through data.
Fragment shader
  • Calculate the amount of virtual light hitting this fragment.
  • White when not in shadow.
  • Black when in shadow.
Blending

Syntax in Unity is “Blend SrcFactor DstFactor”.

  • The generated color is multiplied by SrcFactor.
  • The color already on screen is multiplied by DstFactor.
  • The two are added together.

To accomplish our goal we can:

  • Multiply source (virtual floor surface color) with Zero.
  • Multiply destination (real world color) with SrcColor (the color of our virtual plane - white/black depending on lit/shadowed).
  • The two are added together. Since the first one is Zero, only the second part contributes.

The blending is therefore set up as “Blend Zero SrcColor”.

The best way to wrap your head around this is to turn blending off and create a plane in the scene. Inspect it, and imagine that the color of the plane will be multiplied with the background.

Note that the shadow strength can be lowered to make it a bit softer, the math still holds up.

Happy hacking!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].