Skip to content

Instantly share code, notes, and snippets.

@2youyou2
Created December 17, 2020 09:35
Show Gist options
  • Save 2youyou2/d2244f33c28e1eb20cff2e302b50c796 to your computer and use it in GitHub Desktop.
Save 2youyou2/d2244f33c28e1eb20cff2e302b50c796 to your computer and use it in GitHub Desktop.
unreal 4.25 subsurface shader 流程
- ShadowProjectionPixelShader.usf/Main (画阴影到 Common.ush/LightAttenuationTexture 中)
- SSSTransmission = ManualPCF(ShadowPosition.xy, Settings); (输出到 FadedSSSShadow)
- OutColor = EncodeLightAttenuation(half4(FadedShadow, FadedSSSShadow, FadedShadow, FadedSSSShadow)) (最终输出)
- BasePassPixelShader.usf/FPixelShaderInOut_MainPS (画基本物体的 pass)
- 调用 MaterialTemplate.ush 提供的方法(材质蓝图会根据 MaterialTemplate.ush 填充对应的方法)
GetMaterialBaseColor
GetMaterialMetallic
GetMaterialSpecular
GetXXX...
- ShadingModelsMaterial.ush/SetGBufferForShadingModel 输出到 DeferredShadingCommon.ush/FGBufferData 结构体中
- DeferredLightPixelShaders.usf/DeferredLightPixelMain
- DeferredShadingCommon.ush/GetScreenSpaceData (获取 GBuffer)
- GetGBufferData {
float4 GBufferA = FramebufferFetchMRT(1);
float4 GBufferB = FramebufferFetchMRT(2);
float4 GBufferC = FramebufferFetchMRT(3);
float4 GBufferD = FramebufferFetchMRT(4);
return DecodeGBufferData(GBufferA, GBufferB, GBufferC, GBufferD, GBufferE, GBufferF, GBufferVelocity, CustomNativeDepth, CustomStencil, SceneDepth, bGetNormalizedNormal, CheckerFromSceneColorUV(UV));
}
- GetPerPixelLightAttenuation (获取阴影贴图)
- GetDynamicLighting
- GetShadowTerms (用阴影贴图获取的数据计算阴影)
- ShadingModels.ush/IntegrateBxDF(根据 shading model 调用对应的 BXDF)
- SubsurfaceBxDF
- OutColor += (Radiance * Attenuation) * OpaqueVisibility;
@2youyou2
Copy link
Author

EditorFactories.cpp

UTextureExporterTGA::ExportBinary

Texture is RGBA16 and cannot be represented at such high bit depth in .tga. Color will be scaled to RGBA8.

@2youyou2
Copy link
Author

IndirectLightRendering.cpp => SetupReflectionUniformParameters

CubeArrayTexture = Scene->ReflectionSceneData.CubemapArray.GetRenderTarget().ShaderResourceTexture

@2youyou2
Copy link
Author

2youyou2 commented Sep 24, 2021

查找最近反射球

FScene::FindClosestReflectionCaptures(FVector Position, const FReflectionCaptureProxy* (&SortedByDistanceOUT)[FPrimitiveSceneInfo::MaxCachedReflectionCaptureProxies])

更新最近反射球
FPrimitiveSceneInfo::CacheReflectionCaptures

@2youyou2
Copy link
Author

r.CompileShadersForDevelopment=0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment