|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[Serializable] |
|
|
|
public class SubsurfaceScatteringSettings |
|
|
|
public class SubsurfaceScatteringSettings : ISerializationCallbackReceiver |
|
|
|
{ |
|
|
|
public const int maxNumProfiles = 8; |
|
|
|
public const int neutralProfileID = 7; |
|
|
|
|
|
|
halfRcpWeightedVariances = null; |
|
|
|
filterKernels = null; |
|
|
|
|
|
|
|
OnValidate(); // Perform initialization
|
|
|
|
UpdateCache(); |
|
|
|
} |
|
|
|
|
|
|
|
public void OnValidate() |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (thicknessRemaps == null || thicknessRemaps.Length != (maxNumProfiles * 2)) |
|
|
|
{ |
|
|
|
thicknessRemaps = new float[maxNumProfiles * 2]; |
|
|
|
} |
|
|
|
|
|
|
|
if (halfRcpVariancesAndLerpWeights == null || halfRcpVariancesAndLerpWeights.Length != (maxNumProfiles * 2)) |
|
|
|
{ |
|
|
|
halfRcpVariancesAndLerpWeights = new Vector4[maxNumProfiles * 2]; |
|
|
|
} |
|
|
|
|
|
|
|
if (halfRcpWeightedVariances == null || halfRcpWeightedVariances.Length != maxNumProfiles) |
|
|
|
{ |
|
|
|
halfRcpWeightedVariances = new Vector4[maxNumProfiles]; |
|
|
|
} |
|
|
|
|
|
|
|
if (filterKernels == null || filterKernels.Length != (maxNumProfiles * SubsurfaceScatteringProfile.numSamples)) |
|
|
|
{ |
|
|
|
filterKernels = new Vector4[maxNumProfiles * SubsurfaceScatteringProfile.numSamples]; |
|
|
|
} |
|
|
|
|
|
|
|
Color c = new Color(); |
|
|
|
|
|
|
|
for (int i = 0; i < numProfiles; i++) |
|
|
|
|
|
|
profiles[i].UpdateKernelAndVarianceData(); |
|
|
|
} |
|
|
|
|
|
|
|
UpdateCache(); |
|
|
|
} |
|
|
|
|
|
|
|
public void UpdateCache() |
|
|
|
{ |
|
|
|
// Use the updated data to fill the cache.
|
|
|
|
if (thicknessRemaps == null || thicknessRemaps.Length != (maxNumProfiles * 2)) |
|
|
|
{ |
|
|
|
thicknessRemaps = new float[maxNumProfiles * 2]; |
|
|
|
} |
|
|
|
|
|
|
|
if (halfRcpVariancesAndLerpWeights == null || halfRcpVariancesAndLerpWeights.Length != (maxNumProfiles * 2)) |
|
|
|
{ |
|
|
|
halfRcpVariancesAndLerpWeights = new Vector4[maxNumProfiles * 2]; |
|
|
|
} |
|
|
|
|
|
|
|
if (halfRcpWeightedVariances == null || halfRcpWeightedVariances.Length != maxNumProfiles) |
|
|
|
{ |
|
|
|
halfRcpWeightedVariances = new Vector4[maxNumProfiles]; |
|
|
|
} |
|
|
|
|
|
|
|
if (filterKernels == null || filterKernels.Length != (maxNumProfiles * SubsurfaceScatteringProfile.numSamples)) |
|
|
|
{ |
|
|
|
filterKernels = new Vector4[maxNumProfiles * SubsurfaceScatteringProfile.numSamples]; |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < numProfiles; i++) |
|
|
|
{ |
|
|
|
// Skip unassigned profiles.
|
|
|
|
|
|
|
filterKernels[n * i + j].w = 0.0f; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void OnBeforeSerialize() |
|
|
|
{ |
|
|
|
// No special action required.
|
|
|
|
} |
|
|
|
|
|
|
|
public void OnAfterDeserialize() |
|
|
|
{ |
|
|
|
UpdateCache(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|