- Home /
Why won't my transparent with shader allow me to change the opacity
I have a shader, which allows me to cast a shadow on a transparent material (which I found here on answers).
It works great; except for one thing : I cna't change the intensity/opacity/blackness of the shadow (anyone of those would make me happy; though I'd prefer opactiy properly on my device.
On the desktop, i found that if I put the albedo value up, that my shadow would become more white, and therefore more transparent. It works a bit on my iOS device, but after about 40% of opacity, it just stops getting any ligter (i.e. I can do albedo 100 and it's the same as albedo 2.
Does anyone have any idea about how to fix this shader on iOS? I've spent days stuck on it..
Here it is
Shader "FX/Matte Shadow" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.01
_ShadowStrength ("Shadow strength", Range(0,5)) = 1
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 200
Blend Zero SrcColor
CGPROGRAM
#pragma surface surf ShadowOnly alphatest:_Cutoff
fixed4 _Color;
float _ShadowStrength;
struct Input {
float2 uv_MainTex;
};
inline fixed4 LightingShadowOnly (SurfaceOutput s, fixed3 lightDir, fixed atten){
fixed4 c;
c.rgb = s.Albedo*atten;
c.a = s.Alpha;
return c;
}
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = _Color;
o.Albedo = c.rgb * _ShadowStrength;
o.Alpha = 0;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
Answer by Infrid · Feb 22, 2014 at 03:09 AM
Ok, SuperPig very generously fixed this for me.
Line 25 becomes: c.rgb = lerp(_ShadowStrength *.75, 1, atten).rrr;
Your answer
Follow this Question
Related Questions
Shadow Support in Custom Shader 0 Answers
Edge outline & 2D shadow Shader for planar mesh 0 Answers
How to make shader outline without inner shadow? 0 Answers
Make this shader receive and cast shadow? Can anyone help me thanks! 0 Answers
Combine Basic Shadow Shader and Transparency Shader in Unity 0 Answers