Ejemplo n.º 1
0
        public void InitPass(CRenderContext RHICtx, Graphics.CGfxEffect effect, Graphics.CGfxShadingEnv shadingEnv, Graphics.Mesh.CGfxMtlMesh mesh, UInt32 index)
        {
            if (IsEffectValid == 2)
            {
                if (Effect != effect)
                {
                    Effect = effect;
                    if (Effect.CacheData.PerFrameId != UInt32.MaxValue)
                    {
                        BindCBuffer(Effect.ShaderProgram, Effect.CacheData.PerFrameId, CEngine.Instance.PerFrameCBuffer);
                    }
                }
            }
            ShadingEnv = shadingEnv;
            Effect     = effect;
            MtlMesh    = mesh;
            MeshIndex  = index;

            if (mRenderPipeline == null)
            {
                var RplDesc = new CRenderPipelineDesc();
                RenderPipeline = RHICtx.CreateRenderPipeline(RplDesc);
            }

            this.BindGeometry(MtlMesh.mRootSceneMesh.MeshPrimitives, index, 0);
        }
Ejemplo n.º 2
0
        public Graphics.CGfxShadingEnv[] InitEditorMobileShadingEnv(CRenderContext RHICtx)
        {
            InitSystemStates(RHICtx);

            var result = new Graphics.CGfxShadingEnv[(int)PrebuildPassIndex.PPI_Num];

            result[(int)EngineNS.PrebuildPassIndex.PPI_OpaquePbr]            = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxMobileOpaqueSE>();
            result[(int)EngineNS.PrebuildPassIndex.PPI_TransparentPbr]       = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxMobileTranslucentSE>();
            result[(int)EngineNS.PrebuildPassIndex.PPI_CustomTranslucentPbr] = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxMobileCustomTranslucentSE>();

            result[(int)EngineNS.PrebuildPassIndex.PPI_OpaquePbrEditor]            = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxMobileOpaqueEditorSE>();
            result[(int)EngineNS.PrebuildPassIndex.PPI_CustomTranslucentPbrEditor] = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxMobileCustomTranslucentEditorSE>();

            result[(int)EngineNS.PrebuildPassIndex.PPI_HitProxy] = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxHitProxySE>();

            result[(int)EngineNS.PrebuildPassIndex.PPI_PickedEditor] = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxPickedSetUpSE>();

            result[(int)EngineNS.PrebuildPassIndex.PPI_Gizmos]   = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxGizmosSE>();
            result[(int)EngineNS.PrebuildPassIndex.PPI_Snapshot] = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxSnapshotSE>();

            result[(int)EngineNS.PrebuildPassIndex.PPI_SSM] = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxSE_SSM>();

            result[(int)EngineNS.PrebuildPassIndex.PPI_Sky] = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxSE_MobileSky>();

            result[(int)EngineNS.PrebuildPassIndex.PPI_SceneCapture] = CEngine.Instance.ShadingEnvManager.GetGfxShadingEnv <EngineNS.Graphics.EnvShader.CGfxSceneCaptureSE>();

            return(result);
        }
Ejemplo n.º 3
0
        public void OnCookRenderData(Graphics.CGfxShadingEnv ShadingEnv, PrebuildPassIndex ppi)
        {
            //当CookSpecRenderLayerDataToPass调用后的回调,在这里保留一个可以以后做最后渲染数据的hack
            //如Effect

            if (this.ShadingEnv.EnvCode.Version != EnvCodeVersion)
            {
                var src    = this.Effect.Desc;
                var desc   = Graphics.CGfxEffectDesc.CreateDesc(src.MtlShaderPatch, src.MdfQueueShaderPatch, this.ShadingEnv.EnvCode);
                var effect = CEngine.Instance.EffectManager.GetEffect(CEngine.Instance.RenderContext, desc);
                EnvCodeVersion = this.ShadingEnv.EnvCode.Version;
                //await effect.AwaitLoad();
                effect.PreUse((success) =>
                {
                    this.Effect = effect;
                });
            }
        }
Ejemplo n.º 4
0
        public async System.Threading.Tasks.Task <bool> InitPassForViewportView(CRenderContext RHICtx, Graphics.CGfxShadingEnv shadingEnv, Graphics.CGfxMaterialInstance MtlInst,
                                                                                Graphics.Mesh.CGfxMesh ViewportMesh)
        {
            var effect = GetEffect(RHICtx, shadingEnv.EnvCode, MtlInst, ViewportMesh);

            if (effect == null)
            {
                return(false);
            }
            await effect.AwaitLoad();

            if (effect.ShaderProgram == null)
            {
                return(false);
            }

            this.ShadingEnv = shadingEnv;
            this.Effect     = effect;
            this.mMtlInst   = MtlInst;
            this.MtlMesh    = ViewportMesh.MtlMeshArray[0];
            if (mRenderPipeline == null)
            {
                var RplDesc = new CRenderPipelineDesc();
                RenderPipeline = RHICtx.CreateRenderPipeline(RplDesc);
            }

            BindCBuffer(effect.ShaderProgram, effect.CacheData.PerInstanceId, ViewportMesh.MtlMeshArray[0].CBuffer);
            BindCBuffer(effect.ShaderProgram, effect.CacheData.PerFrameId, CEngine.Instance.PerFrameCBuffer);

            this.BindGeometry(ViewportMesh.MeshPrimitives, 0, 0);

            PreUse();

            return(true);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public void Init(RName shaderName, List <CShaderDefinitions.MacroDefine> defs, CGfxShadingEnv env)
 {
     mShaderName = RName.GetRName(shaderName.Name, RName.enRNameType.Engine);
     //mShaderName = shaderName;
     mEnvType      = env.GetType();
     mMacroDefines = new List <CShaderDefinitions.MacroDefine>();
     mMacroDefines.AddRange(defs);
     UpdateHash64();
 }