vault backup: 2024-06-21 12:45:12

This commit is contained in:
BlueRose 2024-06-21 12:45:12 +08:00
parent 55ee595157
commit c5d432a8f0
2 changed files with 115 additions and 2 deletions

View File

@ -0,0 +1,4 @@
## IdolAnimInstance
UpdateAnimation每帧执行PrepareMocapParameters()会获取TsMotionRetargetComponent的引用正常情况会获取IdolActor的Controller中的TsMotionRetargetComponent。
TsMotionRetargetComponent包含TsChingmuMocapReceiverActor => ChingmuMocapReceiverActor 。

View File

@ -38,12 +38,15 @@ static FToonShadingPerMaterialCustomData ToonShadingPerMaterialCustomData;
1. 实现[[#Encode/Decode函数]]
2. HasCustomGBufferData()函数添加对应的ToonShadingModel宏判断
3. [[#FGBufferData新增变量]]
4. 在Encode/Decode GBufferData中新增逻辑。
4. [[#Encode/Decode GBufferData新增逻辑]]
1. Metallic/Specualr/Roughness => ToonShadowLocation/ToonForceShadow/ToonShadowSmoothness
2. AO => ToonSecondaryShadowLocation
3. CustomData => ToonShadowColor/ToonSecondaryShadowSmoothness
4. PrecomputedShadowFactors => ToonSecondaryShadowColor
### 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)
{
@ -113,6 +116,112 @@ struct FGBufferData
half3 ToonCalcShadowColor;
};
```
### Encode/Decode GBufferData新增逻辑
```c++
void EncodeGBuffer(
FGBufferData GBuffer,
out float4 OutGBufferA,
out float4 OutGBufferB,
out float4 OutGBufferC,
out float4 OutGBufferD,
out float4 OutGBufferE,
out float4 OutGBufferVelocity,
float QuantizationBias = 0 // -0.5 to 0.5 random float. Used to bias quantization.
)
{
...
switch(GBuffer.ShadingModelID)
{
case SHADINGMODELID_TOON_BASE:
OutGBufferB.r = ToonShadingPerMaterialCustomData.ToonShadowLocation;
OutGBufferB.g = ToonShadingPerMaterialCustomData.ToonForceShadow;
OutGBufferB.b = ToonShadingPerMaterialCustomData.ToonShadowSmoothness;
OutGBufferC.a = ToonShadingPerMaterialCustomData.ToonSecondaryShadowLocation;
OutGBufferD.a = ToonShadingPerMaterialCustomData.ToonSecondaryShadowSmoothness;
OutGBufferD.rgb = ToonShadingPerMaterialCustomData.ToonShadowColor.rgb;
OutGBufferE.gba = ToonShadingPerMaterialCustomData.ToonSecondaryShadowColor.rgb;
break;
case SHADINGMODELID_TOON_PBR:
OutGBufferB.g = ToonShadingPerMaterialCustomData.ToonShadowLocation;
OutGBufferD.a = ToonShadingPerMaterialCustomData.ToonShadowSmoothness;
OutGBufferD.rgb = ToonShadingPerMaterialCustomData.ToonShadowColor.rgb;
OutGBufferE.gba = ToonShadingPerMaterialCustomData.ToonSpecularColor.rgb;
break;
case SHADINGMODELID_TOON_SKIN:
OutGBufferB.r = ToonShadingPerMaterialCustomData.ToonShadowLocation;
OutGBufferD.a = ToonShadingPerMaterialCustomData.ToonShadowSmoothness;
OutGBufferD.rgb = ToonShadingPerMaterialCustomData.ToonShadowColor.rgb;
break;
default:
break;
}
...
}
FGBufferData DecodeGBufferData(
float4 InGBufferA,
float4 InGBufferB,
float4 InGBufferC,
float4 InGBufferD,
float4 InGBufferE,
float4 InGBufferF,
float4 InGBufferVelocity,
float CustomNativeDepth,
uint CustomStencil,
float SceneDepth,
bool bGetNormalizedNormal,
bool bChecker)
{
FGBufferData GBuffer = (FGBufferData)0;
...
switch(GBuffer.ShadingModelID)
{
case SHADINGMODELID_TOON_BASE:
GBuffer.ToonShadowColor = InGBufferD.rgb;
GBuffer.ToonShadowLocation = InGBufferB.r;
GBuffer.ToonShadowSmoothness = InGBufferB.b;
GBuffer.ToonForceShadow = InGBufferB.g;
GBuffer.ToonSecondaryShadowColor = InGBufferE.gba;
GBuffer.ToonSecondaryShadowLocation = InGBufferC.a;
GBuffer.ToonSecondaryShadowSmoothness = InGBufferD.a;
GBuffer.Metallic = 0.0;
GBuffer.Specular = 1.0;
GBuffer.Roughness = 1.0;
GBuffer.GBufferAO = 0.0;
GBuffer.IndirectIrradiance = 1.0;
GBuffer.PrecomputedShadowFactors = !(GBuffer.SelectiveOutputMask & SKIP_PRECSHADOW_MASK) ? float4(InGBufferE.r, 1.0, 1.0, 1.0) : ((GBuffer.SelectiveOutputMask & ZERO_PRECSHADOW_MASK) ? 0 : 1);
GBuffer.StoredMetallic = 0.0;
GBuffer.StoredSpecular = 1.0;
break;
case SHADINGMODELID_TOON_PBR:
GBuffer.ToonSpecularColor = InGBufferE.gba;
GBuffer.ToonShadowColor = InGBufferD.rgb;
GBuffer.ToonShadowLocation = InGBufferB.g;
GBuffer.ToonShadowSmoothness = InGBufferD.a;
GBuffer.ToonSecondaryShadowColor = GBuffer.ToonShadowColor;
GBuffer.ToonForceShadow = 1.0;
GBuffer.ToonSpecularLocation = 1.0;
GBuffer.Specular = 1.0;
GBuffer.PrecomputedShadowFactors = !(GBuffer.SelectiveOutputMask & SKIP_PRECSHADOW_MASK) ? float4(InGBufferE.r, 1.0, 1.0, 1.0) : ((GBuffer.SelectiveOutputMask & ZERO_PRECSHADOW_MASK) ? 0 : 1);
break;
case SHADINGMODELID_TOON_SKIN:
GBuffer.ToonShadowColor = InGBufferD.rgb;
GBuffer.ToonShadowLocation = InGBufferB.r;
GBuffer.ToonShadowSmoothness = InGBufferD.a;
GBuffer.ToonSecondaryShadowColor = GBuffer.ToonShadowColor;
GBuffer.ToonForceShadow = 1.0;
GBuffer.Metallic = 0.0;
GBuffer.StoredMetallic = 0.0;
GBuffer.PrecomputedShadowFactors = !(GBuffer.SelectiveOutputMask & SKIP_PRECSHADOW_MASK) ? float4(InGBufferE.r, 1.0, 1.0, 1.0) : ((GBuffer.SelectiveOutputMask & ZERO_PRECSHADOW_MASK) ? 0 : 1);
break;
default:
break;
}
...
};
```
# BasePass
BasePassPixelShader.usf