Unity Shadow in Virtual Reality

How to make a shadow in augmented reality games workaround for shaders in unity

googlecardboardI created a box as flat as a plane. and I put this pox under my character. And I parented the box / plane to the character. So that the charscter is standing on that plane. That means on the left side in unity 3d where the objects are listed I dragged and dropped the box onto the character that I want to have the shadow. So when the character moves the box / plane moves with it below his feet. Now a a texture for this box I have made a graphic that is a png image. A png image can have transparent parts. And the image is one big round black dot filling nearly the complete image and getting invisible to the sides. A black spot is on the png image. This is going to simulate the shadow of your things in the augmented reality game. Look at the image of the alien above. Actually this then is not a real shadow but a black dot that gets more transparent to its sides that moves along with your character. But in terms of illusion for your augmented reality it is really worth a lot. because all these things with shaders that show only shadow in unity 3d are seemingly complicated. I did not manage to get them to work. so I was very happy when I thought of the described workaround for at least having the illusion of an interaction of the objects with the ground of the real world in the augmented reality. I tried it in my app I think it looks pretty neat.

My augmented reality game game using “fake shadow”


My unity VR game

So you right click in your assets at the bottom of the screen and select create > material. Then you tell this material to have as its shader: Legacy shader / transparent. When you click the material you find the option to change the shader at the top right in the inspector. then right. You choose Legacy shader because it does not show a highlight reflection of the light on the transparent parts of your object. So with this shader transparent is transparent.

Then right below picking the shader you can click select to chose the main image for your material. Right click into the assets on the bottom again. Select: Import new asset. Then select your 200 * 200 png image of the round black dot that fills nearly the whole image and gets more transparent to its sides. Imagine to use your graphic program to take a a big fading out paintbrush nearly as big as the whole image size and just put once right into the middle on top of the invisible .png backround.

Then on the left side in unity 3d choose your box / plane. the inspector now shows the values for this box.  Then drag and drop your new material onto the inspector. the box now has this shadow material. And since the box sticks to the charakter and is flat at his feet level it will look like a shadow. this is not a real shadow but as i said. I was really very glad when I found this workaround and thought I share it with you guys. Good Luck with your project. Have fun.

I was confronted with the problem of not having shadows in my Unity augmented reality game. Because this is such an important thing to have if you want to create the illusion of things being in the real world. So I googled to find a lot of pages talking about shaders that show the shadow but are otherwise invisible. and all did not really work. So this is a workaround method that served its purpouse very well. Instead of waiting for shader developement for the next ten years I have something like a shadow already. And as I said this looks quite well. I call it fake shadow. But now my characters and objects stand on the ground. This is extremely important. My tripods look so much more realistic since they at least somehow touch the ground.

When I found this idea I was like: Yes this is great. I hope you can implement it in your games. as I said: if you like: visit my VR game with the link above. It is pretty cool and anyways worth seeing. It is a Unity Game.  Have fun programming and otherwise :) . I just wanted to put up this idea for you of the fake shadow that is a transparent big black dot on a box that the character stands upon. As I said It really worked well for me.

Unity Is cool but I think they should really add thje possibility: “Save Project as”. And I want to use videos in the free version. But the first thing is more important. Copying a project is absolutely neccessary.