Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Sprites/Billboard" {
- Properties {
- _MainTex ("Texture Image", 2D) = "white" {}
- _Color ("Main Color", Color) = (1,1,1,1)
- _ScaleX ("Scale X", Float) = 1.0
- _ScaleY ("Scale Y", Float) = 1.0
- }
- SubShader {
- Pass {
- Tags{"QUEUE" = "AlphaTest" "RenderType" = "TransparentCutout" }
- AlphaToMask On
- ColorMask RGB
- Cull Off
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- // User-specified uniforms
- uniform sampler2D _MainTex;
- fixed4 _Color;
- uniform float _ScaleX;
- uniform float _ScaleY;
- struct vertexInput {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- fixed4 color : COLOR;
- };
- struct vertexOutput {
- float2 uv : TEXCOORD0;
- float4 pos : SV_POSITION;
- fixed4 color : COLOR;
- };
- vertexOutput vert(vertexInput input)
- {
- vertexOutput o;
- o.pos = UnityObjectToClipPos(input.vertex);
- o.uv = input.uv.xy;
- // billboard mesh towards camera
- float3 vpos = mul((float3x3)unity_ObjectToWorld, input.vertex.xyz);
- float4 worldCoord = float4(unity_ObjectToWorld._m03, unity_ObjectToWorld._m13, unity_ObjectToWorld._m23, 1);
- float4 viewPos = mul(UNITY_MATRIX_V, worldCoord) + float4(vpos, 0);
- float4 outPos = mul(UNITY_MATRIX_P, viewPos);
- o.pos = outPos;
- o.color = input.color;
- return o;
- }
- float4 frag(vertexOutput input) : COLOR
- {
- // sample the texture
- fixed4 col = tex2D(_MainTex, input.uv);
- return col;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement