32 lines
709 B
Plaintext
32 lines
709 B
Plaintext
import FluidGridData;
|
|||
|
|
|
||
|
|
struct Params
|
||
|
|
{
|
||
|
|
FluidGridData<float> density;
|
||
|
|
};
|
||
|
|
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);
|
||
|
|
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, 0];
|
||
|
|
return float4(d, d, d, 1);
|
||
|
|
}
|