游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3473|回复: 0

???????: ????????????????????

[复制链接]

5万

主题

5万

帖子

9万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
90639
发表于 2023-8-17 09:38:28 | 显示全部楼层 |阅读模式
??????????????

??????????????????????????????????????????????????????????

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

???????????????????????????????????????????????????????????????

?????????

??????????????????????????????????????????????????

??? Elden Ring

????_20230817090952.gif

???? ???

????_20230817090955.gif

The Last of us Part I Remake

????_20230817090955_1.gif

The Last of us Part II

????_20230817090957.gif

?????2

????_20230817090958.gif

Hogwarts: Legacy

????_20230817090959.gif

??????????????????+?????????????????????????????????????????????????

Far Cry 6

????_20230817091001.gif

?????2

????_20230817091003.gif

????? Death Stranding

????_20230817091004.gif

????????????????????????????????????????????????????????????????????????????????????????

???????????????

????????????????

????????????????

????????????????????????????????????????????

??????????????????????????????????????????????(Shallow Water/Wave Equation)?????????????????UE5.1????

?????????????

????????UE5.1????????????????

????_20230817091005.gif

?????

?????????????????????????????mesh????????????????????????????????????????????????????????????????????????????GPU??????????????????(Texture)??????????

????

Shallow Water Equation?????Shallow Wave Equation???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Wikipedia???https://en.wikipedia.org/wiki/Shallow_water_equations?????????Games103???https://www.bilibili.com/video/BV12Q4y1S73g/?p=10?????????????????????????????????????

????_20230817091005_1.JPG

??ViscosityConstant, ?: SWE constant, hN(t-1): Height sum of the nearest four points

???????????????????????h(t)???????h(t-1)?h(t-2)???????????????????????????Damping???????????????????1?????0-0.5???Damping???0-1????????????

????

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

????_20230817091005_2.gif

??????????????????????????Neumann boundary condition?https://en.wikipedia.org/wiki/Neumann_boundary_condition????????????????????0???????????????????????hN(t-1)????????????X???4????????????????????????4?????????4?????Y??????Y???????X?????????????????????????????????????????????????????????????????

  1. <p>// Suppose Y is the point up to X. YIndex = XIndex + (0, 1)?</p><p>
  2. </p><p>float XHeight = WaterPreHeight.Load(XIndex).x;</p><p>
  3. </p><p>float YHeight = WaterPreHeight.Load(YIndex).x;</p><p>
  4. </p><p>if (IsBoundary(YHeight))</p><p>
  5. </p><p>{</p><p>
  6. </p><p>YHeight = XHeight;</p><p>
  7. </p><p>}</p>
复制代码

????

??????????????????

1. ???????????????????????????????

2. ?????????????

3. ???????

4. ????????????????

????_20230817091006.JPG

??????

???????????????????????????????????????????????????????????????GameThread????????????????????????????????????????????????????????????????????????????????????????????????????????????

?UE??????????SceneCaptureComponent????????????????????????????????????SceneCapture????????????????????????????????????????SceneCapture??????????Shader???????????????????????????????????????????????????????????????

???????????????????????pass?????????????????????????(ShadowDepth)?????UE?????https://docs.unrealengine.com/5.1/en-US/mesh-drawing-pipeline-in-unreal-engine/??

????_20230817091006_1.JPG

????????FParallelMeshDrawCommandPass???????????????DepthBuffer???????????????MeshProcessor?????CullingMode???????PS???????????????????????

????????Pass?????????????????????????SceneRenderer?????????????????????DrawCall????

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??????????????????????????????????????????????????????????????????????ResolvePass????R8???????????????????????????

????_20230817091006_2.JPG

?UE Insight??????????9????????????ResolvePass??????0.08ms?????2080S???

????????????

??????????Pass?????????????????????????????????????????2?R8????????????????????????????+?????????????

??????????????????????????????????????????????????????????????????????????????????????????????????Games103???https://www.bilibili.com/video/BV12Q4y1S73g/?p=10?????????????????????????????

???????????????????????????float_max?????????

  1. <p>if(bIsBoundary)</p><p>
  2. </p><p>{</p><p>
  3. </p><p>WaterHeight[SimulationIndex] = BOUNDARY_HEIGHT;</p><p>
  4. </p><p>}</p><p>
  5. </p><p>else</p><p>
  6. </p><p>{</p><p>
  7. </p><p>CapturedDepthVal = saturate(CapturedDepthVal);</p><p>
  8. </p><p>float CurrentWaterHeight = WaterHeight[SimulationIndex];</p><p>
  9. </p><p>// Object depth above water has no effect</p><p>
  10. </p><p>WaterHeight[SimulationIndex] = CapturedDepthVal == 0.0f ? CurrentWaterHeight : min(CurrentWaterHeight, - CapturedDepthVal);</p><p>
  11. </p><p>}</p>
