- Home /
Combining two transparent shaders with diffuse lighting
I'm trying to write a shader which takes two texture inputs, combines them using seperate texture coordinates (uv, uv2) and alpha channels, whilst using diffuse lighting.
I've copied the source for the Unity Alpha-Diffuse shader, and got as far a combining the textures but when I view the results in the scene it seems that the lighting is also affecting the alpha values of the texture. So things appear more faded than they should be? I'm thinking maybe this is to do with the way I'm combining the colour values of the two textures.
Below is the source for the shader, any help with how to properly combine colour values with this lighting model would be greatly appreciated!!
Shader "Custom/CardShader2" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Card", 2D) = "white" {}
_CharacterTex ("Character", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
CGPROGRAM
#pragma surface surf SimpleLambert alpha
sampler2D _MainTex;
sampler2D _CharacterTex;
float4 _Color;
struct Input {
float2 uv_MainTex;
float2 uv2_CharacterTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c1 = tex2D(_MainTex, IN.uv_MainTex) * _Color;
half4 c2 = tex2D(_CharacterTex, IN.uv2_CharacterTex) * _Color;
o.Albedo = lerp(c1.rgb,c2.rgb,c2.a);
o.Alpha = c1.a;
}
ENDCG
}
Fallback "Transparent/VertexLit"
}
Thanks in advance :)
Your answer
Follow this Question
Related Questions
Transparent Vertex Shader Error 1 Answer
Can you get how much light is on the surface in a shader? 0 Answers
Stencil buffer and transparency 0 Answers
Help Turning Sprites into 3D Objects and Casting Shadows 1 Answer
Transparent cutout shader for circular timer from Photoshop PNG is too messy/sloppy 1 Answer