Fixed water rendering somewhat

This commit is contained in:
Dynamitos
2024-08-21 10:24:37 +02:00
parent 81090d78f0
commit fcdb132d49
8 changed files with 62 additions and 54 deletions
+13 -3
View File
@@ -1,8 +1,8 @@
import Bounding;
import Common;
import Scene;
import WaterCommon;
groupshared WaterPayload p;
[numthreads(1, 1, 1)]
[shader("amplification")]
@@ -10,6 +10,16 @@ void taskMain(
uint threadID: SV_GroupThreadID,
uint groupID: SV_GroupID, )
{
p = pWaterMaterial.tiles[groupID];
DispatchMesh(1, 1, 1, p);
WaterTile tile = pWaterMaterial.tiles[groupID];
GroupMemoryBarrierWithGroupSync();
AABB bounding;
bounding.minCorner = float3(tile.location.x, tile.height, tile.location.y) * tile.extent;
bounding.maxCorner = float3(tile.location.x + 1, tile.height, tile.location.y + 1) * tile.extent;
float3 median = (bounding.minCorner + bounding.maxCorner) / 2;
float distance = distance(median, pViewParams.cameraPos_WS.xyz);
uint numMeshes = max(10 - uint(distance / tile.extent), 1);
WaterPayload payload;
payload.offset = bounding.minCorner;
payload.extent = tile.extent / numMeshes;
DispatchMesh(numMeshes, numMeshes, 1, payload);
}