Exemple #1
0
        public static void CaptureWithPoint(EngineNS.Vector3 point,
                                            EngineNS.Matrix worldMatrix,
                                            EngineNS.Graphics.CGfxCamera camera,
                                            EngineNS.CRenderContext rc,
                                            EngineNS.Vector3 camDir,
                                            EngineNS.Vector3 camUp,
                                            UInt32 actorsCount,
                                            EngineNS.Graphics.RenderPolicy.CGfxRP_SceneCapture rp,
                                            UInt32 textureIdx,
                                            ref EngineNS.Support.CBlobObject dataBlob,
                                            ref EngineNS.Support.CBlobObject picBlob)
        {
            var lookat = point + camDir;

            lookat = EngineNS.Vector3.TransformCoordinate(lookat, worldMatrix);
            point  = EngineNS.Vector3.TransformCoordinate(point, worldMatrix);
            camUp  = EngineNS.Vector3.TransformNormal(camUp, worldMatrix);
            camera.LookAtLH(point, lookat, camUp);
            camera.BeforeFrame();

            //world.Tick();
            //world.SlowDrawAll(rc, camera);

            var maxId = actorsCount;

            rp.TickLogic(null, rc);
            camera.SwapBuffer(true);
            rp.TickRender(null);
            //camera.ClearAllRenderLayerData();

            // debug
#pragma warning disable 0162
            if (false)
            {
                var texRGB = rp.CaptureSV.FrameBuffer.GetSRV_RenderTarget(1);
                texRGB.Save2File(rc, "e:/testCapture.bmp", EngineNS.EIMAGE_FILE_FORMAT.BMP);
            }
#pragma warning restore 0162

            if (rp.UseCapture)
            {
                var blob = new EngineNS.Support.CBlobObject();
                blob.PushData(rp.TexData0.Data, rp.TexData0.Size);
                dataBlob = blob;
                if (rp.CaptureRGBData)
                {
                    blob = new EngineNS.Support.CBlobObject();
                    blob.PushData(rp.TexData1.Data, rp.TexData1.Size);
                    picBlob = blob;
                }
                //await EngineNS.CEngine.Instance.EventPoster.Post(() =>
                //{
                //    rp.CaptureSV.mFrameBuffer.GetSRV_RenderTarget(0).Save2File($"D:\\{camIdx}.png", (int)mWidth, (int)mHeight, (int)(mWidth * 4), rp.TexData0.ToBytes(), EngineNS.EIMAGE_FILE_FORMAT.PNG);
                //    rp.CaptureSV.mFrameBuffer.GetSRV_RenderTarget(1).Save2File($"D:\\{camIdx}_ref.png", (int)mWidth, (int)mHeight, (int)(mWidth * 4), rp.TexData1.ToBytes(), EngineNS.EIMAGE_FILE_FORMAT.PNG);

                //    return true;
                //}, EngineNS.Thread.Async.EAsyncTarget.AsyncEditor);
            }

            var cmd            = EngineNS.CEngine.Instance.RenderContext.ImmCommandList;
            var actirIdTexture = rp.GetActoridTexture();
            cmd.CSSetShaderResource(textureIdx, actirIdTexture);


            uint texSize = 512;
            cmd.CSDispatch(texSize / 8, texSize / 8, 1);
        }