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

当前位置: IT异常查询网 »

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);

unity3D打造skybox淡入淡出 - 移动开发的更多相关文章

  1. Unity3D特效-场景淡入淡出

    最近公司开始搞Unity3D..整个游戏..特效需求还是比较多的.关于UI部分的特效淡入淡出.看网上用的方法都是用个黑东东遮挡然后设置alpha这么搞....本大神感觉非常的low.而且很渣.故奋笔疾 ...

  2. Unity3D 4.61 实现淡入淡出的场景过渡方法。

    还在学习过程中,如果有大大看到请指点. orz原来官方就有了更好的处理方法的教程,具体查看下面视屏. [Unity官方实例教程 秘密行动] Unity官方教程<秘密行动>(五) 屏幕渐变效 ...

  3. moviepy音视频开发:audio_fadein、fadeout实现声音淡入淡出

    ☞ ░ 前往老猿Python博文目录 ░ 一.概述 为了支持一些常规的音频变换处理,moviepy提供了一系列常用的变换函数,开发者可以直接使用这些方法进行变换,这些函数都在moviepy.audio ...

  4. Android 四种简单的动画(淡入淡出、旋转、移动、缩放效果)

    最近在Android开发当中,用到的动画效果. public void onClick(View arg0) { // TODO 自动生成的方法存根 switch (arg0.getId()) { c ...

  5. 【jQuery】使用JQ来编写面板的淡入淡出效果

    本文与上一篇的<[jQuery]使用JQ来编写最主要的淡入淡出效果>(点击打开链接)为姊妹篇. 但上一篇仅仅是对文本的基本控制,本篇则是对面板元素进行控制. 尽管功能上很类似,可是所用到的 ...

  6. JS-运动基础——案例应用:淡入淡出效果

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. js+jq 淡入淡出轮播(点击+定时+鼠标进入移出事件)

    <!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title> ...

  8. JQuery效果-淡入淡出、滑动、动画

    一.JQuery Fading方法 JQuery 有四种fade方法 1.fadeIn() 淡入                       对应也有$(selector).fadeIn(speed, ...

  9. Android动画之淡入淡出

    为了更好的说明Android动画的淡入淡出效果,这里以一个场景为例: 界面上有两个View 控件,两个View交替显示,当一个View淡入显示,另一个View淡出不可见. 我们把当前要显示的View叫 ...

随机推荐

  1. 【C++】this指针

    来自:黄邦勇帅 this 指针是所有成员函数的隐含指针,每次调用成员函数时,this 指针就指向调用此函数的对象.可以在成员函数类 部使用显使用this 指针. 友元函数不是类的成员函数,所以友元函数 ...

  2. 《Java编程思想》笔记 第五章 初始化与清理

    1.构造器 因为创建一个类的对象构造器就会自动执行,故初始化某些东西特好 2.方法重载 方法名相同,参数列表不同. 2.1 区分重载方法 方法重载后区别不同方法的就是方法签名 -->参数类型和个 ...

  3. mvc路由问题

    概述 使用MVC Routing可以不必将URL映射到网站中特定文件.通过添加Routing规则,使URL能够安装指定的规则发送HTTP请求,这种方式能够简洁.方便.有效.快速的实现对指定页面的访问或 ...

  4. npm命令要记

    npm list - depth 0 查看依赖 cnpm install 安装 npm outdated 查看模块过时 npm cache clear

  5. (1) Flutter android studio安装

    Flutter由两部分组成 Flutter引擎和Flutter框架 Flutter引擎由C++编写,在android上通过NDK编译,在ios上通过llvm编译 Flutter框架由dart编写 1. ...

  6. HDU 1013 Digital Roots(字符串,大数,九余数定理)

    Digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  7. 递归输入与引用传值(UVa839 Not so Mobile)

    题目的大意是一个树形天平,输入给出样例的个数,然后空一行,每行4个数W1,D1,W2,D2,分别代表天平左侧的重量.力臂和天平右侧的重量.力臂.如果W1或者W2为0,则代表该节点有左子树或右子树,如果 ...

  8. python3 while循环及for循环

    yueer = 18 count = 0 while count < 3: yueerage = int(input('悦儿多大呢:')) if yueerage == yueer: print ...

  9. spoj - Longest Common Substring(后缀自动机模板题)

    Longest Common Substring 题意 求两个串的最长公共子串. 分析 第一个串建后缀自动机,第二个串在自动机上跑,对于自动机上的结点(状态)而言,它所代表的最大长度为根结点到当前结点 ...

  10. Dfs【p4906】小奔关闹钟

    Background 由于今天是星期一,闹钟准时响了,由于小奔太困了,所以她想关停闹钟. Description 可是,他的闹钟电路太复杂了,有很多个开关,每个开关都连着其他开关,其他开关又连着更多的 ...