首页 > 学院 > 开发设计 > 正文

Unity跑酷扭曲shader

2019-11-14 09:05:46
字体:
来源:转载
供稿:网友

1.这个是用来跑酷场景的跑道扭曲的效果。参数Offset不宜设置太高,因为扭曲太高了,它只是把显示图片给予矩阵旋转,但是三角形顶点还是摄像机外,所以使用的时候,会因为顶点不在摄像机里面而在跑酷过程突然给消失(摄像机裁剪)。 这里写图片描述

Shader "Customs/Curved" { PRoperties { _MainTex ("Base (RGB)", 2D) = "white" {} _QOffset ("Offset", Vector) = (11,-1,0,0) _Color ("Main Color", Color) = (1,1,1,1) _Brightness ("Brightness", Float) = 1.8 _Dist ("Distance", Float) = 100.0 _FogColor("FogColor", Color) = (0.87,0.87,0.87,1) _FogDensity("FogDensity", Float) = 0.1 _FogRange("FogRange", Float) = 300 _Cut("Cut", range(0,1)) = 0 } SubShader { Tags {"RenderType"="TransparentCutOut"} //blend srcalpha oneminussrcalpha Cull off zwrite on CGPROGRAM #pragma surface surf Lambert vertex:vert alphatest:_Cut struct Input { float2 uv_MainTex; }; sampler2D _MainTex; float4 _QOffset; float _Dist; float _Insensitive; float _Brightness; float4 _Color; void vert (inout appdata_full v) { float4 vPos = mul (UNITY_MATRIX_MV, v.vertex); float xsmeh=sin(_WorldSpaceCameraPos.z/120); float zOff = vPos.z/_Dist; vPos += _QOffset*zOff*zOff; v.vertex = mul(transpose(UNITY_MATRIX_IT_MV), vPos); #if SHADER_API_GLES v.vertex.xyz*= 1.0; #endif } void surf (Input IN, inout SurfaceOutput o) { o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * _Brightness * _Color; float alpha = tex2D (_MainTex, IN.uv_MainTex).a; o.Alpha = alpha; } ENDCG } Fallback "Diffuse"}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表