basic marching cubes working
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user