Exemplo n.º 1
0
        internal void StepUpdateProbe(MyCullQuery cullQuery)
        {
            if (state == 0)
            {
                position = MyEnvironment.CameraPosition;// +Vector3.UnitY * 4;
            }

            if (state < 6)
            {
                int faceId = state;
                MyImmediateRC.RC.DeviceContext.ClearDepthStencilView(m_cubemapDepth.SubresourceDsv(faceId), DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1, 0);
                MyImmediateRC.RC.DeviceContext.ClearRenderTargetView(workCubemap.SubresourceRtv(faceId), new Color4(0, 0, 0, 0));

                var localViewProj = PrepareLocalEnvironmentMatrix(MyEnvironment.CameraPosition - position, new Vector2I(CubeMapResolution, CubeMapResolution), faceId, 10000.0f);
                var viewProj      = MatrixD.CreateTranslation(-position) * localViewProj;

                cullQuery.AddForwardPass(ref localViewProj, ref viewProj, new MyViewport(0, 0, CubeMapResolution, CubeMapResolution), m_cubemapDepth.SubresourceDsv(faceId), workCubemap.SubresourceRtv(faceId));

                ++state;
                return;
            }
        }
Exemplo n.º 2
0
            internal void StepUpdateProbe()
            {
                if (state == 0)
                {
                    position = MyEnvironment.CameraPosition + Vector3.UnitY * 4;
                }

                if (state < 6)
                {
                    int faceId = state;
                    MyImmediateRC.RC.Context.ClearDepthStencilView(m_cubemapDepth.SubresourceDsv(faceId), DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1, 0);
                    MyImmediateRC.RC.Context.ClearRenderTargetView(workCubemap.SubresourceRtv(faceId), new Color4(0, 0, 0, 0));

                    var localViewProj = Matrix.CreateTranslation(MyEnvironment.CameraPosition - position) * PrepareLocalEnvironmentMatrix(Vector3.Zero, new Vector2I(256, 256), faceId, 40.0f);
                    var viewProj      = MatrixD.CreateTranslation(-position) * localViewProj;

                    AddForwardCamera(ref localViewProj, ref viewProj, new MyViewport(0, 0, 256, 256), m_cubemapDepth.SubresourceDsv(faceId), workCubemap.SubresourceRtv(faceId));

                    ++state;
                    return;
                }
            }
Exemplo n.º 3
0
        internal static void Combine(RwTexId targetArray, MyShadowCascades firstCascades, MyShadowCascades secondCascades)
        {
            if (!MyRender11.Settings.EnableShadows)
            {
                return;
            }

            ProfilerShort.Begin("MyShadowCascadesPostProcess.Combine");
            MyGpuProfiler.IC_BeginBlock("MyShadowCascadesPostProcess.Combine");

            firstCascades.FillConstantBuffer(firstCascades.CascadeConstantBuffer);
            secondCascades.FillConstantBuffer(secondCascades.CascadeConstantBuffer);
            secondCascades.PostProcessor.MarkCascadesInStencil(secondCascades.CascadeInfo);

            MyRenderContext renderContext = MyRenderContext.Immediate;
            DeviceContext   deviceContext = renderContext.DeviceContext;

            deviceContext.PixelShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);
            deviceContext.PixelShader.SetConstantBuffer(10, firstCascades.CascadeConstantBuffer);
            deviceContext.PixelShader.SetConstantBuffer(11, secondCascades.CascadeConstantBuffer);
            deviceContext.PixelShader.SetConstantBuffer(12, m_inverseConstants);

            for (int subresourceIndex = 0; subresourceIndex < targetArray.Description2d.ArraySize; ++subresourceIndex)
            {
                renderContext.BindGBufferForRead(0, MyGBuffer.Main);
                deviceContext.OutputMerger.SetTargets((DepthStencilView)null, (RenderTargetView)targetArray.SubresourceRtv(subresourceIndex));
                deviceContext.PixelShader.SetShaderResource(0, firstCascades.CascadeShadowmapArray.SubresourceSrv(subresourceIndex));
                deviceContext.PixelShader.SetShaderResource(1, secondCascades.CascadeShadowmapArray.ShaderView);
                //deviceContext.PixelShader.SetShaderResource(4, MyGBuffer.Main.DepthStencil.m_SRV_stencil);
                renderContext.SetPS(m_combinePS);

                Matrix inverseCascadeMatrix = MatrixD.Transpose(MatrixD.Invert(firstCascades.CascadeInfo[subresourceIndex].CurrentLocalToProjection * MyMatrixHelpers.ClipspaceToTexture));
                var    mapping = MyMapping.MapDiscard(m_inverseConstants);
                mapping.WriteAndPosition(ref inverseCascadeMatrix);
                mapping.Unmap();

                MyScreenPass.DrawFullscreenQuad(new MyViewport(0, 0, targetArray.Description2d.Width, targetArray.Description2d.Height));
            }

            deviceContext.OutputMerger.SetTargets(null as DepthStencilView, null as RenderTargetView);
            deviceContext.PixelShader.SetShaderResource(0, null);
            deviceContext.PixelShader.SetShaderResource(1, null);
            deviceContext.PixelShader.SetShaderResource(2, null);
            MyGpuProfiler.IC_EndBlock();
            ProfilerShort.End();
        }