- Home /
Blob shadow with a pseudo realtime effect
Hi guys! I have the free version of Unity, so I cannot have any realtime shadows for my car in a new racing game that I am making. Having a blob shadow is not good enough as is looks unrealistic if the directional light ( the sun ) is at an angle.
I did some thinking, if the blob shadow projector can be inclined at a angle with the car, provided that the directional light is far enough to be assumed at infinity, then a more realistic shadow can be obtained when the projector is along the line joining the car and the sun. I have a code here :
var car : Transform;
var sun : Transform; //the directional light that should cast shadow
var viewLine : Vector3; //vector from car to sun
var carPos : Vector3;
var sunPos : Vector3;
var projectorPosition : Vector3; //where the projector should be
function Update(){
carPos = car.position;
sunPos = sun.position;
viewLine = sunPos - carPos;
//I want the projector to be 10 units away from the car
projectorPosition = viewLine.normalized * 10;
transform.position = carPos + projectorPosition;
//keep the projector faced towards the car
transform.LookAt(car);
}
The above code goes in the blob shadow projecter, which is not a child of the car. I couldnt post screenshots right now, but what happens is that the projector is not aligned at a proper angle with the car but stays at a fixed distance and along the line joining the car and the directional light source...or better If someone could try this script out and see. :)
Or is there a method of getting similar results with a different method?
Thanks for reading! Vatsal