From 55ee5951575514553db98ed598c0755006b24984 Mon Sep 17 00:00:00 2001
From: BlueRose <378100977@qq.com>
Date: Fri, 21 Jun 2024 11:07:35 +0800
Subject: [PATCH] vault backup: 2024-06-21 11:07:35

---
 .../various-complements/histories.json        |  2 +-
 02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md | 76 +++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletion(-)

diff --git a/.obsidian/plugins/various-complements/histories.json b/.obsidian/plugins/various-complements/histories.json
index 9f4dfe9..5d7c90a 100644
--- a/.obsidian/plugins/various-complements/histories.json
+++ b/.obsidian/plugins/various-complements/histories.json
@@ -1 +1 @@
-{"JNCustomAssetEd:定义修型资产":{"JNCustomAssetEd:定义修型资产":{"currentFile":{"count":1,"lastUpdated":1715827692229}}},"GreenScreen":{"GreenScreen":{"currentFile":{"count":1,"lastUpdated":1715843645080}}},"Character":{"Character":{"currentFile":{"count":1,"lastUpdated":1715848900346}}},"定义了·FGuid":{"定义了·FGuid":{"currentFile":{"count":1,"lastUpdated":1715915171873}}},"(例如Idol.BeiLa)。以及FollowingSocketName":{"(例如Idol.BeiLa)。以及FollowingSocketName":{"currentFile":{"count":1,"lastUpdated":1716192086731}}},"DirectorCamera为场景相关的相机(静态镜头)。":{"DirectorCamera为场景相关的相机(静态镜头)。":{"currentFile":{"count":1,"lastUpdated":1716192192053}}},"ECS资料":{"ECS资料":{"currentFile":{"count":1,"lastUpdated":1716465594941}}},"DebugView":{"DebugView":{"internalLink":{"count":1,"lastUpdated":1716796051996}}},".p4ignore":{".p4ignore":{"currentFile":{"count":1,"lastUpdated":1717048569032}}},"admin":{"admin":{"currentFile":{"count":1,"lastUpdated":1717123692206}}},"具体的命令应该说是":{"具体的命令应该说是":{"currentFile":{"count":1,"lastUpdated":1717749753511}}},"添加一个Idol.xxx标签。":{"添加一个Idol.xxx标签。":{"currentFile":{"count":2,"lastUpdated":1718092533903}}}}
\ No newline at end of file
+{"ECS资料":{"ECS资料":{"currentFile":{"count":1,"lastUpdated":1716465594941}}},"DebugView":{"DebugView":{"internalLink":{"count":1,"lastUpdated":1716796051996}}},".p4ignore":{".p4ignore":{"currentFile":{"count":1,"lastUpdated":1717048569032}}},"admin":{"admin":{"currentFile":{"count":1,"lastUpdated":1717123692206}}},"具体的命令应该说是":{"具体的命令应该说是":{"currentFile":{"count":1,"lastUpdated":1717749753511}}},"添加一个Idol.xxx标签。":{"添加一个Idol.xxx标签。":{"currentFile":{"count":2,"lastUpdated":1718092533903}}},"FGBufferData":{"FGBufferData":{"currentFile":{"count":1,"lastUpdated":1718936545718}}}}
\ No newline at end of file
diff --git a/02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md b/02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md
index 81b75e2..927b53f 100644
--- a/02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md
+++ b/02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md
@@ -35,8 +35,84 @@ static FToonShadingPerMaterialCustomData ToonShadingPerMaterialCustomData;
 
 
 ## DeferredShadingCommon.ush
+1. 实现[[#Encode/Decode函数]]
+2. HasCustomGBufferData()函数添加对应的ToonShadingModel宏判断
+3. [[#FGBufferData新增变量]]
+4. 在Encode/Decode GBufferData中新增逻辑。
 
+### Encode/Decode函数
+RGB655 to 8-bit RGB。
+将R 256 => 64 ,GB 256 => 32。之后使用2个8bit浮点来存储:通道1存储R与G的头两位;通道2存储G的后3位与B。
 
+```c++
+float2 EncodeColorToRGB655(float3 Color)  
+{  
+    const uint ChannelR = (1 << 6) - 1;  
+    const uint ChannelG = (1 << 5) - 1;  
+    const uint ChannelB = (1 << 5) - 1;  
+  
+    uint3 RoundedColor = uint3(float3(  
+       round(Color.r * ChannelR),  
+       round(Color.g * ChannelG),  
+       round(Color.b * ChannelB)  
+    ));  
+    return float2(  
+       (RoundedColor.r << 2 | RoundedColor.g >> 3) / 255.0,  
+       (RoundedColor.g << 5 | RoundedColor.b     ) / 255.0  
+    );  
+}  
+  
+float3 DecodeRGB655ToColor(float2 RGB655)  
+{  
+    const uint ChannelR = (1 << 6) - 1;  
+    const uint ChannelG = (1 << 5) - 1;  
+    const uint ChannelB = (1 << 5) - 1;  
+  
+    uint2 Inputs = uint2(round(RGB655 * 255.0));  
+    uint BitBuffer = (Inputs.x << 8) | Inputs.y;  
+    uint R = (BitBuffer & 0xFC00) >> 10;  
+    uint G = (BitBuffer & 0x03E0) >> 5;  
+    uint B = (BitBuffer & 0x001F);  
+  
+    return float3(R, G, B) * float3(1.0 / ChannelR, 1.0 / ChannelG, 1.0 / ChannelB);  
+}
+```
+
+### FGBufferData新增变量
+```c++
+struct FGBufferData  
+{
+...
+	// Toon specular  
+	// 0..1, specular color  
+	half3 ToonSpecularColor;  
+	// 0..1, specular edge position  
+	half ToonSpecularLocation;  
+	// 0..1, specular edge smoothness  
+	half ToonSpecularSmoothness;  
+	  
+	// Toon shadow  
+	// 0..1, shadow color  
+	half3 ToonShadowColor;  
+	// 0..1, shadow egde location  
+	half ToonShadowLocation;  
+	// 0..1, shadow edge smoothness  
+	half ToonShadowSmoothness;  
+	// 0..1, force shadow  
+	half ToonForceShadow;  
+	  
+	// Toon secondary shadow  
+	// 0..1, secondary shadow color  
+	float3 ToonSecondaryShadowColor;  
+	// 0..1, secondary shadow edge location  
+	float ToonSecondaryShadowLocation;  
+	// 0..1, secondary shadow edge smoothness  
+	float ToonSecondaryShadowSmoothness;  
+	  
+	// Toon render  
+	half3 ToonCalcShadowColor;
+};
+```
 # BasePass
 BasePassPixelShader.usf