コード例 #1
0
    /// <summary>
    /// We need to get all the dependencies of the graphics settings
    /// Grab everything we can from the settings that is exposed to script
    /// </summary>
    private void AddGraphicsSettings()
    {
        HashSet <string> settingsFiles = new HashSet <string>();

        if (GraphicsSettings.renderPipelineAsset != null)
        {
            string rpAssetPath = AssetDatabase.GetAssetPath(GraphicsSettings.renderPipelineAsset);
            Debug.LogFormat("Render Pipeline Asset {0}", rpAssetPath);
            settingsFiles.Add(rpAssetPath);
        }

        foreach (BuiltinShaderType shaderType in System.Enum.GetValues(typeof(BuiltinShaderType)))
        {
            Shader shader = GraphicsSettings.GetCustomShader(shaderType);
            if (shader != null)
            {
                string shaderPath = AssetDatabase.GetAssetPath(shader);
                Debug.LogFormat("Shader {0}", shaderPath);
                if (File.Exists(shaderPath))
                {
                    settingsFiles.Add(shaderPath);
                }
            }
        }

        AddDependencies(settingsFiles);
    }
コード例 #2
0
        void RenderForeground()
        {
            float            oldFar             = gameCamera.farClipPlane;
            CameraClearFlags oldFlags           = gameCamera.clearFlags;
            Color            oldBackgroundColor = gameCamera.backgroundColor;

            gameCamera.farClipPlane = Mathf.Max(gameCamera.nearClipPlane + 0.001f, CalculatePlayerDepth() + 0.5f * layerOverlap);

            gameCamera.clearFlags      = CameraClearFlags.SolidColor;
            gameCamera.backgroundColor = new Color(clearColor.r, clearColor.g, clearColor.b, 0);

            Shader originalScreenSpaceShadowShader = GraphicsSettings.GetCustomShader(BuiltinShaderType.ScreenSpaceShadows);

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, noForegroundShadowFadeShader);

            if (takeUnfilteredAlpha)
            {
                gameCamera.AddCommandBuffer(CameraEvent.BeforeImageEffects, grabAlphaCommand);  //Instruction to copy out the state of the RenderTexture before Image Effects are applied
            }
            RenderGameCamera(gameCamera, quadrantTex);
            if (takeUnfilteredAlpha)
            {
                gameCamera.RemoveCommandBuffer(CameraEvent.BeforeImageEffects, grabAlphaCommand);
                Graphics.Blit(lastFrameAlpha, quadrantTex, copyAlphaMat);      //Overwrite the potentially broken post-effects alpha channel with the pre-effect copy
            }

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, originalScreenSpaceShadowShader);

            gameCamera.farClipPlane    = oldFar;
            gameCamera.clearFlags      = oldFlags;
            gameCamera.backgroundColor = oldBackgroundColor;
        }
コード例 #3
0
        void GrabForeground(GameFrame targetFrame)
        {
            gameCamera.farClipPlane  = targetFrame.playerDepth + 0.5f * layerOverlap;
            gameCamera.nearClipPlane = gameNearClipPlane;
            //
            gameCamera.clearFlags      = CameraClearFlags.Color | CameraClearFlags.Depth;
            gameCamera.backgroundColor = new Color(0, 0, 0, 0);

            Shader originalScreenSpaceShadowShader = GraphicsSettings.GetCustomShader(BuiltinShaderType.ScreenSpaceShadows);

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, noForegroundShadowFadeShader);

            LayerMask oldCull = gameCamera.cullingMask;

            if (forceToBackground > 0)
            {
                gameCamera.cullingMask = forceToBackground;
                gameCamera.RenderWithShader(blockoutBackgroundShader, null);
                gameCamera.clearFlags = CameraClearFlags.Nothing;       //Whole point: next Render() respects this depth buffer
            }

            gameCamera.cullingMask = oldCull ^ forceToBackground;
            RenderGameCamera(gameCamera, targetFrame.foregroundBuffer);
            gameCamera.cullingMask = oldCull;

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, originalScreenSpaceShadowShader);

            gameCamera.nearClipPlane = gameNearClipPlane;
            gameCamera.farClipPlane  = gameFarClipPlane;
        }
