可以使3D物体通过顶点变形弯曲,常见于跑酷游戏的跑道。可向左、右、上、下弯曲。

Shader "Custom/VertexColorCurved" {
Properties {
// Shader需要的6个参数
_MainTex ("Base (RGB)", 2D) = "white" {}
_QOffset ("Offset", Vector) = (,,,)
_Dist ("Distance", Float) = 100.0 _BrightnessAmount ("Brightness Amount", Float) = 1.0
_SaturationAmount ("Saturation Amount", Float) = 1.0
_ContrastAmount ("Contrast Amount", Float) = 1.0
} SubShader {
Tags { "Queue" = "Transparent"}
Pass
{ Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc" sampler2D _MainTex; float4 _QOffset;
float _Dist; fixed _BrightnessAmount;
fixed _SaturationAmount;
fixed _ContrastAmount;
float _OpacityAmount; struct v2f {
float4 pos : SV_POSITION;
float4 uv : TEXCOORD0;
float3 viewDir : TEXCOORD1;
fixed4 color : COLOR;
}; v2f vert (appdata_full v)
{
v2f o; float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
float zOff = vPos.z/_Dist;
vPos += _QOffset*zOff*zOff;
o.pos = mul (UNITY_MATRIX_P, vPos);
o.uv = v.texcoord;            //o.color.rgb = v.color.rgb; // 取顶点色 return o;
} float3 ContrastSaturationBrightness (float3 color, float brt, float sat, float con) {
// Increase or decrease these values to
// adjust r, g and b color channels separately
float avgLumR = 0.5;
float avgLumG = 0.5;
float avgLumB = 0.5; // Luminance coefficients for getting luminance from the image
float3 LuminanceCoeff = float3 (0.2125, 0.7154, 0.0721); // Operation for brightmess
float3 avgLumin = float3 (avgLumR, avgLumG, avgLumB);
float3 brtColor = color * brt;
float intensityf = dot (brtColor, LuminanceCoeff);
float3 intensity = float3 (intensityf, intensityf, intensityf); // Operation for saturation
float3 satColor = lerp (intensity, brtColor, sat); // Operation for contrast
float3 conColor = lerp (avgLumin, satColor, con); return conColor;
} half4 frag (v2f i) : COLOR0
{
fixed4 renderTex = tex2D(_MainTex, i.uv); // // Apply vertex color
// renderTex.rgb *= i.color.rgb; // 顶点色和贴图混合 // Apply the brightness, saturation, contrast operations
renderTex.rgb = ContrastSaturationBrightness (renderTex.rgb, _BrightnessAmount, _SaturationAmount, _ContrastAmount); return renderTex;
} ENDCG
}
} FallBack "Diffuse"
}

最新文章

  1. mvc学习中的问题汇总
  2. CentOS6.3 编译安装LAMP(3):编译安装 MySQL5.5.25
  3. 快速入门系列--WCF--06并发限流、可靠会话和队列服务
  4. C# 调用一个按钮的Click事件(利用反射)
  5. NGUI图片闪光
  6. jQuery使用之(三)处理页面的元素
  7. 面向对象之abstract
  8. [Irving]WPF Invalid character in the given encoding. Line xx, position xx.' XML is not valid.
  9. Using Sessions and Session Persistence---reference
  10. Linux内核之mmc子系统-sdio
  11. JNI 详细使用步骤 上手示例
  12. C++多态性中基类析构函数声明为虚函数
  13. TSC打印机使用教程终极版
  14. jsp3
  15. AITP
  16. FFmpeg编解码处理1-转码全流程简介
  17. 高能天气——团队Scrum冲刺阶段-Day 6
  18. clearfix 兼容IE6/IE7,解决ie6/ie7下多出一行的问题,bootstrap的clearfix的bug
  19. JAVA基础知识点转载
  20. 【TCP/IP详解 卷一:协议】第二十二章 TCP的坚持定时器

热门文章

  1. 文件属性之setuid位
  2. Bzoj2434 [Noi2011]阿狸的打字机
  3. Bzoj2756 [SCOI2012]奇怪的游戏
  4. Subime学习记录
  5. [JavaEE] NIO与IO的区别
  6. bootstrap学习总结-01 环境准备
  7. Microsoft SQL Server Management Studio ------------------------------ 附加数据库 对于 服务器
  8. springmvc 注解 配置文件解释
  9. mysql查询区分大小写
  10. HTML 个人资料框