
雾特效
2.进行雾化的基本设置 选择Window->Lighting->Setting->other Setting,在下拉菜单中勾选fog
建立脚本命名为Pop
通过点击按钮选择不同的雾化状态。
发布日期:2021-05-07 17:59:05
浏览次数:29
分类:精选文章
本文共 3468 字,大约阅读时间需要 11 分钟。
雾化效果的实现是通过已经生成的像素的颜色和像素到镜头的距离来确定一个常量色来实现的,使用雾化i更不会改变已经混合的像素的透明度值,只是改变了RGB的值。
Demo:
通过玩家选择雾的模型来修改雾的形态,雾共有三种形式,分别为指数、指数平方、线性三种由远及近的更换模式,本Demo就是通过修改雾的模式来观测者三者的不同, 1.步骤: 搭建环境、灯光、模型摆放等如图

using System.Collections;using System.Collections.Generic;using UnityEngine;public class Pop : MonoBehaviour{ private float ypos1 = 0.0f;//声明边框一的位置 private float ypos2 = 0.0f;//生命边框二的位置 private float ypos3 = 0.0f;//声明边框三的位置 private float ypos4 = 0.0f;//声明边框四的位置 private bool isshowDropdownButton;//声明默认下拉按钮值 private bool isshowDropupButton;//声明回弹按钮值 public float speed = 500.0f;//声明弹出弹回速度 private string St = "FogMode"; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if(isshowDropdownButton == true) { ypos1 += Time.deltaTime * speed; ypos2 += Time.deltaTime * speed; ypos3 += Time.deltaTime * speed; ypos4 += Time.deltaTime * speed; if(ypos1>=60) { ypos1 = 60; } if(ypos2>=120) { ypos2 = 120; } if(ypos3>=180) { ypos3 = 180; } if(ypos4 >= 240) { ypos4 = 240; } if(isshowDropupButton == true) { ypos1 -= Time.deltaTime * speed; ypos2 -= Time.deltaTime * speed; ypos3 -= Time.deltaTime * speed; ypos4 -= Time.deltaTime * speed; if(ypos1>=0||ypos2>=0||ypos3>=0||ypos4>=0) { isshowDropupButton = false; isshowDropdownButton = false; ypos1 = 0; ypos2 = 0; ypos3 = 0; ypos4 = 0; } } } } private void OnGUI() { if(isshowDropdownButton == false) { if(GUI.RepeatButton(new Rect(50,0,200,60),St)) { isshowDropdownButton = true; } } if(isshowDropdownButton == true) { if(GUI.Button(new Rect(50,0,200,60),St)) { isshowDropdownButton = false; isshowDropupButton = true; } if(GUI.Button(new Rect(50,ypos1,200,60),"Linear")) { isshowDropupButton = true; isshowDropdownButton = false; RenderSettings.fogMode = FogMode.Linear; } if(GUI.Button(new Rect(50,ypos2,200,60),"Exp2")) { isshowDropupButton = true; isshowDropdownButton = false; RenderSettings.fogMode = FogMode.ExponentialSquared; } if(GUI.Button(new Rect(50,ypos3,200,60),"Exp")) { isshowDropupButton = true; isshowDropdownButton = false; RenderSettings.fogMode = FogMode.Exponential; } if(GUI.Button(new Rect(50,ypos4,200,60),"None")) { isshowDropupButton = true; isshowDropdownButton = false; RenderSettings.fogMode = 0;//无雾模式 St = "FogMode"; } } }}
实现效果如下

发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2025年03月20日 16时04分40秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
不可思议的纯 CSS 滚动进度条效果
2021-05-09
【CSS进阶】伪元素的妙用--单标签之美
2021-05-09
惊闻NBC在奥运后放弃使用Silverlight
2021-05-09
IE下尚未实现错误的原因
2021-05-09
创建自己的Docker基础镜像
2021-05-09
HTTP 协议图解
2021-05-09
Python 简明教程 --- 20,Python 类中的属性与方法
2021-05-09
KNN 算法-理论篇-如何给电影进行分类
2021-05-09
Spring Cloud第九篇 | 分布式服务跟踪Sleuth
2021-05-09
CODING 敏捷实战系列课第三讲:可视化业务分析
2021-05-09
使用 CODING DevOps 全自动部署 Hexo 到 K8S 集群
2021-05-09
工作动态尽在掌握 - 使用 CODING 度量团队效能
2021-05-09
CODING DevOps 深度解析系列第二课报名倒计时!
2021-05-09
CODING DevOps 线下沙龙回顾二:SDK 测试最佳实践
2021-05-09
数据结构第八节(图(下))
2021-05-09
基于Mustache实现sql拼接
2021-05-09
POJ 2260 Error Correction 模拟 贪心 简单题
2021-05-09
CSUOJ Water Drinking
2021-05-09
Spring MVC+javamail实现邮件发送
2021-05-09
gRPC在 ASP.NET Core 中应用学习(一)
2021-05-09