UE4 Engine Fix-Movable的 SkyLight 导致 SSS 过度曝光的问题

目录:第九艺术-目录

目录

起因问题

Stationary 的SkyLight

Movable 的SkyLight


起因问题

起因问题是 Movable SkyLight 的情况下,Character会整体泛白,基本看不出来原本的颜色

而 Stationary 下 是正常的

UE4 是使用的 SSSS,可分离的次表面散射算法,具体是在 下图 SubsurfaceScattering 的 Pass

过程对比

Stationary 的SkyLight

计算SkyLight是在 BasePass里的 GetSkyLighting() 计算天空光,计算 Out.MRT[0].rgb

除了SkyVisibility,核心就这两句,OutDiffuseLighting 就是 rgb

 // Compute the preconvolved incoming lighting with the bent normal direction
	float3 DiffuseLookup = GetEffectiveSkySHDiffuse(SkyLightingNormal) * ResolvedView.SkyLightColor.rgb;
​
 // Apply AO to the sky diffuse
	OutDiffuseLighting += DiffuseLookup * (SkyVisibility * GeometryTerm);

然后 使用 次表面的话,累加 Color 和 DiffuseColor 计算亮度,=计算 Out.MRT[0].a

  1. LightAccumulator_Add(LightAccumulator, Color + DiffuseColor, DiffuseColor, 1.0f, UseSubsurfaceProfile(GBuffer.ShadingModelID)); 累加计算亮度值
  2. LightAccumulator_GetResult(LightAccumulator); 赋值给 Out.MRT[0].alpha值存储亮度,用于之后 在 需要的时候,通过这张RT上rgb的Color 和alpha 的亮度值 ReconstructLight

在basepass 的最后,还会调整一次预曝光,*= View.PreExposure,注意这里只调整了 xyz

#if !MATERIALBLENDING_MODULATE && USE_PREEXPOSURE
	Out.MRT[0].xyz *= View.PreExposure;
#endif

Movable 的SkyLight

计算SkyLight是在 ReflectionEnvironmentAndSky 里的 SkyLightDiffuse()

除了SkyVisibility,还考虑了 AO,因为这个pass靠后,但核心还是那几句,Lighting 就是rgb

 // Compute the preconvolved incoming lighting with the bent normal direction
	float3 DiffuseLookup = GetSkySHDiffuse(SkyLightingNormal) * View.SkyLightColor.rgb;
​
 // Apply AO to the sky diffuse and account for darkening due to the geometry term
 // apply the Diffuse color to the lighting (including OcclusionTintAndMinOcclusion as it's considered another light, that fixes SubsurfaceProfile being too dark)
	Lighting += ((ScalarFactors * DotProductFactor) * DiffuseLookup + (1 - SkyVisibility) * OcclusionTintAndMinOcclusion.xyz) * DiffuseColor;
​
	Lighting += DiffuseIrradiance * GBuffer.DiffuseColor * (GBuffer.GBufferAO * AmbientOcclusion);
​
#if USE_PREEXPOSURE
	Lighting *= View.PreExposure;
#endif

可以看到这里输出rgb之后,直接就在这里做了预曝光,

然后出来在 ReflectionEnvironmentSkyLighting 才做亮度计算,赋值alpha值

 LightAccumulator_Add(LightAccumulator, SkyLighting, SkyLighting, 1.0f, bNeedsSeparateSubsurfaceLightAccumulation);
 OutColor = LightAccumulator_GetResult(LightAccumulator);

所以这里的alpha亮度就和 basepass不一样了

而在使用的地方,也就是ReconstructLight的时候,会有如下计算

float DiffuseLuminance = CenterSample.a * View.PreExposure;

也就是之后 alpha通道会再乘PreExposure,所以动态天光下相当于alpha通道乘了两次,所以会偏白

解决方法也很简单,把 SkyLightDiffuse 里的计算预曝光的部分移到 ReflectionEnvironmentSkyLighting 里面计算亮度的后面就好了

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
movable-view是一个可移动的视图容器,在页面中可以通过拖拽滑动来改变其位置。它通常与movable-area一起使用,movable-area是movable-view的父级容器,必须设置width和height属性,否则默认为10px。\[1\] 注意事项包括: 1. movable-view和movable-area都必须设置width和height属性,否则默认为10px。 2. movable-view默认为绝对定位,top和left属性为0px。 3. movable-view的移动范围限制在movable-area内,如果movable-view的宽或高值比movable-area大,则只能在x或y方向移动,若都超过,则无法移动。 4. movable-view必须在组件中,并且必须是直接子节点,否则不能移动。\[2\] 在微信小程序中,movable-view是一个独有的模块,它有两个标签:movable-area作为父容器,movable-view作为子容器。子容器必须在父容器中,否则无法实现移动效果。\[3\] 下面是一个示例代码,展示了如何使用movable-view和movable-area来创建一个可移动的红色视图: ```html <movable-area class='area'> <movable-view class='a' direction='all' inertia out-of-bounds="{{false}}" x="{{x*2}}rpx" y="{{y*2}}rpx" damping='30' friction="30"> 我是红色 </movable-view> </movable-area> <button bind:tap="areaEvent">按钮</button> ``` 在这个示例中,movable-view被设置为红色,并且可以通过拖拽滑动来改变其位置。\[3\] #### 引用[.reference_title] - *1* *2* [uni-app视图容器之movable-view](https://blog.csdn.net/qq_27600723/article/details/106452491)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [手把手带你学习微信小程序 —— 九 (movable-view 组件)](https://blog.csdn.net/caidewei121/article/details/96352443)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值