Ejemplo n.º 1
0
        public override void Cleanup()
        {
            mCLDB_Snapshot[0].Cleanup();
            mCLDB_Snapshot[0] = null;
            mCLDB_Snapshot[1].Cleanup();
            mCLDB_Snapshot[1] = null;

            mCLDB_Copy[0].Cleanup();
            mCLDB_Copy[0] = null;
            mCLDB_Copy[1].Cleanup();
            mCLDB_Copy[1] = null;

            BaseSceneView.Cleanup();
            BaseSceneView = null;

            mFinalView = null;

            base.Cleanup();
        }
Ejemplo n.º 2
0
        public void Cleanup()
        {
            mCLDB_Picked[0].Cleanup();
            mCLDB_Picked[0] = null;
            mCLDB_Picked[1].Cleanup();
            mCLDB_Picked[1] = null;

            mCLDB_DisableWarning[0].Cleanup();
            mCLDB_DisableWarning[0] = null;
            mCLDB_DisableWarning[1].Cleanup();
            mCLDB_DisableWarning[1] = null;

            mSV_PickedSetUp.Cleanup();
            mSV_PickedSetUp = null;

            mSV_PickedBlurH = null;
            mSV_PickedBlurV = null;
            //mSV_PickedHollow = null;
        }
Ejemplo n.º 3
0
        public async System.Threading.Tasks.Task <bool> Init(CRenderContext RHICtx, UInt32 width, UInt32 height, CGfxSceneView BaseSceneView)
        {
            if (RHICtx == null || BaseSceneView == null)
            {
                return(false);
            }

            if (mSE_BlurH == null)
            {
                mSE_BlurH = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileBloomBlurHSE>();
            }
            if (mSE_BlurV == null)
            {
                mSE_BlurV = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileBloomBlurVSE>();
            }

            if (mDownSampSE == null)
            {
                mDownSampSE = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileBloomDSSE>();
            }

            if (mUpSampSE == null)
            {
                mUpSampSE = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileBloomUSSE>();
            }

            var ScreenAlignedTriangle = CEngine.Instance.MeshPrimitivesManager.GetMeshPrimitives(RHICtx, CEngineDesc.ScreenAlignedTriangleName, true);
            var mtl = await CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(RHICtx, RName.GetRName("Material/defaultmaterial.instmtl"));

            mScreenAlignedTriangle = CEngine.Instance.MeshManager.CreateMesh(RHICtx, ScreenAlignedTriangle);
            mScreenAlignedTriangle.SetMaterialInstance(RHICtx, 0, mtl, CEngine.Instance.PrebuildPassData.DefaultShadingEnvs);
            //await mScreenAlignedTriangle.AwaitEffects();

            UInt32 Width  = Math.Max(width, 64);
            UInt32 Height = Math.Max(height, 64);

            UInt32 Width8  = Width / 8;
            UInt32 Height8 = Height / 8;

            UInt32 Width16  = Width / 16;
            UInt32 Height16 = Height / 16;

            UInt32 Width32  = Width / 32;
            UInt32 Height32 = Height / 32;

            UInt32 Width64  = Width / 64;
            UInt32 Height64 = Height / 64;

            EPixelFormat chooseFormat = EPixelFormat.PXF_R8G8B8A8_UNORM; //EPixelFormat.PXF_R11G11B10_FLOAT;

            if (RHICtx.ContextCaps.SupportHalfRT == 0)
            {
                chooseFormat = EPixelFormat.PXF_R8G8B8A8_UNORM;
            }
            else
            {
                chooseFormat = EPixelFormat.PXF_R16G16B16A16_FLOAT;
            }
            Profiler.Log.WriteLine(Profiler.ELogTag.Info, "Graphics", $"MobileBloom render texture format: {chooseFormat}");
            //blur h pass;
            {
                CGfxScreenViewDesc VI_BlurH = new CGfxScreenViewDesc();
                VI_BlurH.UseDepthStencilView = false;
                VI_BlurH.Width  = Width8;
                VI_BlurH.Height = Height8;

                CRenderTargetViewDesc RTVDesc0 = new CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = chooseFormat;
                RTVDesc0.Width         = Width8;
                RTVDesc0.Height        = Height8;
                VI_BlurH.mRTVDescArray.Add(RTVDesc0);

                mView_BlurH8 = new CGfxScreenView();
                if (await mView_BlurH8.Init(RHICtx, null, VI_BlurH, mSE_BlurH, mtl, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
                mSE_BlurH.mBaseSceneView = BaseSceneView.FrameBuffer.GetSRV_RenderTarget(0);
            }

            //blur v pass;
            {
                CGfxScreenViewDesc VI_BlurV = new CGfxScreenViewDesc();
                VI_BlurV.UseDepthStencilView = false;
                VI_BlurV.Width  = Width8;
                VI_BlurV.Height = Height8;

                var RTVDesc0 = new EngineNS.CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = chooseFormat;
                RTVDesc0.Width         = Width8;
                RTVDesc0.Height        = Height8;
                VI_BlurV.mRTVDescArray.Add(RTVDesc0);

                mView_BlurV8 = new CGfxScreenView();
                if (await mView_BlurV8.Init(RHICtx, null, VI_BlurV, mSE_BlurV, mtl, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
                mSE_BlurV.mSrcTex = mView_BlurH8.FrameBuffer.GetSRV_RenderTarget(0);
            }

            //ds16;
            {
                CGfxScreenViewDesc DSViewInfo16 = new CGfxScreenViewDesc();
                DSViewInfo16.UseDepthStencilView = false;
                DSViewInfo16.Width  = Width16;
                DSViewInfo16.Height = Height16;

                var RTVDesc0 = new EngineNS.CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = chooseFormat;
                RTVDesc0.Width         = Width16;
                RTVDesc0.Height        = Height16;
                DSViewInfo16.mRTVDescArray.Add(RTVDesc0);

                mDSView16 = new CGfxScreenView();
                if (await mDSView16.Init(RHICtx, null, DSViewInfo16, mDownSampSE, mtl, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
            }

            //ds32;
            {
                CGfxScreenViewDesc DSViewInfo32 = new CGfxScreenViewDesc();
                DSViewInfo32.UseDepthStencilView = false;
                DSViewInfo32.Width  = Width32;
                DSViewInfo32.Height = Height32;

                var RTVDesc0 = new EngineNS.CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = chooseFormat;
                RTVDesc0.Width         = Width32;
                RTVDesc0.Height        = Height32;
                DSViewInfo32.mRTVDescArray.Add(RTVDesc0);

                mDSView32 = new CGfxScreenView();
                if (await mDSView32.Init(RHICtx, null, DSViewInfo32, mDownSampSE, mtl, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
            }

            //ds64;
            {
                CGfxScreenViewDesc DSViewInfo64 = new CGfxScreenViewDesc();
                DSViewInfo64.UseDepthStencilView = false;
                DSViewInfo64.Width  = Width64;
                DSViewInfo64.Height = Height64;

                var RTVDesc0 = new EngineNS.CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = chooseFormat;
                RTVDesc0.Width         = Width64;
                RTVDesc0.Height        = Height64;
                DSViewInfo64.mRTVDescArray.Add(RTVDesc0);

                mDSView64 = new CGfxScreenView();
                if (await mDSView64.Init(RHICtx, null, DSViewInfo64, mDownSampSE, mtl, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
            }

            //us32;
            {
                CGfxScreenViewDesc USViewInfo32 = new CGfxScreenViewDesc();
                USViewInfo32.UseDepthStencilView = false;
                USViewInfo32.Width  = Width32;
                USViewInfo32.Height = Height32;

                var RTVDesc0 = new CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = chooseFormat;
                RTVDesc0.Width         = Width32;
                RTVDesc0.Height        = Height32;
                USViewInfo32.mRTVDescArray.Add(RTVDesc0);

                mUSView32 = new CGfxScreenView();
                if (await mUSView32.Init(RHICtx, null, USViewInfo32, mUpSampSE, mtl, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
            }

            //us16;
            {
                CGfxScreenViewDesc USViewInfo16 = new CGfxScreenViewDesc();
                USViewInfo16.UseDepthStencilView = false;
                USViewInfo16.Width  = Width16;
                USViewInfo16.Height = Height16;

                var RTVDesc0 = new CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = chooseFormat;
                RTVDesc0.Width         = Width16;
                RTVDesc0.Height        = Height16;
                USViewInfo16.mRTVDescArray.Add(RTVDesc0);

                mUSView16 = new CGfxScreenView();
                if (await mUSView16.Init(RHICtx, null, USViewInfo16, mUpSampSE, mtl, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
            }

            //us8;
            {
                CGfxScreenViewDesc USViewInfo8 = new CGfxScreenViewDesc();
                USViewInfo8.UseDepthStencilView = false;
                USViewInfo8.Width  = Width8;
                USViewInfo8.Height = Height8;

                var RTVDesc0 = new CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = chooseFormat;
                RTVDesc0.Width         = Width8;
                RTVDesc0.Height        = Height8;
                USViewInfo8.mRTVDescArray.Add(RTVDesc0);

                mUSView8 = new CGfxScreenView();
                if (await mUSView8.Init(RHICtx, null, USViewInfo8, mUpSampSE, mtl, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
            }

            mRenderPassDesc_Bloom = new CRenderPassDesc();
            FrameBufferClearColor TempClearColor0 = new FrameBufferClearColor();

            TempClearColor0.r = 0.0f;
            TempClearColor0.g = 0.0f;
            TempClearColor0.b = 0.0f;
            TempClearColor0.a = 0.0f;

            mRenderPassDesc_Bloom.mFBLoadAction_Color    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Bloom.mFBStoreAction_Color   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Bloom.mFBClearColorRT0       = TempClearColor0;
            mRenderPassDesc_Bloom.mFBLoadAction_Depth    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Bloom.mFBStoreAction_Depth   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Bloom.mDepthClearValue       = 1.0f;
            mRenderPassDesc_Bloom.mFBLoadAction_Stencil  = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Bloom.mFBStoreAction_Stencil = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Bloom.mStencilClearValue     = 0u;

            {
                var ViewportSizeAndRcpBlurH = new Vector4(width, height, 1.0f / width, 1.0f / height);
                mView_BlurH8.ViewportSizeAndRcp = ViewportSizeAndRcpBlurH;
            }
            {
                var ViewportSizeAndRcpBlurV = new Vector4(Width8, Height8, 1.0f / Width8, 1.0f / Height8);
                mView_BlurV8.ViewportSizeAndRcp = ViewportSizeAndRcpBlurV;
            }
            //down
            {
                var ViewportSizeAndRcpD16 = new Vector4(Width8, Height8, 1.0f / Width8, 1.0f / Height8);
                mDSView16.ViewportSizeAndRcp = ViewportSizeAndRcpD16;
            }
            {
                var ViewportSizeAndRcpD32 = new Vector4(Width16, Height16, 1.0f / Width16, 1.0f / Height16);
                mDSView32.ViewportSizeAndRcp = ViewportSizeAndRcpD32;
            }
            {
                var ViewportSizeAndRcpD64 = new Vector4(Width32, Height32, 1.0f / Width32, 1.0f / Height32);
                mDSView64.ViewportSizeAndRcp = ViewportSizeAndRcpD64;
            }
            //up
            {
                var ViewportRcpU32 = new Vector4(1.0f / Width32, 1.0f / Height32, 1.0f / Width64, 1.0f / Height64);
                mUSView32.ViewportSizeAndRcp = ViewportRcpU32;
            }
            {
                var ViewportRcpU16 = new Vector4(1.0f / Width16, 1.0f / Height16, 1.0f / Width32, 1.0f / Height32);
                mUSView16.ViewportSizeAndRcp = ViewportRcpU16;
            }
            {
                var ViewportRcpU8 = new Vector4(1.0f / Width8, 1.0f / Height8, 1.0f / Width16, 1.0f / Height16);
                mUSView8.ViewportSizeAndRcp = ViewportRcpU8;
            }

            return(true);
        }
Ejemplo n.º 4
0
        public override async System.Threading.Tasks.Task <bool> Init(CRenderContext RHICtx, UInt32 width, UInt32 height, CGfxCamera camera, IntPtr WinHandle)
        {
            CGfxSceneViewInfo SnapshotViewInfo = new CGfxSceneViewInfo();

            SnapshotViewInfo.mUseDSV = true;
            SnapshotViewInfo.Width   = width;
            SnapshotViewInfo.Height  = height;
            SnapshotViewInfo.mDSVDesc.Init();
            SnapshotViewInfo.mDSVDesc.Format = EngineNS.EPixelFormat.PXF_D24_UNORM_S8_UINT;
            SnapshotViewInfo.mDSVDesc.Width  = width;
            SnapshotViewInfo.mDSVDesc.Height = height;

            CRenderTargetViewDesc rtDesc0 = new CRenderTargetViewDesc();

            rtDesc0.Init();
            rtDesc0.Format = EPixelFormat.PXF_R8G8B8A8_UNORM;
            rtDesc0.Width  = width;
            rtDesc0.Height = height;
            SnapshotViewInfo.mRTVDescArray.Add(rtDesc0);

            BaseSceneView = new CGfxSceneView();
            if (false == BaseSceneView.Init(RHICtx, null, SnapshotViewInfo))
            {
                return(false);
            }

            Camera = camera;
            //mCamera.SetSceneView(RHICtx, mBaseSceneView);

            mRenderPassDesc_Snapshot = new CRenderPassDesc();
            FrameBufferClearColor TempClearColor = new FrameBufferClearColor();

            TempClearColor.r = 0.0f;
            TempClearColor.g = 0.0f;
            TempClearColor.b = 0.0f;
            TempClearColor.a = 0.0f;
            mRenderPassDesc_Snapshot.mFBLoadAction_Color    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Snapshot.mFBStoreAction_Color   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Snapshot.mFBClearColorRT0       = TempClearColor;
            mRenderPassDesc_Snapshot.mFBLoadAction_Depth    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Snapshot.mFBStoreAction_Depth   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Snapshot.mDepthClearValue       = 1.0f;
            mRenderPassDesc_Snapshot.mFBLoadAction_Stencil  = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Snapshot.mFBStoreAction_Stencil = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Snapshot.mStencilClearValue     = 0u;

            mRenderPassDesc_Final = new CRenderPassDesc();
            TempClearColor.r      = 0.0f;
            TempClearColor.g      = 1.0f;
            TempClearColor.b      = 0.0f;
            TempClearColor.a      = 0.0f;
            mRenderPassDesc_Final.mFBLoadAction_Color    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Final.mFBStoreAction_Color   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Final.mFBClearColorRT0       = TempClearColor;
            mRenderPassDesc_Final.mFBLoadAction_Depth    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Final.mFBStoreAction_Depth   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Final.mDepthClearValue       = 1.0f;
            mRenderPassDesc_Final.mFBLoadAction_Stencil  = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Final.mFBStoreAction_Stencil = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Final.mStencilClearValue     = 0u;

            if (mSnapshotSE == null)
            {
                mSnapshotSE = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxSnapshotSE>();
            }
            if (mCopySE == null)
            {
                mCopySE = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileCopySE>();
            }

            var ufoViewInfo = new CGfxScreenViewDesc();

            ufoViewInfo.IsSwapChainBuffer   = false;
            ufoViewInfo.UseDepthStencilView = false;
            ufoViewInfo.Width  = width;
            ufoViewInfo.Height = height;

            var rtDesc1 = new CRenderTargetViewDesc();

            rtDesc1.Init();
            rtDesc1.mCanBeSampled = vBOOL.FromBoolean(true);
            rtDesc1.Format        = EPixelFormat.PXF_R8G8B8A8_UNORM;
            rtDesc1.Width         = width;
            rtDesc1.Height        = height;
            ufoViewInfo.mRTVDescArray.Add(rtDesc1);

            var screenAlignedTriangle = CEngine.Instance.MeshPrimitivesManager.GetMeshPrimitives(RHICtx, CEngineDesc.ScreenAlignedTriangleName, true);

            mScreenAlignedTriangle = CEngine.Instance.MeshManager.CreateMesh(RHICtx, screenAlignedTriangle);
            var mtl = await CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(RHICtx, RName.GetRName("Material/defaultmaterial.instmtl"));

            mScreenAlignedTriangle.SetMaterialInstance(RHICtx, 0, mtl, CEngine.Instance.PrebuildPassData.DefaultShadingEnvs);
            //await mScreenAlignedTriangle.AwaitEffects();
            mFinalView = new CGfxScreenView();
            await mFinalView.Init(RHICtx, null, ufoViewInfo, mCopySE, mtl, mScreenAlignedTriangle);

            var viewportSizeAndRcp = new Vector4(width, height, 1.0f / width, 1.0f / height);

            mFinalView.ViewportSizeAndRcp = viewportSizeAndRcp;

            return(true);
        }
Ejemplo n.º 5
0
        public async System.Threading.Tasks.Task <bool> Init(CRenderContext RHICtx, UInt32 width, UInt32 height, CGfxSceneView BaseSceneView)
        {
            if (RHICtx == null || BaseSceneView == null)
            {
                return(false);
            }

            if (mSE_AoMask == null)
            {
                mSE_AoMask = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileAoMaskSE>();
            }
            if (mSE_BlurH == null)
            {
                mSE_BlurH = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileAoBlurHSE>();
            }
            if (mSE_BlurV == null)
            {
                mSE_BlurV = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileAoBlurVSE>();
            }
            mMobileAoSEArrayMask.Add(mSE_AoMask);
            mMobileAoSEArrayMask.Add(mSE_BlurV);

            var ScreenAlignedTriangle = CEngine.Instance.MeshPrimitivesManager.GetMeshPrimitives(RHICtx, CEngineDesc.ScreenAlignedTriangleName, true);
            var DefaultMtlInst        = await CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(RHICtx, RName.GetRName("Material/defaultmaterial.instmtl"));

            mScreenAlignedTriangle = CEngine.Instance.MeshManager.CreateMesh(RHICtx, ScreenAlignedTriangle);
            mScreenAlignedTriangle.SetMaterialInstance(RHICtx, 0, DefaultMtlInst, CEngine.Instance.PrebuildPassData.DefaultShadingEnvs);

            UInt32 Width  = Math.Max(width, 64);
            UInt32 Height = Math.Max(height, 64);

            UInt32 Width4  = Width / mRTCut;
            UInt32 Height4 = Height / mRTCut;

            //ao mask pass;
            {
                CGfxScreenViewDesc VI_AoMask = new CGfxScreenViewDesc();
                VI_AoMask.UseDepthStencilView = false;
                VI_AoMask.Width  = Width4;
                VI_AoMask.Height = Height4;

                CRenderTargetViewDesc RTVDesc0 = new CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = EPixelFormat.PXF_R8_UNORM;
                RTVDesc0.Width         = Width4;
                RTVDesc0.Height        = Width4;
                VI_AoMask.mRTVDescArray.Add(RTVDesc0);

                mView_AoMask = new CGfxScreenView();
                if (await mView_AoMask.InitForMultiPassMode(RHICtx, VI_AoMask, mMobileAoSEArrayMask, DefaultMtlInst, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
                //mSE_AoMask.mBaseSceneView = BaseSceneView.mFrameBuffer.GetSRV_RenderTarget(0);
            }

            //blur h pass;
            {
                CGfxScreenViewDesc VI_BlurH = new CGfxScreenViewDesc();
                VI_BlurH.UseDepthStencilView = false;
                VI_BlurH.Width  = Width4;
                VI_BlurH.Height = Height4;

                CRenderTargetViewDesc RTVDesc0 = new CRenderTargetViewDesc();
                RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc0.Format        = EPixelFormat.PXF_R8_UNORM;
                RTVDesc0.Width         = Width4;
                RTVDesc0.Height        = Width4;
                VI_BlurH.mRTVDescArray.Add(RTVDesc0);

                mView_BlurH = new CGfxScreenView();
                if (await mView_BlurH.Init(RHICtx, null, VI_BlurH, mSE_BlurH, DefaultMtlInst, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
                mSE_BlurH.mSRV_AoMask = mView_AoMask.FrameBuffer.GetSRV_RenderTarget(0);
            }

            ////blur v pass;
            //{
            //    CGfxScreenViewDesc VI_BlurV = new CGfxScreenViewDesc();
            //    VI_BlurV.UseDepthStencilView = false;
            //    VI_BlurV.Width = Width4;
            //    VI_BlurV.Height = Height4;

            //    CRenderTargetViewDesc RTVDesc0 = new CRenderTargetViewDesc();
            //    RTVDesc0.mCanBeSampled = vBOOL.FromBoolean(true);
            //    RTVDesc0.Format = EPixelFormat.PXF_R8_UNORM;
            //    RTVDesc0.Width = Width4;
            //    RTVDesc0.Height = Width4;
            //    VI_BlurV.mRTVDescArray.Add(RTVDesc0);

            //    mView_BlurV = new CGfxScreenView();
            //    if (await mView_BlurV.Init(RHICtx, null, VI_BlurV, mSE_BlurV, DefaultMtlInst, mScreenAlignedTriangle) == false)
            //    {
            //        return false;
            //    }
            //    mSE_BlurV.mSRV_Src = mView_BlurH.FrameBuffer.GetSRV_RenderTarget(0);
            //}

            mRenderPassDesc_Ao = new CRenderPassDesc();
            FrameBufferClearColor TempClearColor0 = new FrameBufferClearColor();

            TempClearColor0.r = 1.0f;
            TempClearColor0.g = 1.0f;
            TempClearColor0.b = 1.0f;
            TempClearColor0.a = 1.0f;

            mRenderPassDesc_Ao.mFBLoadAction_Color    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Ao.mFBStoreAction_Color   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Ao.mFBClearColorRT0       = TempClearColor0;
            mRenderPassDesc_Ao.mFBLoadAction_Depth    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Ao.mFBStoreAction_Depth   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Ao.mDepthClearValue       = 1.0f;
            mRenderPassDesc_Ao.mFBLoadAction_Stencil  = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Ao.mFBStoreAction_Stencil = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Ao.mStencilClearValue     = 0u;

            mViewportSizeAndRcp             = new Vector4(Width4, Height4, 1.0f / Width4, 1.0f / Height4);
            mView_AoMask.ViewportSizeAndRcp = mViewportSizeAndRcp;
            mView_BlurH.ViewportSizeAndRcp  = mViewportSizeAndRcp;
            //mView_BlurV.ViewportSizeAndRcp = ViewportSizeAndRcp;


            return(true);
        }
Ejemplo n.º 6
0
 public void RiseOnDrawUI(CCommandList cmd, CGfxScreenView view)
 {
     OnDrawUI?.Invoke(cmd, view);
 }
Ejemplo n.º 7
0
        public async System.Threading.Tasks.Task <bool> Init(CRenderContext RHICtx, UInt32 width, UInt32 height)
        {
            if (RHICtx == null)
            {
                return(false);
            }

            if (mSE_Mask == null)
            {
                mSE_Mask = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileSunShaftMaskSE>();
            }

            if (mSE_Blur == null)
            {
                mSE_Blur = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxMobileSunShaftBlurSE>();
            }
            mSunShaftSEArrayMask.Add(mSE_Mask);
            mSunShaftSEArrayMask.Add(mSE_Blur);

            mSunShaftSEArrayBlur.Add(mSE_Blur);
            mSunShaftSEArrayBlur.Add(mSE_Blur);

            var ScreenAlignedTriangle = CEngine.Instance.MeshPrimitivesManager.GetMeshPrimitives(RHICtx, CEngineDesc.ScreenAlignedTriangleName, true);
            var DefaultMtlInst        = await CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(RHICtx, RName.GetRName("Material/defaultmaterial.instmtl"));

            mViewportMesh = CEngine.Instance.MeshManager.CreateMesh(RHICtx, ScreenAlignedTriangle);
            mViewportMesh.SetMaterialInstance(RHICtx, 0, DefaultMtlInst, CEngine.Instance.PrebuildPassData.DefaultShadingEnvs);
            //await mViewportMesh.AwaitEffects();

            UInt32 Width  = Math.Max(width, 4);
            UInt32 Height = Math.Max(height, 4);

            UInt32 Width4  = Width / 4;
            UInt32 Height4 = Height / 4;

            //mask view
            {
                CGfxScreenViewDesc VD_Mask = new CGfxScreenViewDesc();
                VD_Mask.UseDepthStencilView = false;
                VD_Mask.Width  = Width4;
                VD_Mask.Height = Height4;

                CRenderTargetViewDesc RTVDesc_Mask = new CRenderTargetViewDesc();
                RTVDesc_Mask.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc_Mask.Format        = EPixelFormat.PXF_R8G8_UNORM;
                RTVDesc_Mask.Width         = Width4;
                RTVDesc_Mask.Height        = Height4;
                VD_Mask.mRTVDescArray.Add(RTVDesc_Mask);

                mView_Mask = new CGfxScreenView();
                if (await mView_Mask.InitForMultiPassMode(RHICtx, VD_Mask, mSunShaftSEArrayMask, DefaultMtlInst, mViewportMesh) == false)
                {
                    System.Diagnostics.Debug.Assert(false);
                    return(false);
                }
            }

            //blur0 view
            {
                CGfxScreenViewDesc VD_Blur = new CGfxScreenViewDesc();
                VD_Blur.UseDepthStencilView = false;
                VD_Blur.Width  = Width4;
                VD_Blur.Height = Height4;

                CRenderTargetViewDesc RTVDesc_Blur = new CRenderTargetViewDesc();
                RTVDesc_Blur.mCanBeSampled = vBOOL.FromBoolean(true);
                RTVDesc_Blur.Format        = EPixelFormat.PXF_R8G8_UNORM;
                RTVDesc_Blur.Width         = Width4;
                RTVDesc_Blur.Height        = Height4;
                VD_Blur.mRTVDescArray.Add(RTVDesc_Blur);

                mView_Blur = new CGfxScreenView();
                if (await mView_Blur.InitForMultiPassMode(RHICtx, VD_Blur, mSunShaftSEArrayBlur, DefaultMtlInst, mViewportMesh) == false)
                {
                    System.Diagnostics.Debug.Assert(false);
                    return(false);
                }
            }

            mRenderPassDesc_SunShaft = new CRenderPassDesc();
            FrameBufferClearColor TempClearColor0 = new FrameBufferClearColor();

            TempClearColor0.r = 0.0f;
            TempClearColor0.g = 0.0f;
            TempClearColor0.b = 0.0f;
            TempClearColor0.a = 0.0f;

            mRenderPassDesc_SunShaft.mFBLoadAction_Color    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_SunShaft.mFBStoreAction_Color   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_SunShaft.mFBClearColorRT0       = TempClearColor0;
            mRenderPassDesc_SunShaft.mFBLoadAction_Depth    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_SunShaft.mFBStoreAction_Depth   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_SunShaft.mDepthClearValue       = 1.0f;
            mRenderPassDesc_SunShaft.mFBLoadAction_Stencil  = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_SunShaft.mFBStoreAction_Stencil = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_SunShaft.mStencilClearValue     = 0u;

            return(true);
        }
Ejemplo n.º 8
0
        public async System.Threading.Tasks.Task <bool> Init(UInt32 width, UInt32 height, CGfxCamera camera)
        {
            CGfxSceneViewInfo VI_PickedSetUp = new CGfxSceneViewInfo();

            VI_PickedSetUp.mUseDSV = true;
            UInt32 TempWidth  = width;
            UInt32 TempHeight = height;

            VI_PickedSetUp.Width  = TempWidth;
            VI_PickedSetUp.Height = TempHeight;
            VI_PickedSetUp.mDSVDesc.Init();
            VI_PickedSetUp.mDSVDesc.Format = EngineNS.EPixelFormat.PXF_D24_UNORM_S8_UINT;
            VI_PickedSetUp.mDSVDesc.Width  = TempWidth;
            VI_PickedSetUp.mDSVDesc.Height = TempHeight;

            CRenderTargetViewDesc RTVDesc_PickeSetUp = new CRenderTargetViewDesc();

            RTVDesc_PickeSetUp.Init();
            RTVDesc_PickeSetUp.Format = EPixelFormat.PXF_R16G16_FLOAT;
            RTVDesc_PickeSetUp.Width  = TempWidth;
            RTVDesc_PickeSetUp.Height = TempHeight;
            VI_PickedSetUp.mRTVDescArray.Add(RTVDesc_PickeSetUp);

            mSV_PickedSetUp = new CGfxSceneView();
            if (false == mSV_PickedSetUp.Init(mRHICtx, null, VI_PickedSetUp))
            {
                return(false);
            }

            mSE_PickedSetUp  = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxPickedSetUpSE>();
            mSE_PickedBlurH  = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxPickedBlurHSE>();
            mSE_PickedBlurV  = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxPickedBlurVSE>();
            mSE_PickedHollow = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <CGfxPickedHollowSE>();
            mBlurAndHollowSEArray.Add(mSE_PickedBlurH);
            mBlurAndHollowSEArray.Add(mSE_PickedHollow);

            var ScreenAlignedTriangle = CEngine.Instance.MeshPrimitivesManager.GetMeshPrimitives(mRHICtx, CEngineDesc.ScreenAlignedTriangleName, true);
            var DefaultMtlInst        = await CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(mRHICtx, RName.GetRName("Material/defaultmaterial.instmtl"));

            mScreenAlignedTriangle = CEngine.Instance.MeshManager.CreateMesh(mRHICtx, ScreenAlignedTriangle);
            mScreenAlignedTriangle.SetMaterialInstance(mRHICtx, 0, DefaultMtlInst, CEngine.Instance.PrebuildPassData.DefaultShadingEnvs);
            //await mScreenAlignedTriangle.AwaitEffects();

            //blur h and hollow;
            {
                CGfxScreenViewDesc VI_BlurH = new CGfxScreenViewDesc();
                VI_BlurH.UseDepthStencilView = false;
                VI_BlurH.Width  = TempWidth;
                VI_BlurH.Height = TempHeight;

                var RTVDesc_BlurH = new CRenderTargetViewDesc();
                RTVDesc_BlurH.Init();
                RTVDesc_BlurH.Format = EPixelFormat.PXF_R16G16_FLOAT;
                VI_BlurH.mRTVDescArray.Add(RTVDesc_BlurH);
                mSV_PickedBlurH = new CGfxScreenView();
                if (await mSV_PickedBlurH.InitForMultiPassMode(mRHICtx, VI_BlurH, mBlurAndHollowSEArray, DefaultMtlInst, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
            }

            //blur v;
            {
                CGfxScreenViewDesc VI_BlurV = new CGfxScreenViewDesc();
                VI_BlurV.UseDepthStencilView = false;
                VI_BlurV.Width  = TempWidth;
                VI_BlurV.Height = TempHeight;

                var RTVDesc_BlurV = new CRenderTargetViewDesc();
                RTVDesc_BlurV.Init();
                RTVDesc_BlurV.Format = EPixelFormat.PXF_R16G16_FLOAT;
                VI_BlurV.mRTVDescArray.Add(RTVDesc_BlurV);
                mSV_PickedBlurV = new CGfxScreenView();
                if (await mSV_PickedBlurV.Init(mRHICtx, null, VI_BlurV, mSE_PickedBlurV, DefaultMtlInst, mScreenAlignedTriangle) == false)
                {
                    return(false);
                }
            }

            mCamera = camera;

            mRenderPassDesc_Picked = new CRenderPassDesc();
            FrameBufferClearColor TempClearColor = new FrameBufferClearColor();

            TempClearColor.r = 0.0f;
            TempClearColor.g = 1.0f;
            TempClearColor.b = 0.0f;
            TempClearColor.a = 0.0f;
            mRenderPassDesc_Picked.mFBLoadAction_Color    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Picked.mFBStoreAction_Color   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Picked.mFBClearColorRT0       = TempClearColor;
            mRenderPassDesc_Picked.mFBLoadAction_Depth    = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Picked.mFBStoreAction_Depth   = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Picked.mDepthClearValue       = 1.0f;
            mRenderPassDesc_Picked.mFBLoadAction_Stencil  = FrameBufferLoadAction.LoadActionClear;
            mRenderPassDesc_Picked.mFBStoreAction_Stencil = FrameBufferStoreAction.StoreActionStore;
            mRenderPassDesc_Picked.mStencilClearValue     = 0u;

            mSE_PickedBlurH.mSRV_PickedSetUp  = mSV_PickedSetUp.FrameBuffer.GetSRV_RenderTarget(0);
            mSE_PickedBlurV.mSRV_PickedBlurH  = mSV_PickedBlurH.FrameBuffer.GetSRV_RenderTarget(0);
            mSE_PickedHollow.mSRV_PickedSetUp = mSV_PickedSetUp.FrameBuffer.GetSRV_RenderTarget(0);
            mSE_PickedHollow.mSRV_PickedBlur  = mSV_PickedBlurV.FrameBuffer.GetSRV_RenderTarget(0);

            var ViewportSizeAndRcp = new Vector4(TempWidth, TempHeight, 1.0f / TempWidth, 1.0f / TempHeight);

            mSV_PickedBlurH.ViewportSizeAndRcp = ViewportSizeAndRcp;
            mSV_PickedBlurV.ViewportSizeAndRcp = ViewportSizeAndRcp;

            return(true);
        }