shadowRadius 不会模糊阴影

shadowRadius doesn't blur the shadow

我想在我的盒子上设置一个模糊的阴影。这是我到目前为止得到的。

关于 shadowRadius 的文档说。

SceneKit produces soft-edged shadows by rendering the silhouettes of geometry into a 2D shadow map and then using several weighted samples from the shadow map to determine the strength of the shadow at each pixel in the rendered scene. This property controls the radius of shadow map sampling. Lower numbers result in shadows with sharply defined, pixelated edges; higher numbers result in blurry shadows.

这是我的影子设置代码

func setupShadow(){
        spotLight.castsShadow = true
        spotLight.shadowRadius = 30000
        spotLight.shadowBias = 1
        spotLight.shadowColor = UIColor.blackColor()
    }

如您所见,阴影半径设置为一个很大的数字,但阴影仍然很尖锐。事实上,即使 shadowRadius 改变,模糊度也不会改变。我做错了什么?

您可能需要更小的半径(例如 [1; 3])。

然后在 iOS 上你还需要使用 shadowSampleCount 指定样本数量(因为在 iOS 上默认只有 1 个样本,这意味着没有模糊)。 请注意,增加样本数量会提高质量,但会对性能产生重大影响。