private void SetDefaultConstantBuffers(EffectMaterial material) { void setDefaultConstantBuffer(string name, DeviceBuffer buffer) { var parameter = material.Effect.GetParameter(name, throwIfMissing: false); if (parameter != null) { material.SetProperty(name, buffer); } } setDefaultConstantBuffer("GlobalConstantsShared", _globalConstantBufferShared.Buffer); setDefaultConstantBuffer("GlobalConstantsVS", _globalConstantBufferVS.Buffer); setDefaultConstantBuffer("GlobalConstantsPS", _globalConstantBufferPS.Buffer); switch (material.LightingType) { case LightingType.Terrain: setDefaultConstantBuffer("Global_LightingConstantsVS", _globalLightingVSTerrainBuffer.Buffer); setDefaultConstantBuffer("Global_LightingConstantsPS", _globalLightingPSTerrainBuffer.Buffer); break; case LightingType.Object: setDefaultConstantBuffer("Global_LightingConstantsVS", _globalLightingVSObjectBuffer.Buffer); setDefaultConstantBuffer("Global_LightingConstantsPS", _globalLightingPSObjectBuffer.Buffer); break; } }