###### tags: `AirSim`
# 進度紀錄 (Unreal Engine 地圖)
- 12/13

- 明天一定
[water](https://www.youtube.com/watch?v=86pXo9-9axU)
人偶
- 有空一定
[Grass node](https://www.youtube.com/watch?v=G6pACRjxLzY)
參考 - [UE 4 Documentation](https://docs.unrealengine.com/4.27/en-US)
## Note
### Material
- 透過使用 Material Instance 可以不用進到 Material 就可以更改參數
- 快捷鍵
- ==1== 加上 ==LMB== 建立 constant node
- ==L== + ==LMB== 建立 Lerp node
在 A 與 B 之間以 Alpha 為比例做插值

- ==3== + ==LMB== 建立 constant3Vector node
可以使用純色
## Foliage
### With Grass node
在原有的 Landscape Material 中
- 建立 Grass node 及 LandscapeLayerSample node 並連接
LandscapeLayerSample node 中的參數名稱必須與在 Blend node 中的 texture 名稱相同
- 建立 Grass Type
透過 Add-New 選單,選擇 Foilage/Landscape Grass Type
#### 參考
- [UE4: Complete Guide to Spawning Foliage on Landscapes Using Grass Node Output](https://www.youtube.com/watch?v=G6pACRjxLzY)
### Foliage Tool
進入 Foliage Tool 面板,透過 ==Add Foliage Type== 選項選擇要使用的 Foliage Type
- 建立 Foliage Type
有兩種可以選擇,Actor Foliage 以及 Statice Mesh Foliage
沒有特別需求的話可以直接使用 Statice Mesh Foliage
- 跟 Landscape Tool 一樣有許多工具可以使用
#### 參考
- UE Documentation - https://docs.unrealengine.com/4.27/en-US/BuildingWorlds/Foliage/
## Texture
### Poliigon 材質
1. 匯入 Texture
- 在 UE Editor 中使用 Poliigon 的材質包時不需要 ==displacement map==
- 打開 ==gloss map==,取消勾選 ==sRGB== 選項

- 打開 ==normal map==,勾選 ==Flip Green channel==

2. 建立 Material
- 建立 Texture Sample 節點

在 Details 面板中,將 ==Texture== 改成匯入的 map
- oneminus 節點

透過這個節點將 ==reflect== 及 ==gloss== map 連到 ==specular== 以及 ==Roughness==
將 ==color== 及 ==normal== map 直接連到 ==Base color== 及 ==normal==

3. 編輯 Material
- 建立 TextureCoordinate 、 Multiply 以及 Scalar parameter 節點

- 將 TextureCoordinate 及 ScalarParameter 節點連上 Multiply 節點,並將 Multiply 節點連到全部的 TextureSample 節點上,並到 ScalarParameter 的 Details 面板中調整 ==Default Value== 為 1

- 使用 ScalarParameter 及 Multiply 節點的組合可以在 Material Editor 外來調整該參數


### 使用 DISP map
1. 透過 Multiply node 將 displacement map 及 scalarparameter node 連接,並接到 ==World Displacement== 接點
在 Details 面板中的 ==Tessellation== 選單中

- 選項 ==Tessellation Mode== 中選擇 ==flat==
- 調整 ==Max Displacement== 的值
2. 同樣使用 Multiply node 將 VertexNormalWS node 插入
3. 再使用一個 Multiply node 將 Object Radius node 接上

4. 建立一個 ScalarParameter node 來控制 ==Tessellation Multiplier==

- 效果

#### 參考
- Poliigon 使用 - https://www.youtube.com/watch?v=JicpNGYA4J0&t=63s
- 在 UE4 中使用 - https://www.youtube.com/watch?v=o0648Sfom8M
- 在 UE4 中使用 DISP map - https://www.youtube.com/watch?v=1GkS9-94k80
### Tiling
#### Material
- 將會用到的 Texture 拉近 Material Editor 中,產生 TextureSample,並透過 LandscapeLayerBlend node 將 TextureSample 連接到 BaseColor

- 將前面用到的 Texture 的 normal map 拉進 Editor 中,並用 LandscapeLayerCoords node 連接 normal 以及 color maps
- 同樣使用 LayerBlend node 將 TextureSample 連接到材料 node 的 Normal 選項

可以使用 constant node 來調整材料的其他性質

#### Assign Material
- 回到地圖中選取 Landscape, 在 Details 面板的 Landscape 選單中的 Landscape Materail 選取剛建立好的 Materail
- 產生 Layer info
進入 Landscape 模式,在 Paint 選單中的 Layers 中會有使用中的 Texture,選取 Texture 中的 ==+== 符號,選擇 ==Weight Blended Layer==

#### 參考
- [UE4: Step-by-Step to Your First Landscape Material for Beginners (Day 2/3: 3-Day Tutorial Series)](https://www.youtube.com/watch?v=cWOlIvq0Etg&t=2s)
## Auto Landscape
- Node
- WorldAligneBlend node
使用 constant node 來控制 ==Sharpness== 以及 ==Bias== 兩個參數,其中 ==Bias== 必須小於0

- 將 constant node 更改成 parameter,這樣可以在 Material Instance 中更改參數
- 將要用的 texture 的 Color 以及 Normal map 拉進 Editor 中並連接到 Lerp node 的 A 與 B inputs
- Lerp node Alpha input 使用 WorldAlignedBlend node 的 ==Vertex Normals== output
- 如果要使用 normal map 的話,會需要將 Color map 的 Lerp node Alpha input 換成 Vertex Normals
- 同樣可以將 TextureSample node 轉換成 parameter,這樣可以在 Material Instance 中更改要用的 Texture

### 參考
- [UE4: How to Create Your First Procedural Auto-Landscape Material Tutorial](https://www.youtube.com/watch?v=76M8Q2jXscM)
- [UE4: 9 Things Every Procedural Auto-Landscape Material Must Have Tutorial](https://www.youtube.com/watch?v=b4HTCo2fRAE)
## Water
1. 增加參數來控制 large wave
- 在 TexCoord node 中有 u 及 v 的速度,如果要分開控制的話可以透過 append node

記得要調整 default value
- 同上建立參數來控制 speed

2. Sine Control ...
- noise speed node 是用來調整前後的 wave 運動
- 控制 Large wave 的運動

- 控制 Absolute World Position node
這會讓 large wave 在遠處的表現得更好

3. Small Wave Control
與前面相同

4. Transition

- 前面完成後你應該會看到這些參數

透過調整這些參數可以將水面的波型調整到適當的外型

### 參考
- [UE4: How Make Water Material in “Starter Content” Work Without Stretching or Distortions - Tutorial](https://www.youtube.com/watch?v=86pXo9-9axU)
# To do (細節優化_寒假再說)
