[小明学Shader]14.热扭曲效果
生活随笔
收集整理的這篇文章主要介紹了
[小明学Shader]14.热扭曲效果
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.代碼
Shader "AAAA/HeatIsland" { Properties {_MainTex ("Base (RGB)", 2D) = "white" {}_OffsetTex ("Shui (RGB)", 2D) = "white" {}_ClipTex ("Clip (RGB)", 2D) = "white" {}_Speed("速度",range(2,12))=12_Range("range",range(0,20))=10 }SubShader {Pass {ZTest Always Cull Off ZWrite OffFog { Mode off }CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma fragmentoption ARB_precision_hint_fastest #include "UnityCG.cginc"uniform sampler2D _MainTex; uniform sampler2D _OffsetTex; uniform float _Speed; uniform float _Range;struct v2f {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;return o; }float4 frag (v2f i) : COLOR{float2 offset = i.uv;//噪聲圖的uv隨著時(shí)間增長一直向下移動(dòng)float2 offsetUV=float2(i.uv.x,i.uv.y-_Time.x*_Speed);//計(jì)算下移后的uv所對(duì)應(yīng)的colorfloat4 shuiColor = tex2D(_OffsetTex, offsetUV);//將MainTex的uv進(jìn)行偏移offsetUV = offset + shuiColor.xy/_Range;return tex2D(_MainTex, offsetUV); } ENDCG} }Fallback off}2.效果
3.注意?
扭曲的本質(zhì)是UV偏移,便宜信息寫在一張?jiān)肼晥D里而已.
轉(zhuǎn)載于:https://www.cnblogs.com/WongSiuming/p/5128811.html
總結(jié)
以上是生活随笔為你收集整理的[小明学Shader]14.热扭曲效果的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 互动网站建设公司设计的网站有哪些特色
- 下一篇: 拼图游戏【简单】