protected override void AfterLoadContent(IContentManager manager, PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory)
        {
            base.AfterLoadContent(manager, ginfo, factory);
            this.ginfo = ginfo;

            pointLightEffect = factory.GetEffect("PrePass/plight");
            _clearGBuffer    = factory.GetEffect("PrePass/ClearGBuffer");
            _lighting        = factory.GetEffect("PrePass/LightingLpp");

            sphereModel = new SimpleModel(factory, "Model/Dsphere");
            ForwardPass = new ForwardPass(ForwardPassDescription.Default());
            _width      = ginfo.BackBufferWidth;
            _height     = ginfo.BackBufferHeight;

            _cwDepthState = new DepthStencilState();
            _cwDepthState.DepthBufferWriteEnable = false;
            _cwDepthState.DepthBufferFunction    = CompareFunction.LessEqual;

            _ccwDepthState = new DepthStencilState();
            _ccwDepthState.DepthBufferWriteEnable = false;
            _ccwDepthState.DepthBufferFunction    = CompareFunction.GreaterEqual;

            _directionalDepthState = new DepthStencilState();;
            _directionalDepthState.DepthBufferWriteEnable = false;
            _directionalDepthState.DepthBufferFunction    = CompareFunction.Greater;


            _depthStateDrawLights = new DepthStencilState();

            //we draw our volumes with front-face culling, so we have to use GreaterEqual here
            _depthStateDrawLights.DepthBufferFunction = CompareFunction.GreaterEqual;
            //with our z-buffer reconstructed we only need to read it
            _depthStateDrawLights.DepthBufferWriteEnable = false;

            _depthStateReconstructZ = new DepthStencilState
            {
                DepthBufferEnable      = true,
                DepthBufferWriteEnable = true,
                DepthBufferFunction    = CompareFunction.Always
            };

            _lightAddBlendState = new BlendState()
            {
                AlphaSourceBlend      = Blend.One,
                ColorSourceBlend      = Blend.One,
                AlphaDestinationBlend = Blend.One,
                ColorDestinationBlend = Blend.One,
            };

            CreateGBuffer(factory);
        }
示例#2
0
        /// <summary>
        /// Sets the world and render technich.
        /// </summary>
        /// <param name="renderTech">The render tech.</param>
        /// <param name="world">The world.</param>
        protected override void SetWorldAndRenderTechnich(out IRenderTechnic renderTech, out IWorld world)
        {
            world = new IWorld(new BepuPhysicWorld(-0.97f, true), new SimpleCuller());

            DeferredRenderTechnicInitDescription desc = DeferredRenderTechnicInitDescription.Default();

            desc.UseFloatingBufferForLightMap = true;
            ///For transparency working right
            ForwardPassDescription fpd = desc.ForwardPass.GetForwardPassDescription();

            fpd.DeferredSortByCameraDistance = true;
            desc.ForwardPass.ApplyForwardPassDescription(fpd);
            renderTech = new DeferredRenderTechnic(desc);
        }
示例#3
0
        /// <summary>
        /// Sets the world and render technich.
        /// </summary>
        /// <param name="renderTech">The render tech.</param>
        /// <param name="world">The world.</param>
        protected override void SetWorldAndRenderTechnich(out IRenderTechnic renderTech, out IWorld world)
        {
            world = new IWorld(new BepuPhysicWorld(-9.7f, true), new SimpleCuller());

            DeferredRenderTechnicInitDescription desc = DeferredRenderTechnicInitDescription.Default();

            desc.UseFloatingBufferForLightMap = true;
            ///For transparency works right, we need to order the objects
            ///by distance from the camera
            ///this is not perfect, but works on most situations
            ForwardPassDescription fpd = desc.ForwardPass.GetForwardPassDescription();

            fpd.ForwardSortByCameraDistance = true; ///defalut is false
            desc.ForwardPass.ApplyForwardPassDescription(fpd);
            renderTech = new DeferredRenderTechnic(desc);
        }