Quantcast
Channel: Questions in topic: "shader programming"
Viewing all articles
Browse latest Browse all 169

Need help with billboard shader

$
0
0
So I have this billboard shader that I found online and it works good and all but it's missing some things that I need and I have never worked with shaders before and don't know how to add it on my own. _ So here is what I need to add: 1. I need to add a color property to the materials, because many of my textures use grayscales and I need to set the color for those grayscales. Material.color does not work for that 2. Some of my meshes share the same position, so then it happens that some are rendered in front of others. this becomes a problem because the wrong ones are renderer in front and I don't seem to have any control on the order of the billboards. I have no idea if it is even possible, but I would love to add some sort of layer sorting thingy that could help me choose the order of which the meshes are renderer so that the correct ones are shown in front of others. Maybe something similar to the 2D layering system for sprite renderer? Any help would be greatly appreciated! _ Here is the shader: Shader "Custom/Billboard" { Properties { _MainTex("Texture Image", 2D) = "white" {} _ScaleX("Scale X", Float) = 1.0 _ScaleY("Scale Y", Float) = 1.0 } SubShader { Tags {"Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"} ZWrite Off Blend SrcAlpha OneMinusSrcAlpha Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag // User-specified uniforms uniform sampler2D _MainTex; uniform float _ScaleX; uniform float _ScaleY; struct vertexInput { float4 vertex : POSITION; float4 tex : TEXCOORD0; }; struct vertexOutput { float4 pos : SV_POSITION; float4 tex : TEXCOORD0; }; vertexOutput vert(vertexInput input) { vertexOutput output; output.pos = mul(UNITY_MATRIX_P, mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0)) + float4(input.vertex.x, input.vertex.y, 0.0, 0.0) * float4(_ScaleX, _ScaleY, 1.0, 1.0)); output.tex = input.tex; return output; } float4 frag(vertexOutput input) : COLOR { return tex2D(_MainTex, float2(input.tex.xy)); } ENDCG } } }

Viewing all articles
Browse latest Browse all 169

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>