Skip to content

Commit

Permalink
Fixed Material Volume Extension default values. Closes #215
Browse files Browse the repository at this point in the history
  • Loading branch information
vpenades committed Jan 24, 2024
1 parent 6a7a68b commit 8a7e74d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/SharpGLTF.Core/Schema2/gltf.MaterialsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ private TextureInfo _GetThicknessTexture(bool create)
public float ThicknessFactor
{
get => (float)_thicknessFactor.AsValue(_thicknessFactorDefault);
set => _thicknessFactor = ((double)value).AsNullable(_thicknessFactorDefault);
set => _thicknessFactor = ((double)value).AsNullable(_thicknessFactorDefault, _thicknessFactorMinimum, double.PositiveInfinity);
}

public Vector3 AttenuationColor
Expand All @@ -604,8 +604,8 @@ public Vector3 AttenuationColor

public float AttenuationDistance
{
get => (float)_attenuationDistance.AsValue(0);
set => _attenuationDistance = value > _attenuationDistanceExclusiveMinimum ? value : throw new ArgumentOutOfRangeException(nameof(value));
get => (float)_attenuationDistance.AsValue(float.PositiveInfinity);
set => _attenuationDistance = ((double)value).AsNullable(double.PositiveInfinity, _attenuationDistanceExclusiveMinimum, double.PositiveInfinity);
}

public IEnumerable<MaterialChannel> GetChannels(Material material)
Expand Down
2 changes: 1 addition & 1 deletion src/SharpGLTF.Toolkit/Materials/MaterialEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private static IEnumerable<_Property> _CreateDefaultProperties(KnownChannel key)
case KnownChannel.VolumeThickness: yield return new _Property(KnownProperty.ThicknessFactor, 0f); break;
case KnownChannel.VolumeAttenuation:
yield return new _Property(KnownProperty.RGB, Vector3.One);
yield return new _Property(KnownProperty.AttenuationDistance, 0f);
yield return new _Property(KnownProperty.AttenuationDistance, float.PositiveInfinity);
break;

default: throw new NotImplementedException();
Expand Down

0 comments on commit 8a7e74d

Please sign in to comment.