当前位置: 首页>>代码示例>>C#>>正文


C# Device.GetRenderTargetData方法代码示例

本文整理汇总了C#中Device.GetRenderTargetData方法的典型用法代码示例。如果您正苦于以下问题:C# Device.GetRenderTargetData方法的具体用法?C# Device.GetRenderTargetData怎么用?C# Device.GetRenderTargetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device的用法示例。


在下文中一共展示了Device.GetRenderTargetData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MeasureLuminance

        public void MeasureLuminance(Effect effect, Device device)
        {
            Surface OriginalRenderTarget = device.GetRenderTarget(0);
            Vector2[] sampleOffsets = new Vector2[16];
            Texture dest = ToneMapTex[nToneMapTex - 1];

            SurfaceDescription destDescr = dest.GetLevelDescription(0);
            SurfaceDescription sourceDescr = Renderer.Instance.RenderSurface.Description;

            GetSampleOffsets_DownScale2x2_Lum(sourceDescr.Width, sourceDescr.Height, destDescr.Width, destDescr.Height, ref sampleOffsets);
            effect.SetValue<Vector2>(new EffectHandle("g_avSampleOffsets"), sampleOffsets);
            effect.Technique = "DownScale2x2_Lum_RGBE8";

            Surface destSurface = dest.GetSurfaceLevel(0);
            device.SetRenderTarget(0, destSurface);
            Surface OriginalDS = device.DepthStencilSurface;
            device.DepthStencilSurface = Renderer.Instance.RenderDepthSurface;
            device.SetSamplerState(0, SamplerState.MagFilter, (int)TextureFilter.Linear);
            device.SetSamplerState(0, SamplerState.MinFilter, (int)TextureFilter.Linear);
            device.SetTexture(0, Renderer.Instance.RenderTexture);

            Renderer.Instance.DrawFullScreenQuad();
            device.SetTexture(0, null);

            effect.Technique = "DownScale3x3_RGBE8";
            for (int i = nToneMapTex - 1; i > 0; i--)
            {
                Surface source = ToneMapTex[i].GetSurfaceLevel(0);
                dest = ToneMapTex[i - 1];
                destSurface = dest.GetSurfaceLevel(0);
                GetSampleOffsetsets_DownScale3x3(destSurface.Description.Width, destSurface.Description.Height, ref sampleOffsets);
                effect.SetValue<Vector2>(new EffectHandle("g_avSampleOffsets"), sampleOffsets);

                device.SetRenderTarget(0, destSurface);
                device.SetTexture(0, ToneMapTex[i]);
                //device.SetSamplerState(0, SamplerStageStates.MagFilter, (int)TextureFilter.Point);
                //device.SetSamplerState(0, SamplerStageStates.MinFilter, (int)TextureFilter.Point);

                Renderer.Instance.DrawFullScreenQuad();

                device.SetTexture(0, null);
            }

            // Add calculated luminance to average
            if (CurrentAvgToneMap == -1)
            {
                Rectangle avgrect = new Rectangle(new Point(), new Size(1, 1));
                device.StretchRectangle(ToneMapTex[0].GetSurfaceLevel(0), avgrect, avgToneMap[0].GetSurfaceLevel(0), avgrect, TextureFilter.Point);

                CurrentAvgToneMap = 0;
            }
            else
            {
                effect.Technique = "CalcAvgLum_RGBE8";
                device.SetTexture(0, avgToneMap[CurrentAvgToneMap]); // "main" average
                int other = (CurrentAvgToneMap == 0 ? 1 : 0);
                device.SetTexture(1, ToneMapTex[0]); // new average to be added
                Surface surf = avgToneMap[other].GetSurfaceLevel(0);
                device.SetRenderTarget(0, surf); // unused "main" average texture used as rendertarget

                Renderer.Instance.DrawFullScreenQuad();

                device.SetTexture(0, null);
                device.SetTexture(1, null);
                CurrentAvgToneMap = other; // swap avgTonemap usage next frame
            }

            device.SetRenderTarget(0, OriginalRenderTarget);
            device.DepthStencilSurface = OriginalDS;

            // Read result
            device.GetRenderTargetData(AverageLum.GetSurfaceLevel(0), LockableAverage.GetSurfaceLevel(0));
            DataRectangle rect = LockableAverage.LockRectangle(0, LockFlags.ReadOnly);
            Color4 color = new Color4(rect.Data.Read<int>());
            LockableAverage.UnlockRectangle(0);

            // Revert LogLum encoding
            float invLogLumRange = 1.0f / (MaxLogLum + MinLogLum);
            float logLumOffset = MinLogLum * invLogLumRange;
            double avgLum = Math.Exp((color.Alpha) / (invLogLumRange + logLumOffset));
            effect.SetValue("avgLogLum", avgLum);
            //System.Console.WriteLine(avgLum);
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:83,代码来源:ToneMap.cs

示例2: copyBuffer

 private void copyBuffer(Device device, Surface bb)
 {
     device.StretchRectangle(bb, _renderTarget0, TextureFilter.Point);
     device.GetRenderTargetData(_renderTarget0, _renderTarget);
 }
开发者ID:stani,项目名称:GScreensTool,代码行数:5,代码来源:DXHookD3D9.cs

示例3: Screenshot

        public void Screenshot(Device device, string filename, int primCount, int numVertices)
        {
            Surface surf;
            using (Surface backbuffer = device.GetBackBuffer(0, 0))
            {
                using (SwapChain sc = device.GetSwapChain(0))
                {
                    surf = Surface.CreateOffscreenPlain(device, sc.PresentParameters.BackBufferWidth, sc.PresentParameters.BackBufferHeight, sc.PresentParameters.BackBufferFormat, Pool.SystemMemory);
                }
                try
                {
                    device.GetRenderTargetData(backbuffer, surf);
                    if(!Directory.Exists(filename + "Output"))
                        Directory.CreateDirectory(filename + "Output");

                    if (!Directory.Exists(filename + "Output\\"+ Interface.exe))
                        Directory.CreateDirectory(filename + "Output\\" + Interface.exe);

                    Surface.ToFile(surf, filename + "Output\\" + Interface.exe + "\\" + primCount + "x" + numVertices + ".bmp", ImageFileFormat.Bmp);
                    surf.Dispose();
                }
                catch (Exception e)
                {
                    Interface.ReportException(e);
                }
            }
        }
开发者ID:emist,项目名称:D3DTextureLoggerClient,代码行数:27,代码来源:Main.cs


注:本文中的Device.GetRenderTargetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。