博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
unity3D打造skybox淡入淡出 - 移动开发
阅读量:7053 次
发布时间:2019-06-28

本文共 3149 字,大约阅读时间需要 10 分钟。

原地址:http://www.it2down.com/it-mobile/426479.htm

 

当前位置:   »

unity3D打造skybox淡入淡出 - 移动开发

www.it2down.com   发布于:2013-6-18 21:54:54   
unity3D制作skybox淡入淡出
首先建立个shader
Shader "Custom/Skybox" {Properties {    _Tint ("Tint Color", Color) = (.5, .5, .5, .5)    _FrontTex ("Front (+Z)", 2D) = "white" {}    _BackTex ("Back (-Z)", 2D) = "white" {}    _LeftTex ("Left (+X)", 2D) = "white" {}    _RightTex ("Right (-X)", 2D) = "white" {}    _UpTex ("Up (+Y)", 2D) = "white" {}    _DownTex ("Down (-Y)", 2D) = "white" {}    _FrontTex2("2 Front (+Z)", 2D) = "white" {}    _BackTex2("2 Back (-Z)", 2D) = "white" {}    _LeftTex2("2 Left (+X)", 2D) = "white" {}    _RightTex2("2 Right (-X)", 2D) = "white" {}    _UpTex2("2 Up (+Y)", 2D) = "white" {}    _DownTex2("2 Down (-Y)", 2D) = "white" {}    _Color ("Fade (use alpha)", Color) = (1,1,1,1)}SubShader {    Tags { "Queue" = "Background" }    Cull Off    ZWrite On    ZTest Always    Fog { Mode Off }    Lighting Off           Color [_Tint]    Pass {        SetTexture [_FrontTex] { combine texture }        SetTexture[_FrontTex2] {             constantColor [_Color]            combine texture lerp (constant) previous        }    }    Pass {        SetTexture [_BackTex] { combine texture }        SetTexture[_BackTex2] {             constantColor [_Color]            combine texture lerp (constant) previous        }    }    Pass {        SetTexture [_LeftTex] { combine texture }        SetTexture[_LeftTex2] {             constantColor [_Color]            combine texture lerp (constant) previous        }    }    Pass {        SetTexture [_RightTex] { combine texture }        SetTexture[_RightTex2] {             constantColor [_Color]            combine texture lerp (constant) previous        }    }    Pass {        SetTexture [_UpTex] { combine texture }        SetTexture[_UpTex2] {             constantColor [_Color]            combine texture lerp (constant) previous        }    }    Pass {        SetTexture [_DownTex] { combine texture }        SetTexture[_DownTex2] {             constantColor [_Color]            combine texture lerp (constant) previous        }    }}Fallback "RenderFX/Skybox", 1}
材质间的动画转换
private var thisMaterial : Material;private var fadeSpeed : float = 0.4;function Start (){    thisMaterial = RenderSettings.skybox;    thisMaterial.color.a = 0.0;}function Update () {    thisMaterial.color.a += (fadeSpeed * Time.deltaTime);     thisMaterial.color.a = Mathf.Clamp(thisMaterial.color.a, 0.0, 1.0);}
skybox的纹理褪色,渐渐的转变。
public var blackTexture : Texture2D;function Start (){    thisMaterial = RenderSettings.skybox;    thisMaterial.color.a = 0.0;    thisMaterial.SetTexture("_FrontTex", blackTexture);    thisMaterial.SetTexture("_BackTex", blackTexture);    thisMaterial.SetTexture("_LeftTex", blackTexture);    thisMaterial.SetTexture("_RightTex", blackTexture);    thisMaterial.SetTexture("_UpTex", blackTexture);    thisMaterial.SetTexture("_DownTex", blackTexture);}function Update () {    thisMaterial.color.a += (fadeSpeed * Time.deltaTime);     thisMaterial.color.a = Mathf.Clamp(thisMaterial.color.a, 0.0, 1.0);}
设置纹理等
thisMaterial.SetTexture("_FrontTex2", textureVariable);

转载地址:http://lhsol.baihongyu.com/

你可能感兴趣的文章
脑洞大开!网易推出国内首部VR漫画《地狱电梯》
查看>>
谷歌被法国数据保护监管机构开出5000万欧元罚单
查看>>
阿里Java研发工程师实习面经,附面试技巧
查看>>
主流区块链(公链)项目总结
查看>>
智能制造催促企业蜕变,关键的“人才”还需政企校的进一步联合
查看>>
你造吗?机器人都在排队买iPhone了
查看>>
Bootstrap学习笔记--图片,jumbotron,page-header,well,警告,按钮,Glyphicon组件,徽章,标签
查看>>
共建安全大生态——2016第十七届信息安全大会采风
查看>>
AR红包大战,抢的不是钱而是发展机会
查看>>
行业人士会聚柏林共话区块链应用与发展
查看>>
IBM陈黎明:“喧嚣”是你们的,而Watson的行业应用早已“照进现实”
查看>>
CacheCloud bug修复日志
查看>>
新零售周年考:创业者和投资人交出了怎样的答卷?
查看>>
JSP中HTTP状态码
查看>>
【转】A Beginner's Guide To Understanding Convolutional Neural Networks
查看>>
JSP发送电子邮件
查看>>
“水下机器人”族群开始壮大,却在集体纠结要不要后面的那根线
查看>>
【Troubleshooting Case】无法删除Exchange 数据库DB 排错?
查看>>
C++ 读写MySQL经典 (转载)
查看>>
向量运算
查看>>