Ask for help, how to change this shader into a connection graph of shader graph?
I use it as a shader billboard, but I don’t know how to use it on a shader graph.
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
float scalex=length(unity_ObjectToWorld._m00_m10_m20);
float scaley=length(unity_ObjectToWorld._m01_m11_m21);
float4 worldCoord = float4(unity_ObjectToWorld._m03, unity_ObjectToWorld._m13, unity_ObjectToWorld._m23, 1);
float4 viewPos = mul(UNITY_MATRIX_V, worldCoord) + float4(v.vertex.xscalex ,v.vertex.yscaley, 0, 0);
float4 outPos = mul(UNITY_MATRIX_P, viewPos);
o.vertex = outPos;
o.uv = v.uv;
return o;
}
Thank you !!!
Shader “ziding/duihuakuan”
{
Properties
{
_MainTex (“Texture”, 2D) = “white” {}
}
SubShader
{
Tags{“Queue”=“Transparent” “DisableBatching” = “True”}
Cull Off ZWrite Off ZTest Always
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include “UnityCG.cginc”
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
float scalex=length(unity_ObjectToWorld._m00_m10_m20);
float scaley=length(unity_ObjectToWorld._m01_m11_m21);
float4 worldCoord = float4(unity_ObjectToWorld._m03, unity_ObjectToWorld._m13, unity_ObjectToWorld._m23, 1);
float4 viewPos = mul(UNITY_MATRIX_V, worldCoord) + float4(v.vertex.xscalex ,v.vertex.yscaley, 0, 0);
float4 outPos = mul(UNITY_MATRIX_P, viewPos);
o.vertex = outPos;
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
fixed4 frag (v2f i) : SV_Target
{
fixed4 col=tex2D(_MainTex,i.uv);
return col;
}
ENDCG
}
}
}
This is the complete shader code, how can I convert it to shader grahp, I want to use it to do the billboard effect of shader grahp, Thank you !!!