shader半透明材质,粒子顶点流控制UV滚动(笔记4)
程序员文章站
2022-06-11 09:09:44
...
Shader "Shader Forge/Test01" {
Properties {
_MainTex ("Main Tex", 2D) = "white" {}
[HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {
"IgnoreProjector"="True"
"Queue"="Transparent"
"RenderType"="Transparent"
}
Pass {
Name "FORWARD"
Tags {
"LightMode"="ForwardBase"
}
Blend One One
ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// #define UNITY_PASS_FORWARDBASE
#include "UnityCG.cginc"
// #pragma multi_compile_fwdbase
// #pragma only_renderers d3d9 d3d11 glcore gles
#pragma target 3.0
// uniform
sampler2D _MainTex;
//uniform
float4 _MainTex_ST;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
fixed4 vertexColor : COLOR;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 uv1 : TEXCOORD1;
fixed4 vertexColor : COLOR;
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.uv0 = v.texcoord0;
o.uv1 = v.texcoord1;
o.vertexColor = v.vertexColor;
o.pos = UnityObjectToClipPos( v.vertex );
return o;
}
float4 frag(VertexOutput i) : COLOR {
////// Lighting:
////// Emissive:
float2 uv = float2((i.uv0.x+i.uv1.x),i.uv0.y);//i.uv0.x跟i.uv0.r都一样,为什么 shaderLab里面xyzw 对应rgba
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(uv, _MainTex));
float3 emissive = (i.vertexColor.rgb*_MainTex_var.rgb);
//float3 finalColor = emissive;
return fixed4(emissive,(i.vertexColor.a*_MainTex_var.a));
}
ENDCG
}
}
FallBack "Diffuse"
CustomEditor "ShaderForgeMaterialInspector"
}
上一篇: Unity中实现物体动态动画效果
下一篇: unity 改变子物体的层级顺序