码迷,mamicode.com
首页 > 编程语言 > 详细

Unity Flow distort of screen

时间:2016-04-01 20:33:29      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:


Shader "ScreenWater" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Field ("Field Channel", 2D) = "black" {}
_Flow ("Flow", 2D) = "black" {}

}

SubShader {
Pass {
ZTest Always Cull Off ZWrite Off Fog { Mode off }

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"

struct v2f {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};

uniform sampler2D _MainTex;
sampler2D _Field;
sampler2D _Flow;
half _Speed;
half _Intens;

v2f vert (appdata_img v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = MultiplyUV (UNITY_MATRIX_TEXTURE0, v.texcoord);

return o;
}

half4 frag (v2f i) : COLOR
{

float t = _Time.x * _Speed;

float2 coor = i.uv ;

half4 flow = tex2D (_Flow,coor + t);

half4 fc = tex2D(_Field, i.uv) * flow;

half4 distort = fc * _Intens ;

return tex2D(_MainTex, i.uv + distort );
}

ENDCG
}
}

Fallback off

}

Unity Flow distort of screen

标签:

原文地址:http://www.cnblogs.com/bearworks/p/5346050.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!