private static bool TryGetLocalLitPass(CustomPassVolume volume, ref PointCloudRenderPass pass) { if (volume.injectionPoint != LitInjectionPoint || volume.customPasses.Count != 1 || !(volume.customPasses[0] is PointCloudRenderPass p)) { return(false); } pass = p; // Don't bind camera color buffer when using lighting - it's going to use GBuffer instead anyway pass.targetColorBuffer = CustomPass.TargetBuffer.None; pass.targetDepthBuffer = CustomPass.TargetBuffer.Camera; return(true); }
void OnEnable() { m_Volume = target as CustomPassVolume; using (var o = new PropertyFetcher <CustomPassVolume>(serializedObject)) { m_SerializedPassVolume = new SerializedPassVolume { isGlobal = o.Find(x => x.isGlobal), injectionPoint = o.Find(x => x.injectionPoint), customPasses = o.Find(x => x.customPasses), }; } CreateReorderableList(m_SerializedPassVolume.customPasses); }
protected override void Initialize(SerializedProperty customPass) { // Header bools m_FilterFoldout = customPass.FindPropertyRelative("filterFoldout"); m_RendererFoldout = customPass.FindPropertyRelative("rendererFoldout"); m_PassFoldout = customPass.FindPropertyRelative("passFoldout"); m_TargetDepthBuffer = customPass.FindPropertyRelative("targetDepthBuffer"); // Filter props m_RenderQueue = customPass.FindPropertyRelative("renderQueueType"); m_LayerMask = customPass.FindPropertyRelative("layerMask"); m_ShaderPasses = customPass.FindPropertyRelative("passNames"); m_ShaderPass = customPass.FindPropertyRelative("shaderPass"); // Render options m_OverrideMaterial = customPass.FindPropertyRelative("overrideMaterial"); m_OverrideMaterialPassName = customPass.FindPropertyRelative("overrideMaterialPassName"); m_SortingCriteria = customPass.FindPropertyRelative("sortingCriteria"); // Depth options m_OverrideDepthState = customPass.FindPropertyRelative("overrideDepthState"); m_DepthCompareFunction = customPass.FindPropertyRelative("depthCompareFunction"); m_DepthWrite = customPass.FindPropertyRelative("depthWrite"); m_Volume = customPass.serializedObject.targetObject as CustomPassVolume; m_ShaderPassesList = new ReorderableList(null, m_ShaderPasses, true, true, true, true); m_ShaderPassesList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { var element = m_ShaderPassesList.serializedProperty.GetArrayElementAtIndex(index); var propRect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight); var labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 50; element.stringValue = EditorGUI.TextField(propRect, "Name", element.stringValue); EditorGUIUtility.labelWidth = labelWidth; }; m_ShaderPassesList.drawHeaderCallback = (Rect testHeaderRect) => { EditorGUI.LabelField(testHeaderRect, Styles.shaderPassFilter); }; }
void OnEnable() { m_Volume = target as CustomPassVolume; using (var o = new PropertyFetcher <CustomPassVolume>(serializedObject)) { m_SerializedPassVolume = new SerializedPassVolume { isGlobal = o.Find(x => x.isGlobal), injectionPoint = o.Find(x => x.injectionPoint), customPasses = o.Find(x => x.customPasses), fadeRadius = o.Find(x => x.fadeRadius), priority = o.Find(x => x.priority), }; } CreateReorderableList(m_SerializedPassVolume.customPasses); UpdateMaterialEditors(); }
/// <summary> /// Removes a custom pass volume from the active custom passes table /// </summary> /// <param name="pass">The custom pass volume to remove from the active custom passes table</param> private void RemovePass(CustomPassVolume pass) { GetActivePasses(); _activePassVolumes.Remove(pass); SetActivePasses(); }
/// <summary> /// Adds a custom pass volume to the active custom passes table /// </summary> /// <param name="pass">The custom pass volume to add to the active custom passes table</param> private void AddPass(CustomPassVolume pass) { GetActivePasses(); _activePassVolumes.Add(pass); SetActivePasses(); }
void Finish() { TrueSkyCamera trueSkyCamera; if (sequence == null) { // Build asset path and name (it has to be relative) string relativePath = UnityEngine.SceneManagement.SceneManager.GetActiveScene().path; string sequenceFilename = relativePath.Replace(".unity", "_sq.asset"); sequence = CustomAssetUtility.CreateAsset <Sequence>(sequenceFilename); } if (trueSky == null) { GameObject g = new GameObject("trueSky"); trueSky = g.AddComponent <trueSKY>(); } if (createAMainCamera) // if user has requested a main camera to be created (as none already) { GameObject MainCam = new GameObject("Main Camera"); MainCam.gameObject.AddComponent <Camera>(); MainCam.tag = "MainCamera"; mainCamera = MainCam.GetComponent <Camera>(); } if (multipleCameras) // if user has requested the script o be assigned to cameras { Camera[] cams = new Camera[Camera.allCamerasCount]; // find all cameras if (Camera.allCamerasCount >= 1) { Array.Copy(Camera.allCameras, cams, Camera.allCamerasCount); } for (int i = 0; i < cams.Length; i++) { trueSkyCamera = cams[i].gameObject.GetComponent <TrueSkyCamera>(); if (trueSkyCamera == null) { cams[i].gameObject.AddComponent <TrueSkyCamera>(); } } } if (mainCamera == null) // if mainCamera still = null, inform user script wasn't assigned + how to assign it { if (Camera.allCamerasCount < 1) { UnityEngine.Debug.LogWarning("Can't find any cameras for trueSky Camera script. Please add a camera manually and repeat the wizard to assign the script to the camera of your choice/all cameras. Alternatively, check the option to automatically create a main camera with the script assigned."); } else if (!multipleCameras) { UnityEngine.Debug.LogWarning("Can't find a main camera for trueSKy Camera script, but other cameras found. Repeat the wizard and assign the script to the camera of your choice/all cameras"); } } else { #if USING_HDRP simul.TrueSkyHDRPCustomPass trueSKYPreRefraction = new simul.TrueSkyHDRPCustomPass(); simul.TrueSkyHDRPCustomPass trueSKYPrePostProcess = new simul.TrueSkyHDRPCustomPass(); CustomPassVolume trueSKYPassBeforePreRefraction = trueSky.gameObject.GetComponent <CustomPassVolume>(); if (trueSKYPassBeforePreRefraction == null) { trueSKYPreRefraction.name = "trueSKY - Before Pre Refraction(Main Render)"; trueSKYPassBeforePreRefraction = trueSky.gameObject.AddComponent <CustomPassVolume>(); trueSKYPassBeforePreRefraction.injectionPoint = CustomPassInjectionPoint.BeforePreRefraction; trueSKYPassBeforePreRefraction.customPasses.Add(trueSKYPreRefraction); CustomPassVolume trueSKYPassBeforePostProcess; trueSKYPrePostProcess.name = "trueSKY - Before Post Process(Translucent Effects)"; trueSKYPassBeforePostProcess = trueSky.gameObject.AddComponent <CustomPassVolume>(); trueSKYPassBeforePostProcess.injectionPoint = CustomPassInjectionPoint.BeforePostProcess; trueSKYPassBeforePostProcess.customPasses.Add(trueSKYPrePostProcess); } if (UnityEngine.Rendering.GraphicsSettings.allConfiguredRenderPipelines.Length > 0) { trueSky.HDRP_RenderPipelineAsset = UnityEngine.Rendering.GraphicsSettings.allConfiguredRenderPipelines[0]; } #else trueSkyCamera = mainCamera.gameObject.GetComponent <TrueSkyCamera>(); if (trueSkyCamera == null) { mainCamera.gameObject.AddComponent <TrueSkyCamera>(); } #endif } if (createCubemapProbe) { // must be after trueSKY obj assigned, in case assigning probe to this instead of mainCam UnityEngine.Object[] objects = FindObjectsOfType(typeof(TrueSkyCubemapProbe)); if (trueSky.gameObject.GetComponent <TrueSkyCubemapProbe>() != null) { DestroyImmediate(trueSky.gameObject.GetComponent <TrueSkyCubemapProbe>()); } trueSky.gameObject.AddComponent <TrueSkyCubemapProbe>(); Material trueSKYSkyboxMat = Resources.Load("trueSKYSkybox", typeof(Material)) as Material; RenderSettings.skybox = trueSKYSkyboxMat; } // If there is not light on the scene, add one: if (lightGameObject == null) { lightGameObject = new GameObject("TrueSkyDirectionalLight"); Light dirLight = lightGameObject.AddComponent <Light>(); dirLight.type = LightType.Directional; lightComponent = lightGameObject.AddComponent <TrueSkyDirectionalLight>(); } // If there is a light, but without the component, add it: if (lightComponent == null) { lightComponent = lightGameObject.AddComponent <TrueSkyDirectionalLight>(); } RenderSettings.sun = lightGameObject.GetComponent <Light>(); #if USING_HDRP lightComponent.Units = TrueSkyDirectionalLight.LightUnits.Photometric; #else lightComponent.Units = TrueSkyDirectionalLight.LightUnits.Radiometric; #endif if (removeFog) { RenderSettings.fog = false; } if (removeSkybox && mainCamera != null) { if (mainCamera.clearFlags != CameraClearFlags.SolidColor) { mainCamera.clearFlags = CameraClearFlags.SolidColor; mainCamera.backgroundColor = Color.black; } } // Set the Near and Far clipping planes on the main camera. mainCamera.nearClipPlane = 0.1f; mainCamera.farClipPlane = 300000.0f; // Now the sequence must be assigned to the trueSKY object. trueSky.sequence = sequence; trueSky.TrueSKYTime = 12.0F; }