예제 #1
0
    private void SetBatchingType(BatchingType newBatchingType)
    {
      // Reset scene.
      _graphicsScreen.Scene.Children.Remove(_originalMeshNodes);
      _graphicsScreen.Scene.Children.Remove(_staticInstancingNodes);
      _graphicsScreen.Scene.Children.Remove(_staticBatchingNodes);

      _batchingType = newBatchingType;
      if (newBatchingType == BatchingType.NoBatching)
      {
        // Strategy A: Add many individual mesh nodes to scene. Disable dynamic hardware instancing.
        _graphicsScreen.Scene.Children.Add(_originalMeshNodes);
        _graphicsScreen.MeshRenderer.EnableInstancing = false;
      }
      else if (newBatchingType == BatchingType.DynamicHardwareInstancing)
      {
        // Strategy B: Many individual nodes. MeshRenderer performs dynamic hardware instancing.
        _graphicsScreen.Scene.Children.Add(_originalMeshNodes);
        _graphicsScreen.MeshRenderer.EnableInstancing = true;
      }
      else if (newBatchingType == BatchingType.StaticHardwareInstancing)
      {
        // Strategy C: A few InstancingMeshNodes.
        _graphicsScreen.Scene.Children.Add(_staticInstancingNodes);
      }
      else if (newBatchingType == BatchingType.StaticBatching)
      {
        // Strategy D: A few merged MeshNodes.
        _graphicsScreen.Scene.Children.Add(_staticBatchingNodes);
      }
    }
예제 #2
0
    private void ChangeBatchingType(BatchingType batchingTypeEnums)
    {
        switch (batchingTypeEnums)
        {
        case BatchingType.NoBatching:
            inDynamicBatching.boolValue = false;
            gpuInstancing.boolValue     = false;
            serializedObject.ApplyModifiedProperties();
            break;

        case BatchingType.UseGpu:
            inDynamicBatching.boolValue = false;
            gpuInstancing.boolValue     = true;
            serializedObject.ApplyModifiedProperties();
            break;

        case BatchingType.UseDynamic:
            inDynamicBatching.boolValue = true;
            gpuInstancing.boolValue     = false;
            serializedObject.ApplyModifiedProperties();
            break;

        default:
            break;
        }
    }
