Combining 2 shaders
I have a sphere in my game and I need to have a texture on its insides. For that I use a certail script. I also want to be able to fade textures in and out with a function I have in another script.
But I can not combine these script. No matter what I try, the image doesn't show inside the sphere.
The shaders are:
Flip Insides:
Shader "Flip Normals" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
Cull Front
CGPROGRAM
#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
float4 color : COLOR;
};
void vert(inout appdata_full v)
{
v.normal.xyz = v.normal * -1;
}
void surf (Input IN, inout SurfaceOutput o) {
fixed3 result = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = result.rgb;
o.Alpha = 1;
}
ENDCG
}
Fallback "Diffuse"
}
And the fader:
Shader "Custom/AlphaBlendTransition" {
Properties {
_Blend ("Blend", Range (0, 1) ) = 0.0
_BaseTexture ("Base Texture", 2D) = "" {}
_OverlayTexture ("Texture 2 with alpha", 2D) = "" {}
}
SubShader {
Pass {
SetTexture[_BaseTexture]
SetTexture[_OverlayTexture] {
ConstantColor (0,0,0, [_Blend])
combine texture Lerp(constant) previous
}
}
}
}
Is it possible to combine these shaders while still viewing the texture from the spheres inside?
Comment
Answer by Namey5 · May 22, 2016 at 06:41 AM
Properties {
_Blend ("Blend", Range(0,1)) = 0.0
_MainTex ("Base (RGB)", 2D) = "white" {}
_OverlayTex ("Texture 2", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
Cull Front
CGPROGRAM
#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
sampler2D _OverlayTex;
struct Input {
float2 uv_MainTex;
float2 uv_OverlayTex;
float4 color : COLOR;
};
half _Blend;
void vert(inout appdata_full v)
{
v.normal.xyz = v.normal * -1;
}
void surf (Input IN, inout SurfaceOutput o) {
fixed3 result = lerp (tex2D (_MainTex, IN.uv_MainTex), tex2D (_OverlayTex, IN.uv_OverlayTex), _Blend);
o.Albedo = result.rgb;
o.Alpha = 1;
}
ENDCG
}
Fallback "Diffuse"