BlueRoseNote/02-Note/DAWA/ASoul/渲染方案/Shader修改部分.md

89 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Common
## Common.ush
添加结构体主要用在材质的CustomNode里。
```c++
// Used by toon shading.
// Define a global custom data structure which can be filled by Custom node in material BP.
struct FToonShadingPerMaterialCustomData
{
// Toon specular
float3 ToonSpecularColor;
float ToonSpecularLocation;
float ToonSpecularSmoothness;
// Toon shadow
float3 ToonShadowColor;
float ToonShadowLocation;
float ToonShadowSmoothness;
float ToonForceShadow;
// Toon secondary shadow
float3 ToonSecondaryShadowColor;
float ToonSecondaryShadowLocation;
float ToonSecondaryShadowSmoothness;
// custom data, usually not used
float4 CustomData0;
float4 CustomData1;
float4 CustomData2;
float4 CustomData3;
};
static FToonShadingPerMaterialCustomData ToonShadingPerMaterialCustomData;
```
## DeferredShadingCommon.ush
# Lighting
## ShadingModels
### ShadingCommon.ush
1. 添加ShadingModelID宏
- SHADINGMODELID_TOON_BASE 13
-
# PostProcess
## ToneMapping
c++部分主要修改了:
1. PostProcessing.cpp
2. PostProcessTonemap.cpp
3. PostProcessTonemap.h
***实现向ToneMaper Shader传递 `TRDGUniformBufferRef<FSceneTextureUniformParameters>`的功能***
之后再PostProcessTonemap.usf中对**CustomStencil**进行判断如果为true则直接返回之前渲染结果。实际上BufferVisualization里根本看不出来。
```c++
#include "DeferredShadingCommon.ush"
// pixel shader entry point
void MainPS(
in noperspective float2 UV : TEXCOORD0,
in noperspective float2 InVignette : TEXCOORD1,
in noperspective float4 GrainUV : TEXCOORD2,
in noperspective float2 ScreenPos : TEXCOORD3,
in noperspective float2 FullViewUV : TEXCOORD4,
float4 SvPosition : SV_POSITION, // after all interpolators
out float4 OutColor : SV_Target0
#if OUTPUT_LUMINANCE
, out float OutLuminance: SV_Target1
#endif
)
{
float Luminance;
FGBufferData SamplerBuffer = GetGBufferData(UV * View.ResolutionFractionAndInv.x, false);
if (SamplerBuffer.CustomStencil > 1.0f && abs(SamplerBuffer.CustomDepth - SamplerBuffer.Depth) < 1)
{
OutColor = SampleSceneColor(UV);
}
else
{
OutColor = TonemapCommonPS(UV, InVignette, GrainUV, ScreenPos, FullViewUV, SvPosition, Luminance);
}
#if OUTPUT_LUMINANCE
OutLuminance = Luminance;
#endif
}
```
## Lut