/TexturePremul.shader Secret
Created
August 26, 2021 08:19
Premultiplied alpha shader drawing a texture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Unlit/TexturePremul" { | |
Properties { | |
_MainTex ("Texture", 2D) = "white" {} | |
} | |
SubShader { | |
Tags { "RenderType"="Transparent" "Queue"="Transparent" } | |
Pass { | |
Blend One OneMinusSrcAlpha // premultiplied alpha | |
ZWrite Off | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
sampler2D _MainTex; | |
struct MeshData { | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct Interpolators { | |
float4 vertex : SV_POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
Interpolators vert (MeshData v) { | |
Interpolators o; | |
o.vertex = UnityObjectToClipPos(v.vertex); | |
o.uv = v.uv; | |
return o; | |
} | |
float4 frag( Interpolators i ) : SV_Target { | |
return tex2D( _MainTex, i.uv ); | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment