It's been two days since I'm looking for information about the shadow of the character.
The environment is 2d, screen space and 3d character.
The problem is that the plane positioned in front of the 2d background does not become transparent (with 2D camera).
I've tried MatteShadow taken from the AC 2.5d tutorial but also FX_Matte Shadow, Custom_ShadowDrawer, InvisibleShadowCaster, Selfmade_TrasparentShadowReceiver (unity forum) and a combination of them in the Mesh Renderer and Shader of the Plane.
Whatever I do if the plane is visible there is the shadow of the character if the plane becomes invisible (thanks to scripts) there is no shadow.
What is a 2.5d game without the shadow? And how is it possible for an engine as unity to have these limitations when an old Wintermute has no problem in this regard and the engine was written by a single person and not by a team?
Does anyone have any idea how to make the plane transparent but allowing the shadow of the character? I can not use the AC 2.5D camera because of some limitations.
Thanks.
Comments
I agree that it should be more simple to have "overlay" shadows in Unity - the MatteShadow example script in the 2.5D tutorial works for me, but only when using Directional lights. Point and Spot lights don't work.
One technique that gives much better results is to create a separate "shadow" camera that then gets overlayed on top of the MainCamera - similar to how you might do it in Photoshop.
I'll see about writing a tutorial for it, but here's the rough guide:
1) Duplicate your character's mesh GameObject (the one with the Skinned Mesh Renderer) and place it on the BackgroundImage layer.
2) Set this duplicate object's Cast Shadows value to Shadows Only
3) Create a plane for the floor, and place it on the BackgroundImage layer. The plane should have a standard default-white material.
4) Create a new Camera in the scene named "Shadow Camera", and remove all components except for the standard Unity camera. Then make it a child of the MainCamera, clearing its transform so that it shares the same point in space and field-of-view.
5) Create a new Render Texture asset in your Project folder, and set the Size values to match your game's intended resolution.
6) Set ShadowCamera's Culling Mask to BackgroundImage, Clear Flags to Solid Color (white) and assign the Render Texture as the asset you just created.
7) Duplicate your scene's light, and set the Culling Mask to BackgroundImage only and enable shadows.
8) If you are using a point light, you will need to ramp up the Intensity value so that the plane is completely white, save for the shaded area caused by your character
9) Download the Legacy Image Effects asset here: https://www.assetstore.unity3d.com/en/#!/content/83913
10) Open ScreenOverlay.cs and replace line 22:
11) Select the MainCamera and attach the modified Screen Overlay component to it
12) Set the Blend Mode to Multiply, and the Texture as the Render Texture asset
You should then have shadows projected onto the plane appearing on top of the rest of your scene.
The MatteShadow shader is only designed to work with nothing behind it, hence the problem.
You should still be able to make use of that shader by moving the background onto the BackgroundImage layer, and then creating the same "ShadowCamera" as the tutorial (which only renders that layer), and making sure the MainCamera doesn't render that layer. That's essentially the principle behind 2.5D mode, only using a sprite instead of a GUI component.
The MainCamera's Clear Flags will also need to be set to Depth Only, and have a higher Depth value than your ShadowCamera.
When the Scene window is open, and you select the ShadowCamera child, the "Camera preview" window should show just the background sprite image. The MainCamera should show your Player on a black background.