通过顶点颜色,制作高级贴图混合效果····
2015-08-11 23:09
363 查看
这个技术在神秘海域和战争机器流行起来···
<img src="http://img.blog.csdn.net/20150811231022590?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
两个贴图融合的非常好···
Shader "Custom/7.4" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _SecondaryTex("Secondary Texture",2D) = "white"{} _HeightMap("HeightMap",2D) = "white"{} _Value("Value",Range(1,20))= 3 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert vertex:vert sampler2D _MainTex; sampler2D _SecondaryTex; sampler2D _HeightMap; float _Value; struct Input { float2 uv_MainTex; float2 uv_SecondaryTex; float3 vertColor; }; void vert(inout appdata_full v,out Input o) { UNITY_INITIALIZE_OUTPUT(Input,o); o.vertColor = v.color.rgb; } void surf (Input IN, inout SurfaceOutput o) { half4 base = tex2D (_MainTex, IN.uv_MainTex); half4 secondTex=tex2D(_SecondaryTex,IN.uv_SecondaryTex); float4 height = tex2D(_HeightMap,IN.uv_MainTex); float redChannel = 1-IN.vertColor.r;//红色通道- - 红色越低就越高,越高就越低 float rHeight = height.r * redChannel; float invertHeight = 1-height.r; float finalHeight = (invertHeight * redChannel)*4; float finalBlend = saturate(rHeight + finalHeight); float hardness = ((1-IN.vertColor.g) * _Value) + 1; finalBlend = pow(finalBlend,hardness); float3 finalColor = lerp(base,secondTex,finalBlend); o.Albedo = finalColor; o.Alpha = base.a; } ENDCG } FallBack "Diffuse" }
相关文章推荐
- HDU 1863 畅通工程
- 用条件变量来解决生产者消费者问题
- scala的list源码解密
- jQuery版感应鼠标显示隐藏的菜单
- Linux学习笔记:常用命令总结
- Android解惑 - 为什么要用Fragment.setArguments(Bundle bundle)来传递参数(转)
- eclipse启动Tomcat服务输入http://localhost:8080/报404解决方法
- 简单的学生类
- 网址保存
- 【LeetCode】169 - Majority Element
- 使用U盘安装Centos 6.5操作系统,磁盘分区过程中出现,"sda必须有一个gpt磁盘标签"
- 1045 access denied for user 'root'@'localhost' using password yes
- hdu 2199 Can you solve this equation?
- OC第一节
- cocos ide 出现连接ide超时的原因和解决办法
- “rmdir: failed to remove ‘tmp’: Directory not empty”解决方案–Linux命令行如何删除非空文件夹
- css进阶学习
- 使用elasticsearch与kibana来分析nginx日志小结
- IOS中使用本地通知为你的APP添加提示用户功能
- arm汇编输出