Question by
OndraPaska · Jan 03, 2018 at 10:05 AM ·
shaderalphaspriterenderer
[SOLVED] Sprite renderer does not render transparent parts of texture
Sprite renderer seems to do some optimization and does not render parts of the image, if they are completely transparent. Bellow is the same shader with a quad and a sprite renderer with the same image (the black squiggle on a transparent background) .
Can this behaviour be somehow switched off?
Please help me, thanks!
This shader just bumps the alpha of any pixel by 0.5
Shader "Shaders101/my1ushader"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"PreviewType" = "Plane"
}
Pass
{
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
float4 frag(v2f i) : SV_Target
{
float4 color = tex2D(_MainTex, i.uv);
float4 mlc = float4(0,0,0,0.5);
return color+mlc;
}
ENDCG
}
}
}
Comment
Best Answer
Answer by OndraPaska · Jan 14, 2018 at 07:57 PM
Ok I figured it out.
For anyone else having to same problem: go to the sprite Import Settings and change the mesh type from Tight to Full Rect.