Hi Tim,
I’m returning again to this highly demanded issue.
What would you recommend to modify here to “check if the position being processed is within a masking primitive there and return from the function early”? For masking, I’ll use a cube from a scene. Would it be easier to assign it in this script as a public GameObject, Collider, Vector3, or something else? What components does this object have to have for masking in this script? I appreciate your help a lot.
void GetSDFCamContribution(in uint perspectiveIndex, in float3 pos3d, inout float accumulatedWeight, inout float accumulatedSDF)
{
int flag = VOX_UNKNOWN;
float sdf;
float newWeight = 0.0;
float normalWeight = 0.0f;
PerspectiveGeometry data = _PerspectiveGeometryData[perspectiveIndex];
if (data.enabled == 0)
return; //this perspective is disabled
if (GetSDFContribution(perspectiveIndex, pos3d, flag, sdf, normalWeight))
{
if (!CalculateSDFWeight(perspectiveIndex, pos3d, sdf, flag, data, normalWeight, newWeight))
return;
}
else
{
// GetSDFContribution return false and the flag values are either VOX_UNKNOWN or VOX_INVALID
// weight unknown voxels are updated to lie at the _sdfSensitivity on the inside of the surface
float weightUnknown = lerp(_WeightUnknown, data.weightUnknown, data.overrideWeightUnknown);
// weight unknown values larger than epsilon are used to keep the surface from getting noisy
if (flag == VOX_UNKNOWN && weightUnknown >= epsilon)
{
sdf = -_SdfSensitivity;
newWeight = weightUnknown;
}
else
{
// for voxels flagged invalid or unknown voxels with very low weight known values, the sdf and weight is not updated.
// This is so the accumulatedSDF remains at the InvalidSDF value so they can be filtered out
// return without updating the accumulatedSDF and accumulatedWeight value.
return;
}
}
// accumulatedSDF is set to InvalidSDF so the first perspective that has a valid update to this must set it
if (accumulatedSDF >= Invalid_Sdf_compare)
{
accumulatedSDF = newWeight * sdf;
accumulatedWeight = newWeight;
}
else
{
// subsequent perspectives can accumulate the sdf and weight values
accumulatedSDF += newWeight * sdf;
accumulatedWeight += newWeight;
}
}