纳金网
标题:
shader简单模拟流水效果
[打印本页]
作者:
烟雨
时间:
2016-5-30 01:19
标题:
shader简单模拟流水效果
Shader "czm/water"{
Properties{
_MainTex("MainTex",2D)="white"{}//
_NoiseTex("NoiseTex",2D)="white"{}//
_Size("NoiseSize",Range(0,1))=0.1
//
_Speed("WaterSpeed",Range(0,1))=1
_Scale("WaveScale",Range(0,2))=1
_Alpha("WaveAlpha", float)=1
_K("K",Range(0,1))=0.2
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend SrcAlpha One
Cull Off
Lighting Off
ZWrite Off
Pass {
Tags { "LightMode" = "Vertex" }
CGPROGRAM
#pragma vertex vertPart
#pragma fragment fragPart
#include "unitycg.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _NoiseTex;
float4 _NoiseTex_ST;
float _Size;
float _Speed;
float _Scale;
float _Alpha;
float _K;
struct vs {
float4 pos
OSITION;
float2 uv : TEXCOORD0;
float4 color : color;
};
vs vertPart (appdata_full v)
{
vs o;
o.pos = mul(UNITY_MATRIX_MVP,v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord,_MainTex);
o.color=v.color;
return o;
}
fixed4 fragPart(vs i) : COLOR {
float2 noiseUV=i.uv;
noiseUV+=_Time*_Speed;//流动速度
fixed2 noiseCol = tex2D(_NoiseTex,noiseUV);
fixed2 mainUV=i.uv;//主uv
mainUV+=noiseCol*_K*_Size*_Scale;
fixed4 mainCol = tex2D(_MainTex,mainUV);
return mainCol*i.color*fixed4(1,1,1,_Alpha);
}
ENDCG
}
}
FallBack "Diffuse"
}
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5