1. Code
Shader"Aaaa/heatisland"{Properties {_maintex ("Base (RGB)", 2D) =" White"{} _offsettex ("Shui (RGB)", 2D) =" White"{} _cliptex ("Clip (RGB)", 2D) =" White"{} _speed ("Speed", Range (2, A))= A_range ("Range", Range (0, -))=Ten}subshader {Pass {ZTest always cull off zwrite off Fog {Mode Off} cgprogram#pragmaVertex vert#pragmaFragment Frag#pragmaFragmentoption Arb_precision_hint_fastest#include"Unitycg.cginc"uniform sampler2d _maintex;uniform sampler2d _offsettex;uniformfloat_speed;uniformfloat_range;structv2f {float4 pos:position; Float2 uv:texcoord0;}; v2f Vert (appdata_img v) {v2f o; O.pos=Mul (UNITY_MATRIX_MVP, V.vertex); O.uv=V.texcoord; returno;} FLOAT4 Frag (v2f i): color{float2 offset=I.uv; //the UV of the noise graph moves downward over timeFloat2 Offsetuv=float2 (i.uv.x,i.uv.y-_time.x*_speed); //calculates the color that corresponds to the next-moved UVFLOAT4 Shuicolor =tex2d (_offsettex, OFFSETUV); //offset the UV of the MaintexOFFSETUV = offset + shuicolor.xy/_range; returntex2d (_maintex, OFFSETUV);} ENDCG}}fallback off}
2. Effects
3. Note
The essence of distortion is the UV offset, and the cheap information is written in a noise figure.
[Xiao Ming learns shader]14. Heat distortion effect