复制代码

??????

???????????????????????????????????????Damping???????????????????????????????????????????????????????????????????????????????????????CS?????????????????????????????????????????????????PCG????????????Games103??????VirtualHeight????https://www.bilibili.com/video/BV12Q4y1S73g?t=4855.3&p=10????????????????

?????????????????????WaterLinePro????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??Shader?????????2???????????????????1????????????????????CS/??PS????????????????ping-pong??????????????????????????????????

????????????????

  1. <p>// Boundary pixels.</p><p>
  2. </p><p>if(IsBoundary(PrevHeight))</p><p>
  3. </p><p>{</p><p>
  4. </p><p>// Skip iteration.</p><p>
  5. </p><p>return;</p><p>
  6. </p><p>}</p><p>
  7. </p><p>// SWE</p><p>
  8. </p><p>float NearHeight = UpPrevHeight + DownPrevHeight + LeftPrevHeight + RightPrevHeight;</p><p>
  9. </p><p>float OutHeight = Damping * (PrevHeight + (PrevHeight - PrevPrevHeight) + TravelSpeed * 0.5f * (NearHeight - PrevHeight * 4));</p><p>
  10. </p><p>// Store to output texture</p><p>
  11. </p><p>OutWaterHeight[CurrentIndex] = OutHeight;</p>
复制代码


??????

?????????????????????????????????????

????_20230817091007.gif
????????????????????

??????????ENQUEUE_RENDER_COMMAND??????????????????????????????????????????????????????????????????Normal/Displacement??????

??????????????????Normal?????????????????????PhotonWater???????Normal/Displacement Pass?????????????????????

????????????????????????????????????????????Norma?????????????????Mesh?????????????PhotonWater?????CDLOD???Mesh Tessellation?Screen-Space Displacement Mapping???????????????????????

???????????

??????????????????????????????????????????????????????????????????2??????????????????????????????????????????????????????????????????????????????????????????????

???????????????????????????????????????????????????????????????????????

????_20230817091007_1.gif

?????????????????????

????_20230817091007_2.gif

??????????????????????????????????????????Mesh?????????????Clip???????????????????????BuildMeshDrawCommand??????CullMode?

  1. <p>ERasterizerCullMode MeshCullMode = ComputeMeshCullMode(MaterialResource, OverrideSettings);</p><p>
  2. </p><p>// Always render back faces</p><p>
  3. </p><p>MeshCullMode = MeshCullMode == CM_CCW ? CM_CW : CM_CCW;</p><p>
  4. </p><p>BuildMeshDrawCommmands(</p><p>
  5. </p><p>...,</p><p>
  6. </p><p>MeshCullMode,</p><p>
  7. </p><p>...</p><p>
  8. </p><p>);</p>
复制代码

??????PS???????????Pass???PS???????????????????????????????????????????????????????????????????????????

  1. <p>// CustomCapturePS.usf</p><p>
  2. </p><p>// Clip using water level, water level is already converted to device Z</p><p>
  3. </p><p>clip(WaterLevelVal - SvPosition.z);</p>
复制代码

???????????????(Proxy)Mesh???????????????????????Hogwarts: Legacy?????????????????????????Mesh??????????????????Sphere/Capsule?????????????????????Artists???????????????????????????4????Attach??????????????Mesh????????????????

???Shader??

????????????Buffer???????????Buffer???????????????????1024x1024???????4096x4096?????????????????????????????????????????

3?????? R16F * 3

????????? R8 * 2

???????DS * 1

????_20230817091007_3.JPG

?????????Pass?

??????????)-CustomCapturePass

?????????????

Resolve????-PhotonWaterCopyCaptureDepth

???????????-ComputeWaves

??????-IterateSWE

???1024X1024??????????UnrealInsight???????(2080S)?

????_20230817091008.JPG

????????????????????????????????????????????????????????????????

??????

???????????????????????PC/Console???????

????_20230817091009.gif

?????????????????Pass??????????????????????S20??????????

1024x1024?????????????3ms?

512x512??????????????1ms???

???????????????????????????????????????????????????????????????????????256x256?????????????

???????????????

??????????????????????????????????????????????????????????????????????????????????????????????????????

???????????????????????????????????????????????????????????????????????

???????????????

