basic marching cubes working

This commit is contained in:
2026-04-11 10:15:50 +02:00
parent a8bcaeee23
commit 8e8d5ca1c9
14 changed files with 784 additions and 127 deletions
+9 -9
View File
@@ -1,32 +1,32 @@
import Common;
import FluidGridData;
struct Params
{
FluidGridData<float> density;
StructuredBuffer<float> vertexBuffer;
StructuredBuffer<uint> indexBuffer;
};
ParameterBlock<Params> params;
struct VertexOut
{
float4 position : SV_Position;
float2 uv : UV;
};
[shader("vertex")]
VertexOut vertexMain(uint vertexId : SV_VertexID)
{
VertexOut output;
output.uv = float2((vertexId << 1) & 2, vertexId & 2);
output.position = float4(output.uv * 2.0f - 1.0f, 0, 1);
uint index = params.indexBuffer[vertexId];
float3 vertex = float3(params.vertexBuffer[index * 3 + 0],
params.vertexBuffer[index * 3 + 1],
params.vertexBuffer[index * 3 + 2]) * 5;
output.position = mul(pViewParams.viewProjectionMatrix, float4(vertex, 1));
return output;
}
[shader("pixel")]
float4 fragmentMain(VertexOut input) : SV_Target
{
FluidGridData<float> density = params.density;
int x = int(input.uv.x * (gridSize.x - 2) + 1);
int y = int(input.uv.y * (gridSize.y - 2) + 1);
float d = density[x, y, 1];
return float4(d, d, d, 1);
return float4(0, 0, 1, 1);
}