hi all,
i am trying to use this billboard shader from wikibooks - ive seen it used and working on a youtube tutorial (using unity 5x), but i cant get it to work.
i create a new surface shader, delete the code that is there and paste in the code from wikibooks, compile, and then try to add it to a material.
the first issue is that all the shader is tagged “cg shader for billboards” in the codes first line, it only shows up in the shader drop down menu as its file name ‘new surface shader’ under the custom tab.
secondly and most importantly - it doesnt work - ive applied it to a material but nothing -
in the youtube video its clear that is does work…
i dont know whether some of the code has changed in the upgrade from 5x to 2017 but can someone help please?
the youtube link is:
and the code is :
Shader "Cg shader for billboards" {
Properties {
_MainTex ("Texture Image", 2D) = "white" {}
_ScaleX ("Scale X", Float) = 1.0
_ScaleY ("Scale Y", Float) = 1.0
}
SubShader {
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
}
}
}
thanks all
paul uk