Help with my shader

Hi all,

After much searching and reading I managed to hack together my shader that takes a rendertexture and applies it as an alpha cutout. I wanted it to apply the cut to a tiling main texture which it does.

But now I would really like the tiling main texture to have its own embedded alpha channel so that that I can layer several poly planes with that material applied, to get a nice layered depth effect but using the one cookie cutter rendertexture on all of them so that it looks like I’m cutting through all layers.

Adding bump support would be fantastic as well on the main texture… but not necessary :smile:

Hope that makes sense? Below is my shader:

Shader "FX/RenderTexture Red Channel To Alpha" { 

	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
	   	_MainTex ("Base (RGB)", 2D) = "white" {}
		_RT ("Base (RGB)", 2D) = "white" {}
	   	_Cutoff ("Cutoff", Range (0,1)) = .5 
	} 
		SubShader {
			Pass {
				Lighting On
		        Material {
		            Diffuse [_Color]
		            Ambient [_Color]
				}
				CGPROGRAM 
					#pragma fragment frag 
					#pragma fragmentoption ARB_fog_exp2
					#include "UnityCG.cginc" 

					sampler2D _MainTex;
					sampler2D _RT; 

					struct v2f { 
					    float4 uv[2] : TEXCOORD0;
						float4 diffuse : COLOR;
					}; 

					half4 frag (v2f i) : COLOR 
					{ 
					   	half4 color = tex2D(_MainTex, i.uv[0].xy);
						half4 alpha = tex2D(_RT, i.uv[1].xy);
					   	return half4 (color.r, color.g, color.b, alpha.r) * i.diffuse*2.0;
					} 
				ENDCG 
		      	AlphaTest Less [_Cutoff]
			} // pass 
		} // subshader 
		Fallback "Transparent/Diffuse" 
} // shader

Thanks in advance for any help I get.

Cheers.

ok solved it. just added the new alpha channel to the rendertexture r channel and it gave me my required outcome. Very simple really… :wink:

Cheers.