应用阴影偏差以防止自阴影伪像。指定的值是每个片段轨迹宽度的比例。
using UnityEngine; using System.Collections;
[RequireComponent(typeof(TrailRenderer))] public class ExampleClass : MonoBehaviour { private TrailRenderer tr;
void Start() { tr = GetComponent<TrailRenderer>(); tr.material = new Material(Shader.Find("Standard")); tr.castShadows = true; tr.receiveShadows = true; tr.shadowBias = 0.3f; } }