void Update() { if (block == null) { block = new MaterialPropertyBlock(); block.SetVectorArray(baseColorId, baseColors); block.SetFloatArray(metallicId, metallic); block.SetFloatArray(smoothnessId, smoothness); if (!lightProbeVolume) { var positions = new Vector3[1023]; for (int i = 0; i < matrices.Length; i++) { positions[i] = matrices[i].GetColumn(3); } var lightProbes = new SphericalHarmonicsL2[1023]; var occlusionProbes = new Vector4[1023]; LightProbes.CalculateInterpolatedLightAndOcclusionProbes( positions, lightProbes, occlusionProbes ); block.CopySHCoefficientArraysFrom(lightProbes); block.CopyProbeOcclusionArrayFrom(occlusionProbes); } } Graphics.DrawMeshInstanced( mesh, 0, material, matrices, 1023, block, ShadowCastingMode.On, true, 0, null, lightProbeVolume ? LightProbeUsage.UseProxyVolume : LightProbeUsage.CustomProvided, lightProbeVolume ); }
void Update() { if (_block == null) { _block = new MaterialPropertyBlock(); _block.SetVectorArray(_baseColorId, _baseColors); _block.SetFloatArray(_metallicId, _metallic); _block.SetFloatArray(_smoothnessId, _smoothness); if (!_lightProbeVolume) { var positions = new Vector3[1023]; for (int i = 0; i < _matrices.Length; i++) { positions[i] = _matrices[i].GetColumn(3); } var lightProbes = new SphericalHarmonicsL2[1023]; var occlusionProbes = new Vector4[1023]; LightProbes.CalculateInterpolatedLightAndOcclusionProbes( positions, lightProbes, occlusionProbes ); _block.CopySHCoefficientArraysFrom(lightProbes); _block.CopyProbeOcclusionArrayFrom(occlusionProbes); } } Graphics.DrawMeshInstanced( _mesh, submeshIndex: 0, _material, _matrices, count: 1023, _block, ShadowCastingMode.On, receiveShadows: true, layer: 0, camera: null, _lightProbeVolume ? LightProbeUsage.UseProxyVolume : LightProbeUsage.CustomProvided, _lightProbeVolume ); }