So many changes again
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import FluidGridData;
|
||||
|
||||
struct Params
|
||||
{
|
||||
// read-write: phi to add source to
|
||||
FluidGridData<float> phi;
|
||||
FluidGridData<float> density;
|
||||
};
|
||||
ParameterBlock<Params> params;
|
||||
|
||||
[shader("compute")]
|
||||
[numthreads(32, 8, 1)]
|
||||
void addSource(uint3 dispatchThreadID : SV_DispatchThreadID)
|
||||
{
|
||||
FluidGridData<float> phi = params.phi;
|
||||
FluidGridData<float> density = params.density;
|
||||
int x = dispatchThreadID.x + 1;
|
||||
int y = dispatchThreadID.y + 1;
|
||||
int z = dispatchThreadID.z + 1;
|
||||
if(x >= gridParams.gridSize.x - 1 || y >= gridParams.gridSize.y - 1 || z >= gridParams.gridSize.z - 1) return;
|
||||
|
||||
// Add a spherical source and union it into the existing level set.
|
||||
float3 center = float3(gridParams.gridSize) * 0.5f;
|
||||
float radius = min(gridParams.gridSize.x, min(gridParams.gridSize.y, gridParams.gridSize.z)) * 0.25f;
|
||||
float3 pos = float3(x, y, z);
|
||||
float dist = length(pos - center);
|
||||
float sourcePhi = dist - radius;
|
||||
phi[x, y, z] = min(phi[x, y, z], sourcePhi);
|
||||
|
||||
if (sourcePhi < 0.0f)
|
||||
{
|
||||
density[x, y, z] += 0.5f;
|
||||
density[x, y, z] = min(density[x, y, z], 1.0f);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user