[Xiao Ming learns shader]14. Heat distortion effect

Source: Internet
Author: User
Tags ming

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.