|
??????????????
??????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????
?????????
??????????????????????????????????????????????????
??? Elden Ring
???? ???
The Last of us Part I Remake
The Last of us Part II
?????2
Hogwarts: Legacy
??????????????????+?????????????????????????????????????????????????
Far Cry 6
?????2
????? Death Stranding
????????????????????????????????????????????????????????????????????????????????????????
???????????????
????????????????
????????????????
????????????????????????????????????????????
??????????????????????????????????????????????(Shallow Water/Wave Equation)?????????????????UE5.1????
?????????????
????????UE5.1????????????????
?????
?????????????????????????????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?????????????????????????????????????
??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????????????
????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????Neumann boundary condition?https://en.wikipedia.org/wiki/Neumann_boundary_condition????????????????????0???????????????????????hN(t-1)????????????X???4????????????????????????4?????????4?????Y??????Y???????X?????????????????????????????????????????????????????????????????
- <p>// Suppose Y is the point up to X. YIndex = XIndex + (0, 1)?</p><p>
- </p><p>float XHeight = WaterPreHeight.Load(XIndex).x;</p><p>
- </p><p>float YHeight = WaterPreHeight.Load(YIndex).x;</p><p>
- </p><p>if (IsBoundary(YHeight))</p><p>
- </p><p>{</p><p>
- </p><p>YHeight = XHeight;</p><p>
- </p><p>}</p>
复制代码
????
??????????????????
1. ???????????????????????????????
2. ?????????????
3. ???????
4. ????????????????
??????
???????????????????????????????????????????????????????????????GameThread????????????????????????????????????????????????????????????????????????????????????????????????????????????
?UE??????????SceneCaptureComponent????????????????????????????????????SceneCapture????????????????????????????????????????SceneCapture??????????Shader???????????????????????????????????????????????????????????????
???????????????????????pass?????????????????????????(ShadowDepth)?????UE?????https://docs.unrealengine.com/5.1/en-US/mesh-drawing-pipeline-in-unreal-engine/??
????????FParallelMeshDrawCommandPass???????????????DepthBuffer???????????????MeshProcessor?????CullingMode???????PS???????????????????????
????????Pass?????????????????????????SceneRenderer?????????????????????DrawCall????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????ResolvePass????R8???????????????????????????
?UE Insight??????????9????????????ResolvePass??????0.08ms?????2080S???
????????????
??????????Pass?????????????????????????????????????????2?R8????????????????????????????+?????????????
??????????????????????????????????????????????????????????????????????????????????????????????????Games103???https://www.bilibili.com/video/BV12Q4y1S73g/?p=10?????????????????????????????
???????????????????????????float_max?????????
- <p>if(bIsBoundary)</p><p>
- </p><p>{</p><p>
- </p><p>WaterHeight[SimulationIndex] = BOUNDARY_HEIGHT;</p><p>
- </p><p>}</p><p>
- </p><p>else</p><p>
- </p><p>{</p><p>
- </p><p>CapturedDepthVal = saturate(CapturedDepthVal);</p><p>
- </p><p>float CurrentWaterHeight = WaterHeight[SimulationIndex];</p><p>
- </p><p>// Object depth above water has no effect</p><p>
- </p><p>WaterHeight[SimulationIndex] = CapturedDepthVal == 0.0f ? CurrentWaterHeight : min(CurrentWaterHeight, - CapturedDepthVal);</p><p>
- </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??????????????????????????????????
????????????????
- <p>// Boundary pixels.</p><p>
- </p><p>if(IsBoundary(PrevHeight))</p><p>
- </p><p>{</p><p>
- </p><p>// Skip iteration.</p><p>
- </p><p>return;</p><p>
- </p><p>}</p><p>
- </p><p>// SWE</p><p>
- </p><p>float NearHeight = UpPrevHeight + DownPrevHeight + LeftPrevHeight + RightPrevHeight;</p><p>
- </p><p>float OutHeight = Damping * (PrevHeight + (PrevHeight - PrevPrevHeight) + TravelSpeed * 0.5f * (NearHeight - PrevHeight * 4));</p><p>
- </p><p>// Store to output texture</p><p>
- </p><p>OutWaterHeight[CurrentIndex] = OutHeight;</p>
复制代码
??????
?????????????????????????????????????
????????????????????
??????????ENQUEUE_RENDER_COMMAND??????????????????????????????????????????????????????????????????Normal/Displacement??????
??????????????????Normal?????????????????????PhotonWater???????Normal/Displacement Pass?????????????????????
????????????????????????????????????????????Norma?????????????????Mesh?????????????PhotonWater?????CDLOD???Mesh Tessellation?Screen-Space Displacement Mapping???????????????????????
???????????
??????????????????????????????????????????????????????????????????2??????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????
?????????????????????
??????????????????????????????????????????Mesh?????????????Clip???????????????????????BuildMeshDrawCommand??????CullMode?
- <p>ERasterizerCullMode MeshCullMode = ComputeMeshCullMode(MaterialResource, OverrideSettings);</p><p>
- </p><p>// Always render back faces</p><p>
- </p><p>MeshCullMode = MeshCullMode == CM_CCW ? CM_CW : CM_CCW;</p><p>
- </p><p>BuildMeshDrawCommmands(</p><p>
- </p><p>...,</p><p>
- </p><p>MeshCullMode,</p><p>
- </p><p>...</p><p>
- </p><p>);</p>
复制代码
??????PS???????????Pass???PS???????????????????????????????????????????????????????????????????????????
- <p>// CustomCapturePS.usf</p><p>
- </p><p>// Clip using water level, water level is already converted to device Z</p><p>
- </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
?????????Pass?
??????????)-CustomCapturePass
?????????????
Resolve????-PhotonWaterCopyCaptureDepth
???????????-ComputeWaves
??????-IterateSWE
???1024X1024??????????UnrealInsight???????(2080S)?
????????????????????????????????????????????????????????????????
??????
???????????????????????PC/Console???????
?????????????????Pass??????????????????????S20??????????
1024x1024?????????????3ms?
512x512??????????????1ms???
???????????????????????????????????????????????????????????????????????256x256?????????????
???????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????
???????????????
??????????????????????????????????????????????
??????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????2 (Red Dead Redemption 2)?????????????????
????????
??????????????????+flowmap??????????????????????
?????2?
?????????
Cities Skylines:
Uncharted:
??Unreal????
??????Photon Water System???????????????????(flowmap)?????
????????????????????????????????????(Flowmap)????PhotonWater???????Flowmap??????????
????????????????????????????????????????????????????
????????????
?????????????????????????
???????????????????????
??????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????PhotonWater??Flowmap???????????????????????
?????????????????????????????????????????????????????????????????Flowmap Advection Pass??????????????????????????????Advection??????????????????????????????????????????????????????????????????????
Advection
????????????????????????????/??/????????????????????????????????Flowmap??????????Advection????????????????????????????
???????????????????????????????????????????????????????????????????????????? https://www.youtube.com/watch?v=qsYE1wMEMPA??
???????????????????????????????????????????????????????????????????????????????????????4???????????GPU?????????
?????????????????????????????????????????????????????????????:
?????????????????????????????????????????????Sample?????????????????????????????????????Advection???????????????????GPU????????????
- int2 CurrentIndex = dispatchThreadId.xy;
- float2 FlowmapVector = GetFlowmapVec(CurrentIndex);
- // Get traced back indices by -FlowmapVector
- float2 TraceBackIndex = CurrentIndex - FlowmapVector * FlowmapStrength;
- // Handle boundary conditions inside the bilinear sample
- OutCurrentHeight[CurrentIndex] = BilinearSampleHeightsAtIndex(TraceBackIndex);
- // We need to update history height at the same time because the simulation depends on two frames of history data.
- OutHistoryHeight[CurrentIndex] = BilinearSampleHistoryHeightsAtIndex(TraceBackIndex);
复制代码
???????
????????????????????????????????Flowmap???Flowmap?????????????????????????????????
?????????????????????????????????????????????????????????????????????Volume Conservation??????????????Flowmap Advection??????????????????????????????????????????????????????????Damping???????????????????Damping????????????????????Flowmap????????damping????
????????Flowmap???Artists??????????????????????????Flowmap??
?????????????????????????????????????(Divergence)???(Curl)?????????????
?????????????Curl????????Divergence?????????????????????????????????????0????????????????????????????????????????????Helmholtz's theorem????????????????0???0???????
??????????????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??????????????????????????????????????
>>??
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
?????????
|
|