protected void RenderCommonProbeFields(bool useMiniStyle) { bool isDeferredRenderingPath = SceneView.IsUsingDeferredRenderingPath(); bool isDeferredReflections = isDeferredRenderingPath && (GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.Disabled); m_Probes.RenderReflectionProbeUsage(useMiniStyle, isDeferredRenderingPath, isDeferredReflections); m_Probes.RenderProbeAnchor(useMiniStyle); }
private void OnPreRender() { this.checkMaterials(true); if (this.m_targetCamera != null) { bool flag = GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.Disabled; if (this.m_prevPerPixelNormals != this.PerPixelNormals || this.m_prevApplyMethod != this.ApplyMethod || this.m_prevDeferredReflections != flag || this.m_commandBuffer_Occlusion.cmdBuffer == null || this.m_commandBuffer_Apply.cmdBuffer == null) { CameraEvent aCameraEvent = CameraEvent.BeforeImageEffectsOpaque; if (this.ApplyMethod == AmplifyOcclusionBase.ApplicationMethod.Deferred) { aCameraEvent = ((!flag) ? CameraEvent.BeforeLighting : CameraEvent.BeforeReflections); } this.createCommandBuffer(ref this.m_commandBuffer_Occlusion, "AmplifyOcclusion_Compute", aCameraEvent); this.createCommandBuffer(ref this.m_commandBuffer_Apply, "AmplifyOcclusion_Apply", aCameraEvent); this.m_prevPerPixelNormals = this.PerPixelNormals; this.m_prevApplyMethod = this.ApplyMethod; this.m_prevDeferredReflections = flag; this.m_paramsChanged = true; } if (this.m_commandBuffer_Occlusion.cmdBuffer != null && this.m_commandBuffer_Apply.cmdBuffer != null) { this.m_curStepIdx = (this.m_sampleStep & 1u); this.UpdateGlobalShaderConstants(); this.checkParamsChanged(); this.UpdateGlobalShaderConstants_AmbientOcclusion(); this.UpdateGlobalShaderConstants_Matrices(); if (this.m_paramsChanged) { this.m_commandBuffer_Occlusion.cmdBuffer.Clear(); this.commandBuffer_FillComputeOcclusion(this.m_commandBuffer_Occlusion.cmdBuffer); } this.m_commandBuffer_Apply.cmdBuffer.Clear(); if (this.ApplyMethod == AmplifyOcclusionBase.ApplicationMethod.Debug) { this.commandBuffer_FillApplyDebug(this.m_commandBuffer_Apply.cmdBuffer); } else if (this.ApplyMethod == AmplifyOcclusionBase.ApplicationMethod.PostEffect) { this.commandBuffer_FillApplyPostEffect(this.m_commandBuffer_Apply.cmdBuffer); } else { bool logTarget = !this.m_HDR; this.commandBuffer_FillApplyDeferred(this.m_commandBuffer_Apply.cmdBuffer, logTarget); } this.updateParams(); this.m_sampleStep += 1u; } } }
private static void FixRenderingPath() { if (renderingPath != RenderingPath.DeferredShading) { Object playerSettings = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset").FirstOrDefault(); if (playerSettings) { Undo.RecordObject(playerSettings, "Change Project Settings"); } renderingPath = RenderingPath.DeferredShading; } BuiltinShaderMode currentShadingShaderMode = GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredShading); BuiltinShaderMode currentReflectionsShaderMode = GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections); bool needsShaderUpdate = deferredShadingShader != neoFurDeferredShadingShader || deferredReflectionsShader != deferredReflectionsShader; needsShaderUpdate |= currentShadingShaderMode != BuiltinShaderMode.UseCustom || currentReflectionsShaderMode != BuiltinShaderMode.UseCustom; if (needsShaderUpdate) { string warningMessage = ""; if (currentShadingShaderMode == BuiltinShaderMode.UseCustom && deferredShadingShader && deferredShadingShader != neoFurDeferredShadingShader) { warningMessage += "Deferred shading shader is currently set to " + deferredShadingShader.name + ". It will be changed to a neofur deferred shading shader.\n"; } if (currentReflectionsShaderMode == BuiltinShaderMode.UseCustom && deferredReflectionsShader && deferredReflectionsShader != neoFurDeferredReflectionsShader) { warningMessage += "Deferred reflections shader is currently set to " + deferredReflectionsShader.name + ". It will be changed to a neofur deferred reflections shader.\n"; } if (warningMessage != "") { warningMessage += "Do you want to change shader references listed above?"; if (!EditorUtility.DisplayDialog("Deferred rendering shader conflict.", warningMessage, "Yes", "No")) { return; } } Object graphicsSettings = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/GraphicsSettings.asset").FirstOrDefault(); if (graphicsSettings) { Undo.RecordObject(graphicsSettings, "Change Project Settings"); } deferredShadingShader = neoFurDeferredShadingShader; deferredReflectionsShader = neoFurDeferredReflectionsShader; } }
internal void OnGUI(UnityEngine.Object[] selection, Renderer renderer, bool useMiniStyle) { int selectionCount = 1; bool flag = SceneView.IsUsingDeferredRenderingPath(); bool flag2 = flag && GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.Disabled; bool usesLightMaps = false; if (selection != null) { for (int i = 0; i < selection.Length; i++) { UnityEngine.Object @object = selection[i]; if (LightmapEditorSettings.IsLightmappedOrDynamicLightmappedForRendering((Renderer)@object)) { usesLightMaps = true; break; } } selectionCount = selection.Length; } this.RenderLightProbeUsage(selectionCount, renderer, useMiniStyle, usesLightMaps); this.RenderReflectionProbeUsage(useMiniStyle, flag, flag2); bool flag3 = this.RenderProbeAnchor(useMiniStyle); if (flag3) { bool flag4 = !this.m_ReflectionProbeUsage.hasMultipleDifferentValues && this.m_ReflectionProbeUsage.intValue != 0; if (flag4) { if (!flag2) { renderer.GetClosestReflectionProbes(this.m_BlendInfo); RendererEditorBase.Probes.ShowClosestReflectionProbes(this.m_BlendInfo); } } } bool flag5 = !this.m_ReceiveShadows.hasMultipleDifferentValues && this.m_ReceiveShadows.boolValue; if ((flag && flag5) || (flag2 && flag3)) { EditorGUILayout.HelpBox(this.m_DeferredNote.text, MessageType.Info); } this.RenderLightProbeProxyVolumeWarningNote(renderer, selectionCount); }
public static int GetShaderMode_s(IntPtr l) { int result; try { BuiltinShaderType type; LuaObject.checkEnum <BuiltinShaderType>(l, 1, out type); BuiltinShaderMode shaderMode = GraphicsSettings.GetShaderMode(type); LuaObject.pushValue(l, true); LuaObject.pushEnum(l, (int)shaderMode); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public override void OnInspectorGUI() { base.serializedObject.Update(); if (base.targets.Length == 1) { this.DoToolbar(); } this.m_ShowProbeModeRealtimeOptions.target = (this.reflectionProbeMode == ReflectionProbeMode.Realtime); this.m_ShowProbeModeCustomOptions.target = (this.reflectionProbeMode == ReflectionProbeMode.Custom); EditorGUILayout.IntPopup(this.m_Mode, ReflectionProbeEditor.Styles.reflectionProbeMode, ReflectionProbeEditor.Styles.reflectionProbeModeValues, ReflectionProbeEditor.Styles.typeText, new GUILayoutOption[0]); if (!this.m_Mode.hasMultipleDifferentValues) { EditorGUI.indentLevel++; if (EditorGUILayout.BeginFadeGroup(this.m_ShowProbeModeCustomOptions.faded)) { EditorGUILayout.PropertyField(this.m_RenderDynamicObjects, ReflectionProbeEditor.Styles.renderDynamicObjects, new GUILayoutOption[0]); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = this.m_CustomBakedTexture.hasMultipleDifferentValues; UnityEngine.Object objectReferenceValue = EditorGUILayout.ObjectField(ReflectionProbeEditor.Styles.customCubemapText, this.m_CustomBakedTexture.objectReferenceValue, typeof(Cubemap), false, new GUILayoutOption[0]); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { this.m_CustomBakedTexture.objectReferenceValue = objectReferenceValue; } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(this.m_ShowProbeModeRealtimeOptions.faded)) { EditorGUILayout.PropertyField(this.m_RefreshMode, ReflectionProbeEditor.Styles.refreshMode, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_TimeSlicingMode, ReflectionProbeEditor.Styles.timeSlicing, new GUILayoutOption[0]); EditorGUILayout.Space(); } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel--; } EditorGUILayout.Space(); GUILayout.Label(ReflectionProbeEditor.Styles.runtimeSettingsHeader, new GUILayoutOption[0]); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(this.m_Importance, ReflectionProbeEditor.Styles.importanceText, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_IntensityMultiplier, ReflectionProbeEditor.Styles.intensityText, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_BoxProjection, ReflectionProbeEditor.Styles.boxProjectionText, new GUILayoutOption[0]); bool flag = SceneView.IsUsingDeferredRenderingPath(); bool flag2 = flag && GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.Disabled; using (new EditorGUI.DisabledScope(!flag2)) { EditorGUILayout.PropertyField(this.m_BlendDistance, ReflectionProbeEditor.Styles.blendDistanceText, new GUILayoutOption[0]); } if (EditorGUILayout.BeginFadeGroup(this.m_ShowBoxOptions.faded)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(this.m_BoxSize, ReflectionProbeEditor.Styles.sizeText, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_BoxOffset, ReflectionProbeEditor.Styles.centerText, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { Vector3 vector3Value = this.m_BoxOffset.vector3Value; Vector3 vector3Value2 = this.m_BoxSize.vector3Value; if (this.ValidateAABB(ref vector3Value, ref vector3Value2)) { this.m_BoxOffset.vector3Value = vector3Value; this.m_BoxSize.vector3Value = vector3Value2; } } } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel--; EditorGUILayout.Space(); GUILayout.Label(ReflectionProbeEditor.Styles.captureCubemapHeaderText, new GUILayoutOption[0]); EditorGUI.indentLevel++; EditorGUILayout.IntPopup(this.m_Resolution, ReflectionProbeEditor.Styles.renderTextureSizes.ToArray(), ReflectionProbeEditor.Styles.renderTextureSizesValues.ToArray(), ReflectionProbeEditor.Styles.resolutionText, new GUILayoutOption[] { GUILayout.MinWidth(40f) }); EditorGUILayout.PropertyField(this.m_HDR, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_ShadowDistance, new GUILayoutOption[0]); EditorGUILayout.IntPopup(this.m_ClearFlags, ReflectionProbeEditor.Styles.clearFlags, ReflectionProbeEditor.Styles.clearFlagsValues, ReflectionProbeEditor.Styles.clearFlagsText, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_BackgroundColor, ReflectionProbeEditor.Styles.backgroundColorText, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_CullingMask, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_UseOcclusionCulling, new GUILayoutOption[0]); EditorGUILayout.PropertiesField(EditorGUI.s_ClipingPlanesLabel, this.m_NearAndFarProperties, EditorGUI.s_NearAndFarLabels, 35f, new GUILayoutOption[0]); EditorGUI.indentLevel--; EditorGUILayout.Space(); if (base.targets.Length == 1) { ReflectionProbe reflectionProbe = (ReflectionProbe)base.target; if (reflectionProbe.mode == ReflectionProbeMode.Custom && reflectionProbe.customBakedTexture != null) { Cubemap cubemap = reflectionProbe.customBakedTexture as Cubemap; if (cubemap && cubemap.mipmapCount == 1) { EditorGUILayout.HelpBox("No mipmaps in the cubemap, Smoothness value in Standard shader will be ignored.", MessageType.Warning); } } } this.DoBakeButton(); EditorGUILayout.Space(); base.serializedObject.ApplyModifiedProperties(); }
public static bool IsDeferredReflections() { return(GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.Disabled); }
void OnPreRender() { Profiler.BeginSample("AO - OnPreRender"); checkMaterials(true); if (m_targetCamera != null) { #if UNITY_EDITOR if ((m_targetCamera.cameraType == CameraType.SceneView) && (((PerPixelNormals == PerPixelNormalSource.GBuffer) && (m_targetCamera.orthographic == true)) || (PerPixelNormals == PerPixelNormalSource.Camera) && (SceneView.lastActiveSceneView.m_SceneLighting == false))) { PerPixelNormals = PerPixelNormalSource.None; } #endif bool deferredReflections = (GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.Disabled); if ((m_prevPerPixelNormals != PerPixelNormals) || (m_prevApplyMethod != ApplyMethod) || (m_prevDeferredReflections != deferredReflections) || (m_commandBuffer_Parameters.cmdBuffer == null) || (m_commandBuffer_Occlusion.cmdBuffer == null) || (m_commandBuffer_Apply.cmdBuffer == null) ) { CameraEvent cameraStage = CameraEvent.BeforeImageEffectsOpaque; if (ApplyMethod == ApplicationMethod.Deferred) { cameraStage = deferredReflections ? CameraEvent.BeforeReflections : CameraEvent.BeforeLighting; } createCommandBuffer(ref m_commandBuffer_Parameters, "AmplifyOcclusion_Parameters_" + m_myIDstring, cameraStage); createCommandBuffer(ref m_commandBuffer_Occlusion, "AmplifyOcclusion_Compute_" + m_myIDstring, cameraStage); createCommandBuffer(ref m_commandBuffer_Apply, "AmplifyOcclusion_Apply_" + m_myIDstring, cameraStage); m_prevPerPixelNormals = PerPixelNormals; m_prevApplyMethod = ApplyMethod; m_prevDeferredReflections = deferredReflections; m_paramsChanged = true; } if ((m_commandBuffer_Parameters.cmdBuffer != null) && (m_commandBuffer_Occlusion.cmdBuffer != null) && (m_commandBuffer_Apply.cmdBuffer != null)) { if (AmplifyOcclusionCommon.IsStereoMultiPassEnabled(m_targetCamera) == true) { uint curStepIdx = (m_sampleStep >> 1) & 1; uint curEyeIdx = (m_sampleStep & 1); m_curTemporalIdx = (curEyeIdx * 2) + (0 + curStepIdx); m_prevTemporalIdx = (curEyeIdx * 2) + (1 - curStepIdx); } else { uint curStepIdx = m_sampleStep & 1; m_curTemporalIdx = 0 + curStepIdx; m_prevTemporalIdx = 1 - curStepIdx; } m_commandBuffer_Parameters.cmdBuffer.Clear(); UpdateGlobalShaderConstants(m_commandBuffer_Parameters.cmdBuffer); UpdateGlobalShaderConstants_Matrices(m_commandBuffer_Parameters.cmdBuffer); UpdateGlobalShaderConstants_AmbientOcclusion(m_commandBuffer_Parameters.cmdBuffer); checkParamsChanged(); if (m_paramsChanged) { m_commandBuffer_Occlusion.cmdBuffer.Clear(); commandBuffer_FillComputeOcclusion(m_commandBuffer_Occlusion.cmdBuffer); } m_commandBuffer_Apply.cmdBuffer.Clear(); if (ApplyMethod == ApplicationMethod.Debug) { commandBuffer_FillApplyDebug(m_commandBuffer_Apply.cmdBuffer); } else { if (ApplyMethod == ApplicationMethod.PostEffect) { commandBuffer_FillApplyPostEffect(m_commandBuffer_Apply.cmdBuffer); } else { bool logTarget = !m_HDR; commandBuffer_FillApplyDeferred(m_commandBuffer_Apply.cmdBuffer, logTarget); } } updateParams(); m_sampleStep++; // No clamp, free running counter } } else { m_targetCamera = GetComponent <Camera>(); Update(); #if UNITY_EDITOR if (m_targetCamera.cameraType != CameraType.SceneView) { System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(T); if (array.Length > 0) { EditorWindow gameView = (EditorWindow)array[0]; gameView.Focus(); } } #endif } Profiler.EndSample(); }
void OnPreRender() { Profiler.BeginSample("AO - OnPreRender"); checkMaterials(true); if (m_targetCamera != null) { bool deferredReflections = (GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.Disabled); if ((m_prevPerPixelNormals != PerPixelNormals) || (m_prevApplyMethod != ApplyMethod) || (m_prevDeferredReflections != deferredReflections) || (m_commandBuffer_Occlusion.cmdBuffer == null) || (m_commandBuffer_Apply.cmdBuffer == null) ) { CameraEvent cameraStage = CameraEvent.BeforeImageEffectsOpaque; if (ApplyMethod == ApplicationMethod.Deferred) { cameraStage = deferredReflections ? CameraEvent.BeforeReflections : CameraEvent.BeforeLighting; } createCommandBuffer(ref m_commandBuffer_Occlusion, "AmplifyOcclusion_Compute", cameraStage); createCommandBuffer(ref m_commandBuffer_Apply, "AmplifyOcclusion_Apply", cameraStage); m_prevPerPixelNormals = PerPixelNormals; m_prevApplyMethod = ApplyMethod; m_prevDeferredReflections = deferredReflections; m_paramsChanged = true; } if ((m_commandBuffer_Occlusion.cmdBuffer != null) && (m_commandBuffer_Apply.cmdBuffer != null)) { m_curStepIdx = m_sampleStep & 1; UpdateGlobalShaderConstants(); checkParamsChanged(); UpdateGlobalShaderConstants_AmbientOcclusion(); UpdateGlobalShaderConstants_Matrices(); if (m_paramsChanged) { m_commandBuffer_Occlusion.cmdBuffer.Clear(); commandBuffer_FillComputeOcclusion(m_commandBuffer_Occlusion.cmdBuffer); } m_commandBuffer_Apply.cmdBuffer.Clear(); if (ApplyMethod == ApplicationMethod.Debug) { commandBuffer_FillApplyDebug(m_commandBuffer_Apply.cmdBuffer); } else { if (ApplyMethod == ApplicationMethod.PostEffect) { commandBuffer_FillApplyPostEffect(m_commandBuffer_Apply.cmdBuffer); } else { bool logTarget = !m_HDR; commandBuffer_FillApplyDeferred(m_commandBuffer_Apply.cmdBuffer, logTarget); } } updateParams(); m_sampleStep++; // No clamp, free running counter } } Profiler.EndSample(); }
public bool OnGUI() { if (Event.current.type == EventType.ValidateCommand) { if (Event.current.commandName == "UndoRedoPerformed") { Repaint(); } } if (renderingPath != RenderingPath.DeferredShading) { issueCache.Add(new Issue("Rendering path is set to " + renderingPath + ". <b>" + RenderingPath.DeferredShading + "</b> rendering path is recommended.", FixRenderingPath, MessageType.Warning)); } else { bool state = deferredShadingShader != neoFurDeferredShadingShader; state |= GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredShading) != BuiltinShaderMode.UseCustom; state |= deferredReflectionsShader != neoFurDeferredReflectionsShader; state |= GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.UseCustom; if (state) { issueCache.Add(new Issue("When using Deferred Shading, <b>Deferred</b> shading and reflection <b>shaders</b> must be changed to NeoFur versions in graphics settings.", FixRenderingPath, MessageType.Error)); } } if (colorSpace != ColorSpace.Linear) { issueCache.Add(new Issue("Color space is currently set to " + colorSpace + ". <b>" + ColorSpace.Linear + "</b> color space is recommended.", FixColorSpace, MessageType.Warning)); } bool returnValue = true; if (NeoFurPluginInfo.buildType == PluginBuildType.Debug) { returnValue = false; EditorGUILayout.HelpBox("NeoFurUnityPlugin is build in Debug mode. Do not ship this.", MessageType.Warning); } if (NeoFurEditorPluginInfo.buildType == PluginBuildType.Debug) { returnValue = false; EditorGUILayout.HelpBox("EditorPlugin is build in Debug mode. Do not ship this.", MessageType.Warning); } if (issueCache.Count > 0) { StringBuilder sb = new StringBuilder(); bool hasError = issueCache.Any(v => v.messageType == MessageType.Error); MessageType messageType = MessageType.Warning; if (hasError) { sb.Append("<b>The following critical issues have been detected. They must be resolved.</b>\n\n"); issueCache.RemoveAll(v => v.messageType != MessageType.Error); messageType = MessageType.Error; } else { //Dont show warnings if the user hid them, but do show errors. if (!forceShowIssues && !NeoFurEditorSettings.instance.showInspectorNotifiations) { return(true); } sb.Append("<b>The following issues have been detected. For best results they should be resolved.</b>\n\n"); } for (int i = 0; i < issueCache.Count; i++) { Issue issue = issueCache[i]; sb.Append("● "); sb.Append(issue.message); if (i < issueCache.Count - 1) { sb.Append("\n\n"); } } //Extra space for button. sb.Append("\n\n\n"); bool originalRichText = false; GUIStyle helpBoxStyle = GUI.skin.GetStyle("HelpBox"); if (helpBoxStyle != null) { originalRichText = helpBoxStyle.richText; helpBoxStyle.richText = true; } EditorGUILayout.HelpBox(sb.ToString(), messageType); if (helpBoxStyle != null) { helpBoxStyle.richText = originalRichText; } //Put button inside helpbox. GUILayout.Space(-30); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Fix Issues Now")) { foreach (var issue in issueCache) { issue.fixButton?.Invoke(); } } EditorGUILayout.Space(); if (!hasError) { //Only show hide button for warnings. if (!forceShowIssues && GUILayout.Button("Hide Issues")) { Undo.RecordObject(NeoFurEditorSettings.instance, "Hide NeoFur Inspector Issues"); NeoFurEditorSettings.instance.showInspectorNotifiations = false; NeoFurEditorSettings.instance.Save(); } EditorGUILayout.Space(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); } returnValue &= issueCache.Count == 0; issueCache.Clear(); return(returnValue); }