Unity混合天空盒
对于不同天气下天空盒的实现。
天空盒时通过天空盒材质更改实现的,新建材质,选择shader/skybox/6sided,然后添加六个天空盒贴图就可以实现天空盒,如果想实现天气变化则需要至少两套贴图,并需要实现渐变。此时需要新建着色器shader。Create/shader/unityshader然后双击新建的shader,添加如下代码,然后将此shader添加到相应材质上,就会看到相应材质有12个贴图槽,即两套天空盒贴图,拖入相应的贴图,通过材质的setfloat方法控制参数_Blend的值即可实现渐变,如第二段代码所示,也可加入灯光强度的设置,以达到相关效果。
Shader "Skybox/Blended" {
Properties{
_Tint("Tint Color", Color) = (., ., ., .)
_Blend("Blend", Range(0.0,1.0)) = 0.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" {}
}
SubShader{
Tags{ "Queue" = "Background" }
Cull Off
Fog{ Mode Off }
Lighting Off
Color[_Tint]
Pass{
SetTexture[_FrontTex]{ combine texture }
SetTexture[_FrontTex2]{ constantColor(,,,[_Blend]) combine texture lerp(constant) previous }
}
Pass{
SetTexture[_BackTex]{ combine texture }
SetTexture[_BackTex2]{ constantColor(,,,[_Blend]) combine texture lerp(constant) previous }
}
Pass{
SetTexture[_LeftTex]{ combine texture }
SetTexture[_LeftTex2]{ constantColor(,,,[_Blend]) combine texture lerp(constant) previous }
}
Pass{
SetTexture[_RightTex]{ combine texture }
SetTexture[_RightTex2]{ constantColor(,,,[_Blend]) combine texture lerp(constant) previous }
}
Pass{
SetTexture[_UpTex]{ combine texture }
SetTexture[_UpTex2]{ constantColor(,,,[_Blend]) combine texture lerp(constant) previous }
}
Pass{
SetTexture[_DownTex]{ combine texture }
SetTexture[_DownTex2]{ constantColor(,,,[_Blend]) combine texture lerp(constant) previous }
}
}
Fallback "Skybox/6 Sided",
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine; public class SetWeather : MonoBehaviour { public Material sky;
public Light sun; private float cloudValue = 0f;
private float sunIntensity; private void SetOvercast(float value)
{
sky.SetFloat("_Blend", value);
// sun.intensity = sunIntensity - (sunIntensity * value);
}
// Use this for initialization
void Start () {
sunIntensity = sun.intensity;
} // Update is called once per frame
void Update () {
SetOvercast(cloudValue);
cloudValue += 0.005f;
}
}
Unity混合天空盒的更多相关文章
- Android和Unity混合开发——解决方案
按这篇文章来做 http://blog.csdn.net/a369414641/article/details/53436477 要注意的地方 1.app是Android Libray,否则无法打包出 ...
- unity skybox天空盒分享无需下载
大概有几十种还是100种,具体忘了 反正很多就是了(哈哈哈哈哈!!!!!!!!!!!!) 老铁们, 多谢支持,谢谢大家. 根据需要使用,下面会分享出下载链接: 链接:https://pan.baidu ...
- 【Unity】打包安卓APK常见问题
问题:unity error invalid command android 原因:Android版本较新,Unity版本太旧(如4.X),Unity打包APK时调用Android工具使用的命令已被安 ...
- Unity3D脚本中文系列教程(十)
http://dong2008hong.blog.163.com/blog/static/4696882720140312627682/?suggestedreading&wumii Unit ...
- Unity3D脚本学习——运行时类
AssetBundle 类,继承自Object.AssetBundles让你通过WWW类流式加载额外的资源并在运行时实例化它们.AssetBundles通过BuildPipeline.BuildAss ...
- 美轮美奂宇宙星空制作神器Spacescape
本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/46444569 作者:car ...
- unity4.3.4firedrillonline项目首次整合问题总结
零.资源导入后把所有资源模型拖到场景中去,并reset Transform,使场景展现原有样子. 一.资源导入之后发现项目场景是黑的,添加灯光之后场景中大部分仍然是黑的(并没有光照的效果) 可能原因: ...
- Unity iOS混合开发界面切换思路
Unity iOS混合开发界面切换思路 最近有很多博友QQ 私信 或则 留言联系我,请教iOS和Unity界面之前相互切换的问题,源代码就不私下发你们了,界面跳转功能的代码我直接贴到下面好了,顺带说i ...
- 解读Unity中的CG编写Shader系列七(不透明度与混合)
转自http://www.itnose.net/detail/6098539.html 1.不透明度 当我们要将两个半透的纹理贴图到一个材质球上的时候就遇到混合的问题,由于前面的知识我们已经知道了片段 ...
随机推荐
- 整理总结 python 中时间日期类数据处理与类型转换(含 pandas)
我自学 python 编程并付诸实战,迄今三个月. pandas可能是我最高频使用的库,基于它的易学.实用,我也非常建议朋友们去尝试它.--尤其当你本身不是程序员,但多少跟表格或数据打点交道时,pan ...
- centos7下mongoDB安装和配置
2018-10-31更新 yum –y install mongodb-org 找不到这个包,清华源: https://mirrors.tuna.tsinghua.edu.cn/help/mongod ...
- CDH集群的配置优化须知
通过改善IFile阅读器的性能 IFile Reader,进而可改善随机处理程序并减少储备空间,达到MapReduce的配置最佳实践要求.而MapReduce shuffle的处理程序和 ...
- laravel基础操作手册
laravel基础操作手册 1.路由配置 测试配置路由: Route::get('/test', 'TestController@index'); 2.控制器书写 3.模型文件 4.增加扩展类文件 L ...
- Web高性能动画及渲染原理(1)CSS动画和JS动画
目录 一. CSS动画 和 JS动画 1.1 CSS动画 1.2 JS动画 1.3 小结 二. 使用Velocity.js实现动画 示例代码托管在:http://www.github.com/dash ...
- 02-16 k近邻算法
目录 k近邻算法 一.k近邻算法学习目标 二.k近邻算法引入 三.k近邻算法详解 3.1 k近邻算法三要素 3.1.1 k值的选择 3.1.2 最近邻算法 3.1.3 距离度量的方式 3.1.4 分类 ...
- github代码仓库提示:“We found a potential security vulnerability in one of your dependencies”
问题描述: Github上传代码后出现这样的错误: We found a potential security vulnerability in one of your dependencies. A ...
- 破阵九解:Node和浏览器之事件循环/任务队列/异步顺序/数据结构
前言 本文内容比较长,请见谅.如有评议,还请评论区指点,谢谢大家! >> 目录 开门见山:Node和浏览器的异步执行顺序问题 两种环境下的宏任务和微任务(macrotask &&a ...
- Python 之Re模块(正则表达式)
一.简介 正则表达式本身是一种小型的.高度专业化的编程语言,而在python中,通过内嵌集成re模块,程序媛们可以直接调用来实现正则匹配. 二.正则表达式中常用的字符含义 1.普通字符和11个元字符: ...
- [CF722C] Destroying Array
C. Destroying Array time limit per test 1 second memory limit per test 256 megabytes input standard ...