- Home /
How to measure the area of shadow on a GameObject?
Good day everyone.
I have a simple scene: a plane with several cube GameObjects (of varying sizes, with textures on each facet) and a directional light shining at an angle (with hard shadows). The result is that each facet of most of the cubes has a differently-sized shadows cast on it.
Is it possible to read how much shadow is cast (in percentages maybe?) on each facet of a cube?
I was thinking maybe by reading how the color of the texture on each facet of a cube changes by the shadow cast on it, but I do not know how to do it.
Does the color of the texture actually changes?
Do I need to read some light map on a GameObject to determine this?
Could someone provide a sample code on how this could be done?
Thank you!
I do not quite get it, if you have the cubes on scene, the shadow is not on them but on any object behind them.
Then you can read on: http://web.cs.wpi.edu/~matt/courses/cs563/talks/shadow/shadow.html
Also, section 9.4 of the Cg tutorial has a good explanation of the basic technique: http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter09.html
Of course not all the cubes have shadows. I am asking, how do I access that information in Unity?
I want to know, for each cube that has a shadow cast on it, to be able to calculate how much shadow is cast, without having to implement an outside algorithm to do it.
I mean, the information is right there - the shadow is displayed correctly after all. I am only asking - how do I access that data and read from it?
You can't. Follow Aras' advice to render it manually from the light's POV using the information already provided.
Your answer
Follow this Question
Related Questions
Receive Shadows with Custom Vertex Shader & Shadow Passes Functioning Incorrectly 1 Answer
Toon Shader Not Working With Multiple Spotlight Shadows (Pro) 0 Answers
Toon Shader Working With Multiple Spotlight Shadows (Pro) 0 Answers
Custom Shadow Effects 1 Answer
Shadows have weird seams and gaps 1 Answer