Question by
stokesy96 · Jun 13, 2018 at 11:47 AM ·
shadersshader programmingshaderlab
Trying to make a masking shader and the areas that are supposed to be blank are culling the things behind it.
Hi,
I'm trying to make a shader smoke particles and the areas that are supposed to be blank are culling the things behind it. I don't really know what the technical name for this is so I haven't been able to trouble shoot it very successfully.
This is the shader code I'm using: // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,)' with 'UnityObjectToClipPos()'
// Unlit alpha-blended shader.
// - no lighting
// - no lightmap support
// - no per-material color
Shader "Unlit/TransparentAlphaMask" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_AlphaTex ("Alpha mask (R)", 2D) = "white" {}
_SpeedX("speedX", float)=1.5
_SpeedY("speedY", float)=1.5
_Scale("Scale", range(0.005,0.5))=0.03
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend SrcAlpha OneminusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
sampler2D _AlphaTex;
float4 _MainTex_ST;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord);
fixed4 col2 = tex2D(_AlphaTex, i.texcoord);
return fixed4(col.r, col.g, col.b, col2.a);
}
ENDCG
}
}
}
issue.png
(83.3 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612164656im_/https://answers.unity.com/themes/thub/images/avi.jpg)