diff --git a/src/Svg.Model/SvgFilterContext.cs b/src/Svg.Model/SvgFilterContext.cs index 6635358f4c..0a40ca95d6 100644 --- a/src/Svg.Model/SvgFilterContext.cs +++ b/src/Svg.Model/SvgFilterContext.cs @@ -1393,6 +1393,14 @@ private SKPoint3 GetPoint3(float x, float y, float z) var location = GetPoint3(svgSpotLight.X, svgSpotLight.Y, svgSpotLight.Z); var target = GetPoint3(svgSpotLight.PointsAtX, svgSpotLight.PointsAtY, svgSpotLight.PointsAtZ); var specularExponentSpotLight = svgSpotLight.SpecularExponent; + if (specularExponentSpotLight < 1f) + { + specularExponentSpotLight = 1f; + } + else if (specularExponentSpotLight > 128f) + { + specularExponentSpotLight = 128f; + } var limitingConeAngle = svgSpotLight.LimitingConeAngle; if (float.IsNaN(limitingConeAngle) || limitingConeAngle > 90f || limitingConeAngle < -90f) { @@ -1607,7 +1615,19 @@ private SKColorChannel GetColorChannel(SvgChannelSelector svgChannelSelector) var surfaceScale = svgSpecularLighting.SurfaceScale; var specularConstant = svgSpecularLighting.SpecularConstant; + if (specularConstant < 0f) + { + specularConstant = 0f; + } var specularExponent = svgSpecularLighting.SpecularExponent; + if (specularExponent < 1f) + { + specularExponent = 1f; + } + else if (specularExponent > 128f) + { + specularExponent = 128f; + } // TODO: svgSpecularLighting.KernelUnitLength switch (svgSpecularLighting.LightSource) @@ -1627,6 +1647,14 @@ private SKColorChannel GetColorChannel(SvgChannelSelector svgChannelSelector) var location = GetPoint3(svgSpotLight.X, svgSpotLight.Y, svgSpotLight.Z); var target = GetPoint3(svgSpotLight.PointsAtX, svgSpotLight.PointsAtY, svgSpotLight.PointsAtZ); var specularExponentSpotLight = svgSpotLight.SpecularExponent; + if (specularExponentSpotLight < 1f) + { + specularExponentSpotLight = 1f; + } + else if (specularExponentSpotLight > 128f) + { + specularExponentSpotLight = 128f; + } var limitingConeAngle = svgSpotLight.LimitingConeAngle; if (float.IsNaN(limitingConeAngle) || limitingConeAngle > 90f || limitingConeAngle < -90f) {