Unity Shaders and Effects Cookbook 4-1 4-2 静态立方体贴图的创建与使用

本文介绍了Unity中如何创建和使用静态立方体贴图(Cubemap),包括立方体贴图的概念,静态立方体贴图的特点,以及通过编写Unity编辑器插件生成Cubemap的过程。此外,还展示了在Shader中应用Cubemap进行反射效果的实现方法。
摘要由CSDN通过智能技术生成
               

开始学习第4章 - 着色器的反射

看完了1、2节,来记录一下。反射主要是利用了 Cubemap 立方体贴图。


认识Cubemap

立方体贴图,就如同名字所说,在一个立方体上有6张图,就这样认为吧。


假想一下 ,在一个艳丽的房间里,有一个表面是镜子的圆球,那这个圆球表面就反射了房间里面的所有东西,就是一个大号的凸镜。

这是到网上找得一张图,很直观的表达了我的意思……


注意标题中说的,静态立方体贴图,为什么叫静态,因为这一次使用的立方体贴图是提前生成好的图片,而不是动态生成的。

这又是什么意思呢?

就拿上面图片中的场景来说,如果是静态的立方体贴图,那么当这个球在移动的时候,球上面显示的东西是不会变动的。

现实生活中的话,球移动,球上面显示出来的内容应该也是要随之变动的。

那么这里使用静态立方体贴图呢,是先学习立方体贴图的知识,后面会学习动态立方体贴图的,在书上是 4.6 这一节。


创建Cubemap

首先来创建一个立方体贴图,在Assets 中右键新建一个 Cubemap。


搭建场景,添加一个Sphere 作为Camera 的容器。因为要借助 Camera 的 API 来生成Cubemap。

转自http://blog.csdn.net/huutu http://www.thisisgame.com.cn

下面是我搭建的场景。


下面编写一个Unity编辑器插件来生成CubeMap。

using UnityEngine;using System.Collections;using UnityEditor;pub
Book Description: Since their introduction to Unity, Shaders have been notoriously difficult to understand and implement in games: complex mathematics have always stood in the way of creating your own Shaders and attaining that level of realism you crave. With Shaders, you can transform your game into a highly polished, refined product with Unity’s post-processing effects. Unity Shaders and Effects Cookbook is the first of its kind to bring you the secrets of creating Shaders for Unity3D―guiding you through the process of understanding vectors, how lighting is constructed with them, and also how textures are used to create complex effects without the heavy math. We’ll start with essential lighting and finishing up by creating stunning screen Effects just like those in high quality 3D and mobile games. You’ll discover techniques including normal mapping, image-based lighting, and how to animate your models inside a Shader. We’ll explore the secrets behind some of the most powerful techniques, such as physically based rendering! With Unity Shaders and Effects Cookbook, what seems like a dark art today will be second nature by tomorrow. What You Will Learn Understand physically based rendering to fit the aesthetic of your game Enter the world of post-processing effects to make your game look visually stunning Add life to your materials, complementing Shader programming with interactive scripts Design efficient Shaders for mobile platforms without sacrificing their realism Use state-of-the-art techniques such as volumetric explosions and fur shading Build your knowledge by understanding how Shader models have evolved and how you can create your own Discover what goes into the structure of Shaders and why lighting works the way it does Master the math and algorithms behind the most used lighting models
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值