- Home /
Receive shadows on "Screen Space - Camera" canvas
Hello!
My scene consists of a dice box (Constrained space for dice throwing, transparent), but main interaction is done through the "Screen Space - Camera" UI canvas. The problem is that this type of canvas ignores shadows, and if you throw dice in the dice box on top of it, it looks like a dice is floating even after landing, because there is no shadow. I would like to make it render. I would appreciate pointing in the direction of a solution.
Here is how it looks (Gray is representation of UI):
Here is how I want it to look, but without prototype texture:
Thanks in advance!
Have you tried making a world canvas that is a child of your camera?
Yes, but it does not render shadows on itself too, and it is not fit for purpose moreover
Have you considered just faking it with a black shadow UI element as a child of your die?
Answer by SunnyChow · Feb 16, 2018 at 05:22 PM
You description is confusing. What are doing? Are you rendering things on RenderTexture? Or are you parenting the 3d GameObject onto the UI elements?
if it's case 1, the shadow is rendered on the RenderTexture, but the alpha channel is kept as zero. You need some custom shader to adjust it.
if it's case 2, UI default shader doesn't receive shadow. you need to write a ui shader that receive shadow
I have all interactions done at UI canvas, dice box is 3d and is always at top. It's only goal is for throwing dice, for it to look fancy and stuff. But dice doesn't cast shadows on canvas. I thought there could be another way of doing it, except for the shader writing, guess will have to look into it some day or another. Anyway, thank you!
Answer by Harinezumi · Feb 16, 2018 at 09:56 PM
It is perfectly fine to use multiple cameras in a scene (as long as only one has AudioListener on it), then order them with their camera depth property. So in your case I would have a camera that just renders the 2D UI, and then another camera, above the UI, that renders the 3D dice over a 3D box.
Would this approach do what you are trying to achieve?
Your answer
Follow this Question
Related Questions
IOS Unity 5 spike in "RenderShadowMap 1 Answer
How to attach a (that world type) canvas to a moving player? 0 Answers
Shadows in my rendered "Portal" Don't Render 0 Answers
All UI getting pink in windows 1 Answer
Native Rendering Plugin with UI Image 0 Answers