Load the serialized diameters into runtime memory and upload to GPU device.
This commit is contained in:
Родитель
c8c261d66e
Коммит
1b723437d8
|
@ -1689,14 +1689,17 @@ namespace Unity.DemoTeam.Hair
|
||||||
|
|
||||||
using (var alignedRootDirection = new NativeArray<Vector4>(strandGroupAsset.strandCount, Allocator.Temp, NativeArrayOptions.ClearMemory))
|
using (var alignedRootDirection = new NativeArray<Vector4>(strandGroupAsset.strandCount, Allocator.Temp, NativeArrayOptions.ClearMemory))
|
||||||
using (var alignedParticlePosition = new NativeArray<Vector4>(strandGroupParticleCount, Allocator.Temp, NativeArrayOptions.ClearMemory))
|
using (var alignedParticlePosition = new NativeArray<Vector4>(strandGroupParticleCount, Allocator.Temp, NativeArrayOptions.ClearMemory))
|
||||||
|
using (var alignedParticleDiameter = new NativeArray<float>(strandGroupParticleCount, Allocator.Temp, NativeArrayOptions.ClearMemory))
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (void* rootDirectionPtr = strandGroupAsset.rootDirection)
|
fixed (void* rootDirectionPtr = strandGroupAsset.rootDirection)
|
||||||
fixed (void* particlePositionPtr = strandGroupAsset.particlePosition)
|
fixed (void* particlePositionPtr = strandGroupAsset.particlePosition)
|
||||||
|
fixed (void* particleDiameterPtr = strandGroupAsset.particleDiameter)
|
||||||
{
|
{
|
||||||
UnsafeUtility.MemCpyStride(alignedRootDirection.GetUnsafePtr(), sizeof(Vector4), rootDirectionPtr, sizeof(Vector3), sizeof(Vector3), strandGroupAsset.strandCount);
|
UnsafeUtility.MemCpyStride(alignedRootDirection.GetUnsafePtr(), sizeof(Vector4), rootDirectionPtr, sizeof(Vector3), sizeof(Vector3), strandGroupAsset.strandCount);
|
||||||
UnsafeUtility.MemCpyStride(alignedParticlePosition.GetUnsafePtr(), sizeof(Vector4), particlePositionPtr, sizeof(Vector3), sizeof(Vector3), strandGroupParticleCount);
|
UnsafeUtility.MemCpyStride(alignedParticlePosition.GetUnsafePtr(), sizeof(Vector4), particlePositionPtr, sizeof(Vector3), sizeof(Vector3), strandGroupParticleCount);
|
||||||
|
UnsafeUtility.MemCpyStride(alignedParticleDiameter.GetUnsafePtr(), sizeof(float), particleDiameterPtr, sizeof(float), sizeof(float), strandGroupParticleCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1709,6 +1712,7 @@ namespace Unity.DemoTeam.Hair
|
||||||
uploadCtx.SetData(solverData[i].initialRootDirection, alignedRootDirection);
|
uploadCtx.SetData(solverData[i].initialRootDirection, alignedRootDirection);
|
||||||
|
|
||||||
uploadCtx.SetData(solverData[i].particlePosition, alignedParticlePosition);
|
uploadCtx.SetData(solverData[i].particlePosition, alignedParticlePosition);
|
||||||
|
uploadCtx.SetData(solverData[i].particleDiameter, alignedParticleDiameter);
|
||||||
|
|
||||||
uploadCtx.SetData(solverData[i].lodGuideCount, strandGroupAsset.lodGuideCount);
|
uploadCtx.SetData(solverData[i].lodGuideCount, strandGroupAsset.lodGuideCount);
|
||||||
uploadCtx.SetData(solverData[i].lodGuideIndex, strandGroupAsset.lodGuideIndex);
|
uploadCtx.SetData(solverData[i].lodGuideIndex, strandGroupAsset.lodGuideIndex);
|
||||||
|
|
|
@ -108,6 +108,7 @@ namespace Unity.DemoTeam.Hair
|
||||||
public static int _ParticlePositionCorr;
|
public static int _ParticlePositionCorr;
|
||||||
public static int _ParticleVelocity;
|
public static int _ParticleVelocity;
|
||||||
public static int _ParticleVelocityPrev;
|
public static int _ParticleVelocityPrev;
|
||||||
|
public static int _ParticleDiameter;
|
||||||
|
|
||||||
public static int _LODGuideCount;
|
public static int _LODGuideCount;
|
||||||
public static int _LODGuideIndex;
|
public static int _LODGuideIndex;
|
||||||
|
@ -704,7 +705,8 @@ namespace Unity.DemoTeam.Hair
|
||||||
changed |= CreateBuffer(ref solverData.particlePositionPrevPrev, "ParticlePosition_2", (Conf.SECOND_ORDER_UPDATE != 0) ? particleCount : 1, particleStrideVector4);
|
changed |= CreateBuffer(ref solverData.particlePositionPrevPrev, "ParticlePosition_2", (Conf.SECOND_ORDER_UPDATE != 0) ? particleCount : 1, particleStrideVector4);
|
||||||
changed |= CreateBuffer(ref solverData.particleVelocity, "ParticleVelocity_0", particleCount, particleStrideVector4);
|
changed |= CreateBuffer(ref solverData.particleVelocity, "ParticleVelocity_0", particleCount, particleStrideVector4);
|
||||||
changed |= CreateBuffer(ref solverData.particleVelocityPrev, "ParticleVelocity_1", (Conf.SECOND_ORDER_UPDATE != 0) ? particleCount : 1, particleStrideVector4);
|
changed |= CreateBuffer(ref solverData.particleVelocityPrev, "ParticleVelocity_1", (Conf.SECOND_ORDER_UPDATE != 0) ? particleCount : 1, particleStrideVector4);
|
||||||
|
changed |= CreateBuffer(ref solverData.particleDiameter, "ParticleDiameter", particleCount, particleStrideScalar);
|
||||||
|
|
||||||
changed |= CreateBuffer(ref solverData.lodGuideCount, "LODGuideCount", Mathf.Max(1, lodCount), particleStrideIndex);
|
changed |= CreateBuffer(ref solverData.lodGuideCount, "LODGuideCount", Mathf.Max(1, lodCount), particleStrideIndex);
|
||||||
changed |= CreateBuffer(ref solverData.lodGuideIndex, "LODGuideIndex", Mathf.Max(1, lodCount) * strandCount, particleStrideIndex);
|
changed |= CreateBuffer(ref solverData.lodGuideIndex, "LODGuideIndex", Mathf.Max(1, lodCount) * strandCount, particleStrideIndex);
|
||||||
changed |= CreateBuffer(ref solverData.lodGuideCarry, "LODGuideCarry", Mathf.Max(1, lodCount) * strandCount, particleStrideScalar);
|
changed |= CreateBuffer(ref solverData.lodGuideCarry, "LODGuideCarry", Mathf.Max(1, lodCount) * strandCount, particleStrideScalar);
|
||||||
|
@ -819,6 +821,7 @@ namespace Unity.DemoTeam.Hair
|
||||||
ReleaseBuffer(ref solverData.particlePositionCorr);
|
ReleaseBuffer(ref solverData.particlePositionCorr);
|
||||||
ReleaseBuffer(ref solverData.particleVelocity);
|
ReleaseBuffer(ref solverData.particleVelocity);
|
||||||
ReleaseBuffer(ref solverData.particleVelocityPrev);
|
ReleaseBuffer(ref solverData.particleVelocityPrev);
|
||||||
|
ReleaseBuffer(ref solverData.particleDiameter);
|
||||||
|
|
||||||
ReleaseBuffer(ref solverData.lodGuideCount);
|
ReleaseBuffer(ref solverData.lodGuideCount);
|
||||||
ReleaseBuffer(ref solverData.lodGuideIndex);
|
ReleaseBuffer(ref solverData.lodGuideIndex);
|
||||||
|
@ -906,6 +909,7 @@ namespace Unity.DemoTeam.Hair
|
||||||
target.BindComputeBuffer(UniformIDs._ParticlePositionCorr, solverData.particlePositionCorr);
|
target.BindComputeBuffer(UniformIDs._ParticlePositionCorr, solverData.particlePositionCorr);
|
||||||
target.BindComputeBuffer(UniformIDs._ParticleVelocity, solverData.particleVelocity);
|
target.BindComputeBuffer(UniformIDs._ParticleVelocity, solverData.particleVelocity);
|
||||||
target.BindComputeBuffer(UniformIDs._ParticleVelocityPrev, solverData.particleVelocityPrev);
|
target.BindComputeBuffer(UniformIDs._ParticleVelocityPrev, solverData.particleVelocityPrev);
|
||||||
|
target.BindComputeBuffer(UniformIDs._ParticleDiameter, solverData.particleDiameter);
|
||||||
|
|
||||||
target.BindComputeBuffer(UniformIDs._LODGuideCount, solverData.lodGuideCount);
|
target.BindComputeBuffer(UniformIDs._LODGuideCount, solverData.lodGuideCount);
|
||||||
target.BindComputeBuffer(UniformIDs._LODGuideIndex, solverData.lodGuideIndex);
|
target.BindComputeBuffer(UniformIDs._LODGuideIndex, solverData.lodGuideIndex);
|
||||||
|
|
|
@ -38,7 +38,8 @@ namespace Unity.DemoTeam.Hair
|
||||||
public ComputeBuffer particlePositionCorr; // xyz: ftl correction, w: -
|
public ComputeBuffer particlePositionCorr; // xyz: ftl correction, w: -
|
||||||
public ComputeBuffer particleVelocity; // xyz: velocity, w: splatting weight
|
public ComputeBuffer particleVelocity; // xyz: velocity, w: splatting weight
|
||||||
public ComputeBuffer particleVelocityPrev; // xyz: velocity, w: splatting weight
|
public ComputeBuffer particleVelocityPrev; // xyz: velocity, w: splatting weight
|
||||||
|
public ComputeBuffer particleDiameter; // x: diameter (mm)
|
||||||
|
|
||||||
public ComputeBuffer lodGuideCount; // n: lod index -> num. guides
|
public ComputeBuffer lodGuideCount; // n: lod index -> num. guides
|
||||||
public ComputeBuffer lodGuideIndex; // i: lod index * strand count + strand index -> guide index
|
public ComputeBuffer lodGuideIndex; // i: lod index * strand count + strand index -> guide index
|
||||||
public ComputeBuffer lodGuideCarry; // f: lod index * strand count + strand index -> guide carry
|
public ComputeBuffer lodGuideCarry; // f: lod index * strand count + strand index -> guide carry
|
||||||
|
|
Загрузка…
Ссылка в новой задаче