Вот сам шейдер. В него нужно добавить обработку переменной Color (которая означает цвета вершин треугольника)
Под первым шейдером приведен пример другого шейдера, который поддерживает эти входные данные.
Заранее спасибо.
Синтаксис:
Используется glsl
Shader "Animation/Grass" {
Properties {
_Color ("Main Color", Color) = (1,1,1,0.5)
_MainTex ("Texture", 2D) = "white" { }
_WaveAmplitude ("Wave Amplitude", Float) = 0.1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 50
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Cull Off
CGPROGRAM
#pragma exclude_renderers xbox360
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float _WaveAmplitude;
float4 _Color;
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
float4 _MainTex_ST;
v2f vert (appdata_base v)
{
float wind = _WaveAmplitude * sin( 1.57 *_Time.y + v.vertex.x);
v.vertex.x += wind * step(0.8, v.texcoord.y) * step(0.8, v.texcoord.x);
v.vertex.z -= wind * step(0.8, v.texcoord.y) * step(v.texcoord.x, 0.8);
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord;
return o;
}
half4 frag (v2f i) : COLOR
{
half4 texcol = tex2D (_MainTex, i.uv);
return texcol * _Color;
}
ENDCG
}
}
Fallback "VertexLit"
}
Properties {
_Color ("Main Color", Color) = (1,1,1,0.5)
_MainTex ("Texture", 2D) = "white" { }
_WaveAmplitude ("Wave Amplitude", Float) = 0.1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 50
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Cull Off
CGPROGRAM
#pragma exclude_renderers xbox360
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float _WaveAmplitude;
float4 _Color;
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
float4 _MainTex_ST;
v2f vert (appdata_base v)
{
float wind = _WaveAmplitude * sin( 1.57 *_Time.y + v.vertex.x);
v.vertex.x += wind * step(0.8, v.texcoord.y) * step(0.8, v.texcoord.x);
v.vertex.z -= wind * step(0.8, v.texcoord.y) * step(v.texcoord.x, 0.8);
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord;
return o;
}
half4 frag (v2f i) : COLOR
{
half4 texcol = tex2D (_MainTex, i.uv);
return texcol * _Color;
}
ENDCG
}
}
Fallback "VertexLit"
}
Синтаксис:
Используется glsl
Shader "Shaderforterr" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Cutoff ("Cutoff", Range (0,0.1)) = .09
}
SubShader {
Pass {
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float3 color : COLOR0;
};
struct indata
{
float4 vertex;
float3 normal;
float4 texcoord;
float4 color;
};
v2f vert(indata v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_UV(0);
o.color = v.color;
return o;
}
half4 frag(v2f i) : COLOR
{
half4 color = tex2D(_MainTex, i.uv.xy);
return half4(i.color*tex2D(_MainTex, i.uv).rgb, 1-tex2D(_MainTex, i.uv.xy).a);
}
ENDCG
AlphaTest Less [_Cutoff]
}
}
}
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Cutoff ("Cutoff", Range (0,0.1)) = .09
}
SubShader {
Pass {
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float3 color : COLOR0;
};
struct indata
{
float4 vertex;
float3 normal;
float4 texcoord;
float4 color;
};
v2f vert(indata v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_UV(0);
o.color = v.color;
return o;
}
half4 frag(v2f i) : COLOR
{
half4 color = tex2D(_MainTex, i.uv.xy);
return half4(i.color*tex2D(_MainTex, i.uv).rgb, 1-tex2D(_MainTex, i.uv.xy).a);
}
ENDCG
AlphaTest Less [_Cutoff]
}
}
}