public override void Dispose() { base.Dispose(); Shader.globalRenderPipeline = ""; SupportedRenderingFeatures.active = new SupportedRenderingFeatures(); #if UNITY_EDITOR SceneViewDrawMode.ResetDrawMode(); #endif m_Renderer.Dispose(); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); Shader.globalRenderPipeline = ""; SupportedRenderingFeatures.active = new SupportedRenderingFeatures(); #if UNITY_EDITOR SceneViewDrawMode.ResetDrawMode(); #endif Lightmapping.ResetDelegate(); CameraCaptureBridge.enabled = false; }
public sealed override void Dispose() { base.Dispose(); Shader.globalRenderPipeline = ""; SupportedRenderingFeatures.active = new SupportedRenderingFeatures(); #if UNITY_EDITOR SceneViewDrawMode.ResetDrawMode(); #endif renderer.Dispose(); Lightmapping.ResetDelegate(); }
static void SetSupportedRenderingFeatures() { #if UNITY_EDITOR SupportedRenderingFeatures.active = new SupportedRenderingFeatures() { reflectionProbeSupportFlags = SupportedRenderingFeatures.ReflectionProbeSupportFlags.None, defaultMixedLightingMode = SupportedRenderingFeatures.LightmapMixedBakeMode.Subtractive, supportedMixedLightingModes = SupportedRenderingFeatures.LightmapMixedBakeMode.Subtractive, supportedLightmapBakeTypes = LightmapBakeType.Baked | LightmapBakeType.Mixed, supportedLightmapsModes = LightmapsMode.CombinedDirectional | LightmapsMode.NonDirectional, rendererSupportsLightProbeProxyVolumes = false, rendererSupportsMotionVectors = false, rendererSupportsReceiveShadows = false, rendererSupportsReflectionProbes = true }; SceneViewDrawMode.SetupDrawMode(); #endif }
public static void Render(ScriptableRenderContext context, IEnumerable <Camera> cameras) { //************************** SetRenderingFeatures **************************************** #if UNITY_EDITOR SupportedRenderingFeatures.active = new SupportedRenderingFeatures() { reflectionProbeSupportFlags = SupportedRenderingFeatures.ReflectionProbeSupportFlags.None, defaultMixedLightingMode = SupportedRenderingFeatures.LightmapMixedBakeMode.Subtractive, supportedMixedLightingModes = SupportedRenderingFeatures.LightmapMixedBakeMode.Subtractive, supportedLightmapBakeTypes = LightmapBakeType.Baked | LightmapBakeType.Mixed, supportedLightmapsModes = LightmapsMode.CombinedDirectional | LightmapsMode.NonDirectional, rendererSupportsLightProbeProxyVolumes = false, rendererSupportsMotionVectors = false, rendererSupportsReceiveShadows = true, rendererSupportsReflectionProbes = true }; SceneViewDrawMode.SetupDrawMode(); #endif // ////////////////////////////////////////////////////////////////////////////////// foreach (Camera camera in cameras) { //************************** Culling **************************************** ScriptableCullingParameters cullingParams; if (!CullResults.GetCullingParameters(camera, out cullingParams)) { continue; } CullResults cull = new CullResults(); CullResults.Cull(ref cullingParams, context, ref cull); //************************** Cam Properties ********************************** context.SetupCameraProperties(camera); //************************** Clear Flags ************************************ CommandBuffer cmd = new CommandBuffer(); cmd.name = "Clear Flag"; ClearFlag(cmd, camera); context.ExecuteCommandBuffer(cmd); cmd.Release(); //************************** Lighting Variables ***************************** CommandBuffer cmdLighting = new CommandBuffer(); cmdLighting.name = "Lighting variable"; int additionalLightSet = 0; int mainLightIndex = -1; for (int i = 0; i < cull.visibleLights.Count; i++) { VisibleLight light = cull.visibleLights[i]; if (mainLightIndex == -1) //Directional light { if (light.lightType == LightType.Directional) { cmdLighting.SetGlobalVector("_LightColor0", light.light.color); Vector4 dir = light.localToWorld.GetColumn(2); cmdLighting.SetGlobalVector("_WorldSpaceLightPos0", new Vector4(-dir.x, -dir.y, -dir.z, 0)); mainLightIndex = i; } } else { additionalLightSet++; continue;//so far just do only 1 directional light } } context.ExecuteCommandBuffer(cmdLighting); cmdLighting.Release(); //************************** Draw Settings ************************************ FilterRenderersSettings filterSettings = new FilterRenderersSettings(true); DrawRendererSettings drawSettingsDefault = new DrawRendererSettings(camera, passNameDefault); drawSettingsDefault.rendererConfiguration = renderConfig; drawSettingsDefault.SetShaderPassName(5, m_UnlitPassName); DrawRendererSettings drawSettingsBase = new DrawRendererSettings(camera, passNameBase); drawSettingsBase.rendererConfiguration = renderConfig; DrawRendererSettings drawSettingsAdd = new DrawRendererSettings(camera, passNameAdd); drawSettingsAdd.rendererConfiguration = renderConfig; DrawRendererSettings drawSettingsShadow = new DrawRendererSettings(camera, passNameShadow); //DrawRendererSettings drawSettingsMeta = new DrawRendererSettings(camera, passNameMeta); //************************** Skybox ************************************ if (camera.clearFlags == CameraClearFlags.Skybox) { context.DrawSkybox(camera); } //************************** Opaque ************************************ // Opaque filterSettings.renderQueueRange = RenderQueueRange.opaque; // Draw OPAQUE objects using DEFAULT pass drawSettingsDefault.sorting.flags = SortFlags.CommonOpaque; context.DrawRenderers(cull.visibleRenderers, ref drawSettingsDefault, filterSettings); // Draw OPAQUE objects using BASE pass drawSettingsBase.sorting.flags = SortFlags.CommonOpaque; context.DrawRenderers(cull.visibleRenderers, ref drawSettingsBase, filterSettings); // Draw OPAQUE objects using ADD pass drawSettingsAdd.sorting.flags = SortFlags.CommonOpaque; context.DrawRenderers(cull.visibleRenderers, ref drawSettingsAdd, filterSettings); //************************** Transparent ************************************ filterSettings.renderQueueRange = RenderQueueRange.transparent; // Draw TRANSPARENT objects using DEFAULT pass drawSettingsDefault.sorting.flags = SortFlags.CommonTransparent; context.DrawRenderers(cull.visibleRenderers, ref drawSettingsDefault, filterSettings); // Draw TRANSPARENT objects using BASE pass drawSettingsBase.sorting.flags = SortFlags.CommonTransparent; context.DrawRenderers(cull.visibleRenderers, ref drawSettingsBase, filterSettings); // Draw TRANSPARENT objects using ADD pass drawSettingsAdd.sorting.flags = SortFlags.CommonTransparent; context.DrawRenderers(cull.visibleRenderers, ref drawSettingsAdd, filterSettings); context.Submit(); } }