コード例 #4
0
        void RenderForeground()
        {
            float            oldFar             = gameCamera.farClipPlane;
            CameraClearFlags oldFlags           = gameCamera.clearFlags;
            Color            oldBackgroundColor = gameCamera.backgroundColor;

            gameCamera.farClipPlane = Mathf.Max(gameCamera.nearClipPlane + 0.001f, CalculatePlayerDepth() + 0.5f * layerOverlap);

            gameCamera.clearFlags      = CameraClearFlags.SolidColor;
            gameCamera.backgroundColor = clearColor;

            Shader originalScreenSpaceShadowShader = GraphicsSettings.GetCustomShader(BuiltinShaderType.ScreenSpaceShadows);

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, noForegroundShadowFadeShader);

            RenderGameCamera(gameCamera, quadrantTex);

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, originalScreenSpaceShadowShader);

            gameCamera.farClipPlane    = oldFar;
            gameCamera.clearFlags      = oldFlags;
            gameCamera.backgroundColor = oldBackgroundColor;

            Graphics.SetRenderTarget(Output as RenderTexture);
            Graphics.DrawTexture(new Rect(Screen.width * 0.5f, 0, Screen.width * 0.5f, Screen.height * 0.5f), quadrantTex);
        }
コード例 #5
0
        void RenderForeground(GameFrame targetFrame)
        {
            float            oldFarClip = cleanProxyCamera.farClipPlane;
            LayerMask        oldCull    = cleanProxyCamera.cullingMask;
            CameraClearFlags oldClear   = cleanProxyCamera.clearFlags;
            Color            oldBGCol   = cleanProxyCamera.backgroundColor;

            Color blackAndClear = new Color(0, 0, 0, 0);

            Graphics.SetRenderTarget(targetFrame.foregroundBuffer);
            GL.Clear(true, true, blackAndClear);

            cleanProxyCamera.farClipPlane    = Mathf.Max(cleanProxyCamera.nearClipPlane + 0.001f, targetFrame.playerDist + 0.5f * layerOverlap);
            cleanProxyCamera.clearFlags      = CameraClearFlags.Color | CameraClearFlags.Depth; //Just cleared
            cleanProxyCamera.backgroundColor = blackAndClear;

            if (forceToBackground > 0)
            {
                cleanProxyCamera.cullingMask = forceToBackground;
                //TODO: optimize by disabling all lighting in this render
                cleanProxyCamera.targetTexture = targetFrame.foregroundBuffer;
                cleanProxyCamera.RenderWithShader(blockoutBackgroundShader, null);

                //now depth buffer wont allow writes where the ground would have been
                cleanProxyCamera.clearFlags = CameraClearFlags.Nothing;
            }

            Shader originalScreenSpaceShadowShader = GraphicsSettings.GetCustomShader(BuiltinShaderType.ScreenSpaceShadows);

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, noForegroundShadowFadeShader);

            cleanProxyCamera.cullingMask = oldCull ^ forceToBackground;

            if (MixCast.ProjectSettings.grabUnfilteredAlpha)
            {
                cleanProxyCamera.AddCommandBuffer(CameraEvent.BeforeImageEffects, grabAlphaCommand);  //Instruction to copy out the state of the RenderTexture before Image Effects are applied
            }
            RenderGameCamera(cleanProxyCamera, targetFrame.foregroundBuffer);

            if (MixCast.ProjectSettings.grabUnfilteredAlpha)
            {
                cleanProxyCamera.RemoveCommandBuffer(CameraEvent.BeforeImageEffects, grabAlphaCommand);
                Graphics.Blit(LastFrameAlpha, targetFrame.foregroundBuffer, copyAlphaMat);      //Overwrite the potentially broken post-effects alpha channel with the pre-effect copy
            }
            else
            {
                LastFrameAlpha = targetFrame.foregroundBuffer;
            }

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, originalScreenSpaceShadowShader);

            cleanProxyCamera.farClipPlane    = oldFarClip;
            cleanProxyCamera.cullingMask     = oldCull;
            cleanProxyCamera.clearFlags      = oldClear;
            cleanProxyCamera.backgroundColor = oldBGCol;
        }
コード例 #6
0
    public static int GetCustomShader_s(IntPtr l)
    {
        int result;

        try
        {
            BuiltinShaderType type;
            LuaObject.checkEnum <BuiltinShaderType>(l, 1, out type);
            Shader customShader = GraphicsSettings.GetCustomShader(type);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, customShader);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }