- Home /
whats prevent shadows from coming
I am not able to produce shadows in unity 3d pro. I have tried with both hard and soft shadows. But not able to see shadows .I also want to produce realtime shadows and detect shadows. whats preventing shadows from coming.
I have attached the scence with my question. link text
I have read this already and done all the required settings. But still not able to see any shadows. and I also want to detect shadows as well using script.Thanks
Best solution for directional lights is to just detect a certain angle of rotation of the directional light for static objects.
For other light types try to deter$$anonymous$$e ways to get the information you need without actually relying on knowing actual light information.
If you just need the shadow information for a visual effect (but not a game mechanic) then solve it with a shader.
Shadows are created only in the rendering pipeline (or baked into a lightmap in the editor). You can't easily get the amount or even if a object is receiving a shadow.
For realtime random light shadow tracking you would need:
A system to cast rays to check if there is a direct unobstructed line to every light source.
cast a ray toward the inverse direction of your directional light or towards the position of a normal light
Detect if there is a collider in the way, if a collider is hit you have a shadow. If there is a ceiling or something behind the light, use a radius 1 collision sphere on the light. On collision ask for the light, if there is none -> shadow
For performance I also recommend:
A system to not have to do complete step 1 for every inch of every object every frame.
A system that seperates step 2 into smaller chunks allowing for smaller updates (number of rays per frame, next frame does the next batch, next frame does the third batch etc )
An alternative would be to render the scene with a replacement shader that renders only the shadows in white to a render texture, then use some math to figure out the point in which you are interrested and check if the pixel is white.
For the rest you will need to open up new questions ;-)
Answer by Freezy · Jun 26, 2012 at 09:27 AM
Do not use the built in default diffuse, it has no shadow support apparently. Create a material, diffuse shader, optionally assign a color.
Shadow should now appear at least in game view.
I have used materials and assigned the color still not able to see any real shadows
Answer by Meltdown · Jun 26, 2012 at 05:24 PM
Click on your light, and make sure you set it to have shadows. Also check your quality settings. Project Settings -> Quality. You may be on an editor quality setting that has shadows disabled.
I have checked all the setting but not able to see any shadows in my game .I also want to detect my shadows as well when it is lying on object and when object is in direct contact with sun
Your answer
Follow this Question
Related Questions
Trees done by brush won't cast a shadow? 0 Answers
Shadow Demo in Unity 3 Pro 1 Answer
Why is shadow going through a part of a wall? 1 Answer
Unity Custom CutOut Shader 1 Answer
Toon Shader Not Working With Multiple Spotlight Shadows (Pro) 0 Answers