From 6ddb534e379f0eb36bfc932e7f5b566617a912f0 Mon Sep 17 00:00:00 2001 From: BlueRose <378100977@qq.com> Date: Fri, 21 Jun 2024 17:58:39 +0800 Subject: [PATCH] vault backup: 2024-06-21 17:58:39 --- 02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md b/02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md index 0e72743..4bfce92 100644 --- a/02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md +++ b/02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md @@ -43,6 +43,8 @@ static FToonShadingPerMaterialCustomData ToonShadingPerMaterialCustomData; 2. AO => ToonSecondaryShadowLocation 3. CustomData => ToonShadowColor/ToonSecondaryShadowSmoothness 4. PrecomputedShadowFactors => ToonSecondaryShadowColor +5. `#define GBUFFER_REFACTOR 0` 以此关闭自动生成Encode/Decode GBufferData代码,并使用硬编码调用Encode/Decode GBufferData。 +6. `#if WRITES_VELOCITY_TO_GBUFFER` => `#if GBUFFER_HAS_VELOCITY`,以此**关闭写入VELOCITY到GBuffer中**。 ### Encode/Decode函数 RGB655 to 8-bit RGB。 @@ -224,6 +226,48 @@ FGBufferData DecodeGBufferData( ``` # BasePass BasePassPixelShader.usf +1. `#if 1` => `#if GBUFFER_REFACTOR && 0`,以此关闭自动生成Encode/Decode GBufferData代码,并使用硬编码调用Encode/Decode GBufferData。 +2. 在FPixelShaderInOut_MainPS()中添加写入FGBufferData逻辑。代码如下: + +```c++ +... +switch(GBuffer.ShadingModelID) +{ + case SHADINGMODELID_TOON_BASE: + GBuffer.ToonShadowColor = ToonShadingPerMaterialCustomData.ToonShadowColor.rgb; + GBuffer.ToonShadowLocation = ToonShadingPerMaterialCustomData.ToonShadowLocation; + GBuffer.ToonShadowSmoothness = ToonShadingPerMaterialCustomData.ToonShadowSmoothness; + GBuffer.ToonForceShadow = ToonShadingPerMaterialCustomData.ToonForceShadow; + GBuffer.ToonSecondaryShadowColor = ToonShadingPerMaterialCustomData.ToonSecondaryShadowColor.rgb; + GBuffer.ToonSecondaryShadowLocation = ToonShadingPerMaterialCustomData.ToonSecondaryShadowLocation; + GBuffer.ToonSecondaryShadowSmoothness = ToonShadingPerMaterialCustomData.ToonSecondaryShadowSmoothness; + GBuffer.Specular = 1.0; + GBuffer.GBufferAO = 0.0; + GBuffer.PrecomputedShadowFactors.gba = 1; + break; + case SHADINGMODELID_TOON_PBR: + GBuffer.ToonSpecularColor = ToonShadingPerMaterialCustomData.ToonSpecularColor.rgb; + GBuffer.ToonShadowColor = ToonShadingPerMaterialCustomData.ToonShadowColor.rgb; + GBuffer.ToonShadowLocation = ToonShadingPerMaterialCustomData.ToonShadowLocation; + GBuffer.ToonShadowSmoothness = ToonShadingPerMaterialCustomData.ToonShadowSmoothness; + GBuffer.ToonSecondaryShadowColor = ToonShadingPerMaterialCustomData.ToonShadowColor.rgb; + GBuffer.ToonForceShadow = 1.0; + GBuffer.Specular = 1.0; + GBuffer.PrecomputedShadowFactors.gba = 1; + break; + case SHADINGMODELID_TOON_SKIN: + GBuffer.ToonShadowColor = ToonShadingPerMaterialCustomData.ToonShadowColor.rgb; + GBuffer.ToonShadowLocation = ToonShadingPerMaterialCustomData.ToonShadowLocation; + GBuffer.ToonShadowSmoothness = ToonShadingPerMaterialCustomData.ToonShadowSmoothness; + GBuffer.ToonSecondaryShadowColor = ToonShadingPerMaterialCustomData.ToonShadowColor.rgb; + GBuffer.ToonForceShadow = 1.0; + GBuffer.PrecomputedShadowFactors.g = 1; + break; + default: + break; +} +... +``` # Lighting