---
title: "CubeMap & Skybox"
author: "Perrin Yong"
author_profile: https://www.pystone.net/profile/
published_by: "Perrin Yong"
canonical: https://www.pystone.net/notes/unity-cubemap-skybox/
type: note
content_role: unspecified
visibility: public
id_stability: rename-stable
source_path: "10-计算机、信息技术与工程/05-游戏图形与运行时/Unity/CubeMap & Skybox.md"
content_hash: b1e8a476677bc60d460a11bea1b5ae1a79bb3da97b4d528a3a65c23339a33f73
knowledge_version: 224c990773de.5fa8af6e39fa
site_commit: 224c990773de166d23a886306577dd90379529ce
notes_commit: 5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a
---
# CubeMap & Skybox

> 创建时间：2021/3/8 11:46

## Cubemap

A Cubemap is a collection of **six square textures** that represent the reflections on an environment. The six squares form the faces of an imaginary cube that surrounds an object; each face represents the view along the directions of the world axes (up, down, left, right, forward and back).

可以使用方向向量对它们索引和采样

```csharp
string s1 = &quot;Hello &quot;;
string s2 = s1;
s1 += &quot;World&quot;;

System.Console.WriteLine(s2);
//Output: Hello

```

## 制作方法

### Legacy Cubemap Assets

![Alt text](/media/93c73dc963da3750c3b8.png)

### Cubemap texture

![Alt text](/media/f30a67ccfeefd8c1b07f.png)

### PanoramaToCubemap

![Alt text](/media/86959cb28357d4db7766.png)

### Shader实现

使用Texture2D格式，在Shader当中组织，而不使用Unity的Cubemap格式。

![Alt text](/media/10cac10e5d5fb54504cc.png)

## Skybox的实现

### 使用Cubemap

制作Cubemap资源 。Buitin Shader当中的Skybox/Cubemap可以对Cubemap采样

![Alt text](/media/e27fff68512cf4e3d741.png)

### 在Shader中对6张图采样

Builtin Shader: Mobile-Skybox

![Alt text](/media/a6864d9b103b55495608.png)

### Panorama(全景画)

Builtin Shader: Skybox/Panoramic
可以直接Texture2D格式的对全景图进行采样。

## Ref

<https://blog.csdn.net/v_xchen_v/article/details/79474193>
