I have a light projector from the standard asset package hitting a plane, but the light it gives out is very pale, hardly visible. I would like to increase it’s intensity, but I know nothing about shader code, and two hours of searching has yielded no answer.
I was able to achieve the desired effect by putting a second identical projector in the same place, but that is just horrible for performance.
Is there an easy way to do this?
Thank you!
(I prefer javascript for coding)
I use this one that also preserves “Near Clip Plane” and “Far Clip Plane”. Try with Intensity 3 for example. This works like a charm for me.
// Upgrade NOTE: replaced '_Projector' with 'unity_Projector'
// Upgrade NOTE: replaced '_ProjectorClip' with 'unity_ProjectorClip'
Shader "Projector/LightWithIntensity" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ShadowTex ("Cookie", 2D) = "" {}
_FalloffTex ("FallOff", 2D) = "" {}
_Intensity ("Intensity",Float) = 1
}
Subshader {
Tags {"Queue"="Transparent"}
Pass {
ZWrite Off
ColorMask RGB
Blend DstColor One
Offset -1, -1
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct v2f {
float4 uvShadow : TEXCOORD0;
float4 uvFalloff : TEXCOORD1;
UNITY_FOG_COORDS(2)
float4 pos : SV_POSITION;
};
float4x4 unity_Projector;
float4x4 unity_ProjectorClip;
v2f vert (float4 vertex : POSITION)
{
v2f o;
o.pos = UnityObjectToClipPos(vertex);
o.uvShadow = mul (unity_Projector, vertex);
o.uvFalloff = mul (unity_ProjectorClip, vertex);
UNITY_TRANSFER_FOG(o,o.pos);
return o;
}
fixed4 _Color;
sampler2D _ShadowTex;
sampler2D _FalloffTex;
float _Intensity;
fixed4 frag (v2f i) : SV_Target
{
fixed4 texS = tex2Dproj (_ShadowTex, UNITY_PROJ_COORD(i.uvShadow));
texS.rgb *= _Color.rgb;
texS.a = 1.0-texS.a;
fixed4 texF = tex2Dproj (_FalloffTex, UNITY_PROJ_COORD(i.uvFalloff));
fixed4 res = texS * _Intensity * texF.a;
UNITY_APPLY_FOG_COLOR(i.fogCoord, res, fixed4(0,0,0,0));
return res;
}
ENDCG
}
}
}
The above solution did not work for me, it would change all of my impacted materials to Magenta. I am also shader code inept, and struggled for quite some time to find a solution for this.
What ended up working for me, was to change one line of code (line 16) inside the standard Projector/Light shader:
Blend DstColor One
to
Blend SrcColor One
I also added just a flat white texture to my falloff input, and from there am able to lower the intensity (should I choose) through the “Main Color” channel.
I know it’s an old topic, but a very simple alternative for us HDR users is to goto the standard shader and add [HDR] on top of the main color.
From this
_Color ("Main Color", Color) = (1,1,1,1)
to this
[HDR]
_Color ("Main Color", Color) = (1,1,1,1)
It effecitvely enables the HDR color picker and gives you built in access to the brightness value.
Here is the solution that have worked fine for me.
http://effectronica.com/?p=462
Replace the Projector/Light with the shader :
Shader "Effectronica/Zodiac Additive" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ShadowTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
_FalloffTex ("FallOff", 2D) = "white" { TexGen ObjectLinear }
}
Subshader {
Tags { "RenderType"="Transparent-1" }
Pass {
ZWrite Off
AlphaTest Greater 0
Offset -1, -1
ColorMask RGB
Blend SrcAlpha One
Color [_Color]
SetTexture [_ShadowTex] {
constantColor [_Color]
combine texture*constant
Matrix [_Projector]
}
SetTexture [_FalloffTex] {
constantColor (0,0,0,0)
combine previous lerp (texture) constant
Matrix [_ProjectorClip]
}
}
}
}
And you will have your Projector shining really bright!
Using the ProjectorLight shader from Standard Assets/Effects/Projectors/Shader, you can change the Main Color to make it brighter,
e.g. in the material inspector change the Main Color to higher RGB, like white 255,255,255.
Projector Light.shader
Just replace with it and than change ‘Intensity’ float at material ! Done 
// Upgrade NOTE: replaced '_Projector' with 'unity_Projector'
// Upgrade NOTE: replaced '_ProjectorClip' with 'unity_ProjectorClip'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Projector/Light" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ShadowTex ("Cookie", 2D) = "" {}
_FalloffTex ("FallOff", 2D) = "" {}
_Intensity ("Intensity",Float) = 1
}
Subshader {
Tags {"Queue"="Transparent"}
Pass {
ZWrite Off
Fog { Color (0, 0, 0) }
ColorMask RGB
Blend DstColor One
Offset -1, -1
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 uvShadow : TEXCOORD0;
float4 uvFalloff : TEXCOORD1;
float4 pos : SV_POSITION;
};
float4x4 unity_Projector;
float4x4 unity_ProjectorClip;
v2f vert (float4 vertex : POSITION)
{
v2f o;
o.pos = UnityObjectToClipPos (vertex);
o.uvShadow = mul (unity_Projector, vertex);
o.uvFalloff = mul (unity_ProjectorClip, vertex);
return o;
}
fixed4 _Color;
sampler2D _ShadowTex;
sampler2D _FalloffTex;
float _Intensity;
fixed4 frag (v2f i) : SV_Target
{
fixed4 texS = tex2Dproj (_ShadowTex, UNITY_PROJ_COORD(i.uvShadow));
texS.rgb *= _Color.rgb;
texS.a = 0;
fixed4 texF = tex2Dproj (_FalloffTex, UNITY_PROJ_COORD(i.uvFalloff));
fixed4 res = texS * _Intensity;
return res;
}
ENDCG
}
}
}