I set spotlight angle to 150 degree. But it is not doing what I hope for in this unusual situation.
It's simple.
If I set spot light angle to 150 degree, then it has to lighten 150 degree area. but as you can see above, light reaches only small area in the center(maybe like 24 degree area??)
Why is this happening? and How can I fix it?
I know I can make range something big like 5000 to solve problem. But I have to make spotlight reach until maximum range. And on maximum range, light should be spread out exactly along with angle. Light must be SPREAD ON MAXIMUM RANGE.
Distance between spot light and plane is 50. and spotlight range is 51. I overrided default shader to modify light attenuation to be very low so that light will be reached until almost maximum range.
Thanks.
Added purpose of my application and shader
OK. First of all, Thank you all for your time to help me. Really.. I really appreciate of everyone.
I am pretty experienced full-stack programmer but really new in 3D graphics and shader things.. So I don't think I can make projector by my own in short time without long term study of shader programming.
Anyway,
Purpose of my application
I'm simulating CCTV placement and I have to visualize exact CCTV coverage area. That's why I need something like unity standard asset projector. BUT! UNITY PROJECTOR can't make shadow and it even lighten back side of mesh which doesn't make sense totally and can't be used for my purpose. As mentioned in answers, I know that I'm making something very unrealistic. To visualize exact CCTV coverage area, I need some light which goes only until certain range. So, to clarify what I'm trying, I will list the properties my projector needs to satisfy.
Possible to control vertical and horizontal angle. (Unity projector can)
- Rectangular shape as CCTV cameras see (I think cookie can solve)
- Possible to control maximum range (light or cameras always has range option)
- Light should reach until maximum range and it has to evenly distributed in maximum range. (This is the beginning of this thread)
- Projector should make hard shadow (because purpose is showing exact coverage area)
I was planning to make this kind of projector putting spot light inside of box with a rectangular hole. I was going to dynamically make exact coordinated box according to properties of CCTV above : range. vertical and horizontal angle. But if spot light is like this, I can't do this.
My shader (I don't want to call it MY shader beacause I just added a line to default shader as I mentioned)
- I changed light mode to deferred in player setting
- Changed DEFERRED default shader to my custom shader in resources folder(Internal-DeferredShading.shader). But I didn't change any code in this file.
- Copy UnityDeferredLibrary.cginc file in my resources and added a line
This is the shader code
// spot light case
#if defined (SPOT)
float3 tolight = _LightPos.xyz - wpos;
half3 lightDir = normalize (tolight);
float4 uvCookie = mul (_LightMatrix0, float4(wpos,1));
float atten = tex2Dproj(_LightTexture0, UNITY_PROJ_COORD(uvCookie)).w;
atten *= uvCookie.w < 0;
float att = dot(tolight, tolight) * _LightPos.w;
// as you can notice, this is A line I added
att = att *att *att *att*att *att *att *att*att *att *att *att * att *att *att *att*att *att *att *att*att *att *att *att * att *att *att *att*att *att *att *att*att *att *att *att;
atten *= tex2D (_LightTextureB0, att.rr).UNITY_ATTEN_CHANNEL;
atten *= UnityDeferredComputeShadow (wpos, fadeDist, uv);
I'm now really desperate and hurry now. I really need help. I am even willing to pay if someone makes this kind of projector...
Thank you again to all. I really appreciate.
reference images