示例#1
0
 public CDepthStencilState CreateDepthStencilState(CDepthStencilStateDesc desc)
 {
     unsafe
     {
         var obj = SDK_IRenderContext_CreateDepthStencilState(CoreObject, &desc);
         if (obj.Pointer == IntPtr.Zero)
         {
             return(null);
         }
         return(new CDepthStencilState(obj));
     }
 }
示例#2
0
        public CDepthStencilState GetDepthStencilState(CRenderContext rc, CDepthStencilStateDesc desc)
        {
            Hash64 hash = new Hash64();

            unsafe
            {
                Hash64.CalcHash64(&hash, (byte *)&desc, sizeof(CDepthStencilStateDesc));
            }
            CDepthStencilState state;

            if (States.TryGetValue(hash, out state) == false)
            {
                state = rc.CreateDepthStencilState(desc);
                States.Add(hash, state);
            }
            return(state);
        }
示例#3
0
        public void InitSystemStates(CRenderContext RHICtx)
        {
            //raster stat;
            CRasterizerStateDesc RSDescOpaque = new CRasterizerStateDesc();

            RSDescOpaque.InitForOpaque();
            mOpaqueRasterStat = CEngine.Instance.RasterizerStateManager.GetRasterizerState(RHICtx, RSDescOpaque);

            CRasterizerStateDesc RSDescTranslucent = new CRasterizerStateDesc();

            RSDescTranslucent.InitForTranslucent();
            mTranslucentRasterStat = CEngine.Instance.RasterizerStateManager.GetRasterizerState(RHICtx, RSDescTranslucent);

            {
                CRasterizerStateDesc rsDesc = new CRasterizerStateDesc();
                rsDesc.InitForTranslucent();
                rsDesc.CullMode      = ECullMode.CMD_NONE;
                mNoCullingRasterStat = CEngine.Instance.RasterizerStateManager.GetRasterizerState(RHICtx, rsDesc);
            }

            //depth stencil stat;
            CDepthStencilStateDesc OpaqueDSSDesc = new CDepthStencilStateDesc();

            OpaqueDSSDesc.InitForOpacity();
            mOpaqueDSStat = CEngine.Instance.DepthStencilStateManager.GetDepthStencilState(RHICtx, OpaqueDSSDesc);

            CDepthStencilStateDesc TranslucentDSSDesc = new CDepthStencilStateDesc();

            TranslucentDSSDesc.InitForTranslucency();
            mTranslucentDSStat = CEngine.Instance.DepthStencilStateManager.GetDepthStencilState(RHICtx, TranslucentDSSDesc);

            CDepthStencilStateDesc dsDesc = new CDepthStencilStateDesc();

            dsDesc.InitForTranslucency();
            dsDesc.DepthEnable       = 0;
            mDisableDepthStencilStat = CEngine.Instance.DepthStencilStateManager.GetDepthStencilState(RHICtx, dsDesc);

            CDepthStencilStateDesc DSDescEqual = new CDepthStencilStateDesc();

            DSDescEqual.DepthEnable                  = 1;
            DSDescEqual.DepthWriteMask               = EDepthWriteMask.DSWM_ALL;
            DSDescEqual.DepthFunc                    = EComparisionMode.CMP_EQUAL;
            DSDescEqual.StencilEnable                = 0;
            DSDescEqual.StencilReadMask              = 0xFF;
            DSDescEqual.StencilWriteMask             = 0xFF;
            DSDescEqual.FrontFace.StencilDepthFailOp = EStencilOp.STOP_KEEP;
            DSDescEqual.FrontFace.StencilFailOp      = EStencilOp.STOP_KEEP;
            DSDescEqual.FrontFace.StencilFunc        = EComparisionMode.CMP_NEVER;
            DSDescEqual.BackFace.StencilDepthFailOp  = EStencilOp.STOP_KEEP;
            DSDescEqual.BackFace.StencilFailOp       = EStencilOp.STOP_KEEP;
            DSDescEqual.BackFace.StencilFunc         = EComparisionMode.CMP_NEVER;
            DSDescEqual.StencilRef                   = 0;
            mDSEqual = CEngine.Instance.DepthStencilStateManager.GetDepthStencilState(RHICtx, DSDescEqual);

            //blend state
            CBlendStateDesc ShadowBlendDesc = new CBlendStateDesc();

            ShadowBlendDesc.InitForShadow();
            mShadowBlendStat = CEngine.Instance.BlendStateManager.GetBlendState(RHICtx, ShadowBlendDesc);

            CBlendStateDesc OpaqueBlendDesc = new CBlendStateDesc();

            OpaqueBlendDesc.InitForOpacity();
            mOpaqueBlendStat = CEngine.Instance.BlendStateManager.GetBlendState(RHICtx, OpaqueBlendDesc);

            CBlendStateDesc TranslucentBlendDesc = new CBlendStateDesc();

            TranslucentBlendDesc.InitForTranslucency();
            mTranslucentBlendStat = CEngine.Instance.BlendStateManager.GetBlendState(RHICtx, TranslucentBlendDesc);

            {
                CBlendStateDesc bldDesc = new CBlendStateDesc();
                bldDesc.InitForTranslucency();
                bldDesc.RenderTarget0.SrcBlend  = EBlend.BLD_ONE;
                bldDesc.RenderTarget0.DestBlend = EBlend.BLD_ONE;
                mAddColorBlendStat = CEngine.Instance.BlendStateManager.GetBlendState(RHICtx, bldDesc);
            }

            CBlendStateDesc SnapshotBlendDesc = new CBlendStateDesc();

            SnapshotBlendDesc.InitForSnapshot();
            mSnapshotBlendStat = CEngine.Instance.BlendStateManager.GetBlendState(RHICtx, SnapshotBlendDesc);


            Image2DShadingEnvs[(int)PrebuildPassIndex.PPI_Default] = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.Mesh.CImage2DShadingEnv>();
            mOtherShadingEnvs.Add(Image2DShadingEnvs[(int)PrebuildPassIndex.PPI_Default]);

            Font2DShadingEnvs[(int)PrebuildPassIndex.PPI_Default] = Bricks.FreeTypeFont.CFTShadingEnv.GetFTShadingEnv();
            mOtherShadingEnvs.Add(Font2DShadingEnvs[(int)PrebuildPassIndex.PPI_Default]);

            Graphics.CGfxShadingEnv temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxDefaultSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileBloomUSSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileBloomDSSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileBloomSetUpSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileBloomBlurHSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileBloomBlurVSE>();
            mOtherShadingEnvs.Add(temp);

            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileCopySE>();
            mOtherShadingEnvs.Add(temp);

            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxHitProxyAxisSE>();
            mOtherShadingEnvs.Add(temp);

            //picked editor;
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxPickedBlurHSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxPickedBlurVSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxPickedHollowSE>();
            mOtherShadingEnvs.Add(temp);

            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileCopyEditorSE>();
            mOtherShadingEnvs.Add(temp);

            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileSunShaftMaskSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileSunShaftBlurSE>();
            mOtherShadingEnvs.Add(temp);

            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileAoMaskSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileAoBlurHSE>();
            mOtherShadingEnvs.Add(temp);
            temp = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <Graphics.EnvShader.CGfxMobileAoBlurVSE>();
            mOtherShadingEnvs.Add(temp);
        }