??????????????????????????????????????????????

????_20230817091009_1.gif

??????????????????????????????????????????????????????????????

??????????????????????????????????????????????????????????????????????????????????????

???????????????????????????????????????????2 (Red Dead Redemption 2)?????????????????

????_20230817091011.gif

????????

??????????????????+flowmap??????????????????????

?????2?

????_20230817091012.gif

?????????

Cities Skylines:

????_20230817091013.gif

Uncharted:

????_20230817091014.gif

??Unreal????

????_20230817091015.gif

??????Photon Water System???????????????????(flowmap)?????

????_20230817091015_1.JPG

????????????????????????????????????(Flowmap)????PhotonWater???????Flowmap??????????

????_20230817091016.gif

????????????????????????????????????????????????????

????????????

?????????????????????????

????_20230817091017.gif

???????????????????????

????_20230817091018.gif

??????

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????PhotonWater??Flowmap???????????????????????

?????????????????????????????????????????????????????????????????Flowmap Advection Pass??????????????????????????????Advection??????????????????????????????????????????????????????????????????????

????_20230817091018_1.JPG

Advection

????????????????????????????/??/????????????????????????????????Flowmap??????????Advection????????????????????????????

???????????????????????????????????????????????????????????????????????????? https://www.youtube.com/watch?v=qsYE1wMEMPA??

????_20230817091019.JPG

???????????????????????????????????????????????????????????????????????????????????????4???????????GPU?????????

?????????????????????????????????????????????????????????????:

????_20230817091019_1.JPG

?????????????????????????????????????????????Sample?????????????????????????????????????Advection???????????????????GPU????????????

  1. int2 CurrentIndex = dispatchThreadId.xy;

  2. float2 FlowmapVector = GetFlowmapVec(CurrentIndex);

  3. // Get traced back indices by -FlowmapVector

  4. float2 TraceBackIndex = CurrentIndex - FlowmapVector * FlowmapStrength;

  5. // Handle boundary conditions inside the bilinear sample

  6. OutCurrentHeight[CurrentIndex] = BilinearSampleHeightsAtIndex(TraceBackIndex);

  7. // We need to update history height at the same time because the simulation depends on two frames of history data.

  8. OutHistoryHeight[CurrentIndex] = BilinearSampleHistoryHeightsAtIndex(TraceBackIndex);
复制代码

???????

????????????????????????????????Flowmap???Flowmap?????????????????????????????????

?????????????????????????????????????????????????????????????????????Volume Conservation??????????????Flowmap Advection??????????????????????????????????????????????????????????Damping???????????????????Damping????????????????????Flowmap????????damping????

????????Flowmap???Artists??????????????????????????Flowmap??

?????????????????????????????????????(Divergence)???(Curl)?????????????

????_20230817091019_2.gif

?????????????Curl????????Divergence?????????????????????????????????????0????????????????????????????????????????????Helmholtz's theorem????????????????0???0???????

????_20230817091019_3.JPG

??????????????divergence-free?flowmap??????????????????????????????????????????????????????????????????????????https://youtu.be/qsYE1wMEMPA?list=PLi3obdsHfCiIjjfoF43df61WR1aXNhNID&t=699???????????https://en.wikipedia.org/wiki/Helmholtz_decomposition???????

?PhotonWater?????Flowmap???????????????????

????

?????????????????????????????????????????????????????????????????????Wrap???????????????????????????

????

???????Pass?Flowmap Advection?????????????????????????????????????Pass????????

???????????????????????????Flowmap?TextureSample??????????????????????????????????????????Flowmap???????????????????????????2080S???Pass GPU?????0.1ms??????????????????????????????????????

????_20230817091020.JPG

>>??
1. Games103?https://www.bilibili.com/video/BV12Q4y1S73g/?p=10? -??Surface Waves?SWE?????????
2. Waterline Pro Plugin?https://www.unrealengine.com/marketplace/en-US/product/waterline? -??????????????SceneCapture?????????????????
3. Kass, Michael, and Gavin Miller. "Rapid, stable fluid dynamics for computer graphics." Proceedings of the 17th annual conference on Computer graphics and interactive techniques. 1990.
4. But How DO Fluid Simulations Work? (https://www.youtube.com/watch?v=qsYE1wMEMPA) ????????Advection???
5. 3B1B???????? (https://www.youtube.com/watch?v=rB83DpBJQsE)
6. PhotonWater?GDC?? (https://www.youtube.com/watch?v=rB83DpBJQsE)???Flowmap?????

?/Byreave
?????????

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-10-18 22:46

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表