예제 #3
0
    public override void OnInspectorGUI()
    {
        //Header
        Texture2D headerImage = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/Scripts/RenderPipeline/Sources/Textures/MobileBaseSRP_Header.psd", typeof(Texture2D));

        headerContent = new GUIContent(headerImage);

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(headerContent, GUILayout.MaxHeight(30f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        EditorGUILayout.LabelField(headerVersion, EditorStyles.miniLabel);
        GUILayout.EndHorizontal();


        //Common Setup Block
        CustomUi.GuiLineSeparator(1);
        commonPipelineProps = CustomUi.FoldOut("Common Pipeline properties", commonPipelineProps);
        EditorGUILayout.Separator();

        if (commonPipelineProps)
        {
            shaderErrorMaterial     = serializedObject.FindProperty("ShaderErrorMaterial");
            useLinearLightIntensity = serializedObject.FindProperty("UseLinearLightIntensity");
            defaultMaterialOverride = serializedObject.FindProperty("defaultMaterialOverride");

            //Shader Error material field
            EditorGUILayout.ObjectField(shaderErrorMaterial);
            if (shaderErrorMaterial.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("Warning: Shader Error material is not assigned. Please assign one!", MessageType.Warning);
            }

            EditorGUILayout.ObjectField(defaultMaterialOverride);
            if (defaultMaterialOverride.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("Warning: Default Unlit material is not assigned. Please assign one!", MessageType.Warning);
            }
            serializedObject.ApplyModifiedProperties();

            //Light Attenuation type selector
            lightColorSpaceEnums = (LightColorSpace)EditorGUILayout.EnumPopup("Light Attenuation Formule:", lightColorSpaceEnums);
            ChangeLightAttenuationType(lightColorSpaceEnums);
        }

        //Batching Setup Block
        CustomUi.GuiLineSeparator(2);
        batchingProps = CustomUi.FoldOut("Batching Settings", batchingProps);
        EditorGUILayout.Separator();
        if (batchingProps)
        {
            gpuInstancing     = serializedObject.FindProperty("GpuInstancing");
            inDynamicBatching = serializedObject.FindProperty("InDynamicBatching");
            batchingTypeEnums = (BatchingType)EditorGUILayout.EnumPopup("Batching Type:", batchingTypeEnums);
            ChangeBatchingType(batchingTypeEnums);
        }

        //Render Target Setup Block
        CustomUi.GuiLineSeparator(2);
        renderTargetProps = CustomUi.FoldOut("Render Target Properties", renderTargetProps);
        EditorGUILayout.Separator();

        if (renderTargetProps)
        {
            renderMesh     = serializedObject.FindProperty("RenderMesh");
            renderMaterial = serializedObject.FindProperty("RenderMaterial");
            EditorGUILayout.ObjectField(renderMesh, meshTargetContent);
            if (renderMesh.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("Warning: Target mesh filter is not assigned. Please assign one!", MessageType.Warning);
            }
            EditorGUILayout.ObjectField(renderMaterial, renderMaterialContent);
            if (renderMaterial.objectReferenceValue == null)
            {
                renderMaterial.objectReferenceValue = new Material(Shader.Find("Hidden/CameraBlit"));
                EditorGUILayout.HelpBox("Warning: Render material is not assigned. Please assign one!", MessageType.Warning);
            }
            serializedObject.ApplyModifiedProperties();
        }

        //Postprocessing Settings Block
        CustomUi.GuiLineSeparator(2);
        postprocessingPorps = CustomUi.FoldOut("Postprocessing", postprocessingPorps);
        EditorGUILayout.Separator();
        if (postprocessingPorps)
        {
            //Usage tip
            EditorGUILayout.HelpBox("Create PostProcessing preset and assign it to scenes PostProcess controller", MessageType.Info);

            //Global toggles
            CustomUi.GuiLineSeparator(1);

            useBloom               = serializedObject.FindProperty("UseGlobalBloom");
            useFishEye             = serializedObject.FindProperty("UseGlobalFishEye");
            useVignetting          = serializedObject.FindProperty("UseGlobalVignetting");
            useLut                 = serializedObject.FindProperty("UseGlobalLut");
            useChromaticAberration = serializedObject.FindProperty("UseChromaticAberration");

            EditorGUILayout.LabelField(postGlobalTogglesLableContent, EditorStyles.boldLabel);
            useBloom.boolValue               = EditorGUILayout.Toggle(useBloomContent, useBloom.boolValue);
            useFishEye.boolValue             = EditorGUILayout.Toggle(useFishEyeContent, useFishEye.boolValue);
            useVignetting.boolValue          = EditorGUILayout.Toggle(useVignettingContent, useVignetting.boolValue);
            useChromaticAberration.boolValue = EditorGUILayout.Toggle(useChromaticAberrationContent, useChromaticAberration.boolValue);
            useLut.boolValue = EditorGUILayout.Toggle(useLutContent, useLut.boolValue);

            CustomUi.GuiLineSeparator(1);

            defaultPostPreset = serializedObject.FindProperty("DefaultPostPreset");
            EditorGUILayout.ObjectField(defaultPostPreset, defaultPostPresetContent);

            CustomUi.GuiLineSeparator(1);

            EditorGUILayout.LabelField(subResLableContent, EditorStyles.boldLabel);
            downScaleValue   = serializedObject.FindProperty("DownScaleValue");
            useSubResolution = EditorGUILayout.Toggle(useSubResContent, useSubResolution);
            if (useSubResolution)
            {
                EditorGUILayout.IntSlider(downScaleValue, 1, 10, resolutionDownscaleContent);
            }
            else
            {
                downScaleValue.intValue = 1;
            }

            CustomUi.GuiLineSeparator(1);

            EditorGUILayout.LabelField(blurFiltering, EditorStyles.boldLabel);
            dualFiltering  = serializedObject.FindProperty("DualFiltering");
            blurOffsetDown = serializedObject.FindProperty("BlurOffsetDown");
            blurOffsetUp   = serializedObject.FindProperty("BlurOffsetUp");
            bluumPasses    = serializedObject.FindProperty("BloomPasses");
            EditorGUILayout.ObjectField(dualFiltering, dualMaterialContent);
            EditorGUILayout.Slider(blurOffsetDown, 0f, 10f, blurOffsetDownContent);
            EditorGUILayout.Slider(blurOffsetUp, 0f, 10f, blurOffsetUpContent);
            EditorGUILayout.IntSlider(bluumPasses, 3, 10, bluumPassesContent);

            serializedObject.ApplyModifiedProperties();
        }
        //CustomUI.GuiLineSeparator(10);
        //base.OnInspectorGUI();
    }
예제 #4
0
    private void SetBatchingType(BatchingType newBatchingType)
    {
      // Reset scene.
      _graphicsScreen.Scene.Children.Remove(_originalMeshNodes);
      _graphicsScreen.Scene.Children.Remove(_staticInstancingNodes);
      _graphicsScreen.Scene.Children.Remove(_staticBatchingNodes);

      _batchingType = newBatchingType;
      if (newBatchingType == BatchingType.NoBatching)
      {
        // Strategy A: Add many individual mesh nodes to scene. Disable dynamic hardware instancing.
        _graphicsScreen.Scene.Children.Add(_originalMeshNodes);
        _graphicsScreen.MeshRenderer.EnableInstancing = false;
      }
      else if (newBatchingType == BatchingType.DynamicHardwareInstancing)
      {
        // Strategy B: Many individual nodes. MeshRenderer performs dynamic hardware instancing.
        _graphicsScreen.Scene.Children.Add(_originalMeshNodes);
        _graphicsScreen.MeshRenderer.EnableInstancing = true;
      }
      else if (newBatchingType == BatchingType.StaticHardwareInstancing)
      {
        // Strategy C: A few InstancingMeshNodes.
        _graphicsScreen.Scene.Children.Add(_staticInstancingNodes);
      }
      else if (newBatchingType == BatchingType.StaticBatching)
      {
        // Strategy D: A few merged MeshNodes.
        _graphicsScreen.Scene.Children.Add(_staticBatchingNodes);
      }
    }