• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Rendering.RenderContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SiliconStudio.Xenko.Rendering.RenderContext的典型用法代码示例。如果您正苦于以下问题:C# RenderContext类的具体用法?C# RenderContext怎么用?C# RenderContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RenderContext类属于SiliconStudio.Xenko.Rendering命名空间,在下文中一共展示了RenderContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PrepareCore

 protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
 {
     if (lightComponentForwardRenderer != null)
     {
         lightComponentForwardRenderer.Draw(context);
     }
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:7,代码来源:LightComponentRenderer.cs


示例2: DrawCore

        protected override void DrawCore(RenderContext context, RenderFrame output)
        {
            var input = Input.GetSafeRenderFrame(context);

            // If RenderFrame input or output are null, we can't do anything
            if (input == null)
            {
                return;
            }

            // If an effect is set, we are using it
            if (Effect != null)
            {
                Effect.SetInput(0, input);
                if (input.DepthStencil != null)
                {
                    Effect.SetInput(1, input.DepthStencil);
                }
                Effect.SetOutput(output);
                Effect.Draw(context);
            }
            else if (input != output)
            {
                // Else only use a scaler if input and output don't match
                // TODO: Is this something we want by default or we just don't output anything?
                var effect = context.GetSharedEffect<ImageScaler>();
                effect.SetInput(0, input);
                effect.SetOutput(output);
                effect.Draw(context);
            }
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:31,代码来源:SceneEffectRenderer.cs


示例3: DrawCore

        protected override void DrawCore(RenderContext context, RenderFrame output)
        {
            var graphicsDevice = context.GraphicsDevice;

            // clear the targets
            if (output.DepthStencil != null && (ClearFlags == ClearRenderFrameFlags.ColorAndDepth || ClearFlags == ClearRenderFrameFlags.DepthOnly))
            {
                const DepthStencilClearOptions ClearOptions = DepthStencilClearOptions.DepthBuffer | DepthStencilClearOptions.Stencil;
                graphicsDevice.Clear(output.DepthStencil, ClearOptions, Depth, Stencil);
            }

            if (ClearFlags == ClearRenderFrameFlags.ColorAndDepth || ClearFlags == ClearRenderFrameFlags.ColorOnly)
            {
                foreach (var renderTarget in output.RenderTargets)
                {
                    if (renderTarget != null)
                    {
                        // If color is in GammeSpace and rendertarget is either SRgb or HDR, use a linear value to clear the buffer.
                        // TODO: We will need to move this color transform code to a shareable component
                        var color = Color.ToColorSpace(ColorSpace, (renderTarget.Format.IsSRgb() || renderTarget.Format.IsHDR()) ? ColorSpace.Linear : graphicsDevice.ColorSpace);
                        graphicsDevice.Clear(renderTarget, color);
                    }
                }
            }
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:25,代码来源:ClearRenderFrameRenderer.cs


示例4: DrawCore

        protected override void DrawCore(RenderContext context, RenderItemCollection renderItems, int fromIndex, int toIndex)
        {
            var graphicsDevice = context.GraphicsDevice;
            var destination = new RectangleF(0, 0, 1, 1);

            // find the last background to display with valid texture
            BackgroundComponent background = null;
            for (var i = toIndex; i >= fromIndex; --i)
            {
                background = (BackgroundComponent)renderItems[i].DrawContext;
                if (background.Texture != null)
                    break;
            }

            // Abort if not valid background component
            if (background == null || background.Texture == null)
                return;

            var texture = background.Texture;
            var target = CurrentRenderFrame;
            var imageBufferMinRatio = Math.Min(texture.ViewWidth / (float)target.Width, texture.ViewHeight / (float)target.Height);
            var sourceSize = new Vector2(target.Width * imageBufferMinRatio, target.Height * imageBufferMinRatio);
            var source = new RectangleF((texture.ViewWidth - sourceSize.X) / 2, (texture.ViewHeight - sourceSize.Y) / 2, sourceSize.X, sourceSize.Y);

            spriteBatch.Parameters.Add(BackgroundEffectKeys.Intensity, background.Intensity);
            spriteBatch.Begin(SpriteSortMode.FrontToBack, graphicsDevice.BlendStates.Opaque, graphicsDevice.SamplerStates.LinearClamp, graphicsDevice.DepthStencilStates.None, null, backgroundEffect);
            spriteBatch.Draw(texture, destination, source, Color.White, 0, Vector2.Zero);
            spriteBatch.End();
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:29,代码来源:BackgroundComponentRenderer.cs


示例5: LoadContent

        protected override void LoadContent()
        {
            var assetManager = Services.GetSafeServiceAs<ContentManager>();
            var graphicsContext = Services.GetSafeServiceAs<GraphicsContext>();

            // Preload the scene if it exists
            if (InitialSceneUrl != null && assetManager.Exists(InitialSceneUrl))
            {
                SceneInstance = new SceneInstance(Services, assetManager.Load<Scene>(InitialSceneUrl));
            }

            if (MainRenderFrame == null)
            {
                // TODO GRAPHICS REFACTOR Check if this is a good idea to use Presenter targets
                MainRenderFrame = RenderFrame.FromTexture(GraphicsDevice.Presenter?.BackBuffer, GraphicsDevice.Presenter?.DepthStencilBuffer);
                if (MainRenderFrame != null)
                {
                    previousWidth = MainRenderFrame.Width;
                    previousHeight = MainRenderFrame.Height;
                }
            }

            // Create the drawing context
            renderContext = RenderContext.GetShared(Services);
            renderDrawContext = new RenderDrawContext(Services, renderContext, graphicsContext);
        }
开发者ID:cg123,项目名称:xenko,代码行数:26,代码来源:SceneSystem.cs


示例6: UpdateCameraToRenderView

        public static void UpdateCameraToRenderView(RenderContext context, RenderView renderView)
        {
            var camera = context.Tags.Get(CameraComponentRendererExtensions.Current);
            var sceneCameraRenderer = context.Tags.Get(SceneCameraRenderer.Current);

            if (camera == null || sceneCameraRenderer == null)
                return;

            // Setup viewport size
            var currentViewport = sceneCameraRenderer.ComputedViewport;
            var aspectRatio = currentViewport.AspectRatio;

            // Update the aspect ratio
            if (camera.UseCustomAspectRatio)
            {
                aspectRatio = camera.AspectRatio;
            }

            // If the aspect ratio is calculated automatically from the current viewport, update matrices here
            camera.Update(aspectRatio);

            // Copy camera data
            renderView.View = camera.ViewMatrix;
            renderView.Projection = camera.ProjectionMatrix;
            renderView.NearClipPlane = camera.NearClipPlane;
            renderView.FarClipPlane = camera.FarClipPlane;
            renderView.Frustum = camera.Frustum;

            // Copy scene camera renderer data
            renderView.CullingMask = sceneCameraRenderer.CullingMask;
            renderView.CullingMode = sceneCameraRenderer.CullingMode;
            renderView.ViewSize = new Vector2(sceneCameraRenderer.ComputedViewport.Width, sceneCameraRenderer.ComputedViewport.Height);

            Matrix.Multiply(ref renderView.View, ref renderView.Projection, out renderView.ViewProjection);
        }
开发者ID:cg123,项目名称:xenko,代码行数:35,代码来源:CameraRenderModeBase.cs


示例7: UpdateParameters

        public static void UpdateParameters(RenderContext context, CameraComponent camera)
        {
            if (camera == null) throw new ArgumentNullException("camera");

            // Setup viewport size
            var currentViewport = context.GraphicsDevice.Viewport;
            var aspectRatio = currentViewport.AspectRatio;

            // Update the aspect ratio
            if (camera.UseCustomAspectRatio)
            {
                aspectRatio = camera.AspectRatio;
            }

            // If the aspect ratio is calculated automatically from the current viewport, update matrices here
            camera.Update(aspectRatio);

            // Store the current view/projection matrix in the context
            var viewParameters = context.Parameters;
            viewParameters.Set(TransformationKeys.View, camera.ViewMatrix);
            viewParameters.Set(TransformationKeys.Projection, camera.ProjectionMatrix);
            viewParameters.Set(TransformationKeys.ViewProjection, camera.ViewProjectionMatrix);
            viewParameters.Set(CameraKeys.NearClipPlane, camera.NearClipPlane);
            viewParameters.Set(CameraKeys.FarClipPlane, camera.FarClipPlane);
            viewParameters.Set(CameraKeys.VerticalFieldOfView, camera.VerticalFieldOfView);
            viewParameters.Set(CameraKeys.OrthoSize, camera.OrthographicSize);
            viewParameters.Set(CameraKeys.ViewSize, new Vector2(currentViewport.Width, currentViewport.Height));
            viewParameters.Set(CameraKeys.AspectRatio, aspectRatio);

            //viewParameters.Set(CameraKeys.FocusDistance, camera.FocusDistance);
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:31,代码来源:CameraComponentRenderer.cs


示例8: Setup

 /// <summary>
 /// Setups the current material using the graphics device.
 /// </summary>
 /// <param name="graphicsDevice">Graphics device to setup</param>
 /// <param name="viewMatrix">The camera's View matrix</param>
 /// <param name="projMatrix">The camera's Projection matrix</param>
 public virtual void Setup(RenderContext context)
 {
     if (!IsInitialized)
     {
         InitializeCore(context);
         IsInitialized = true;
     }          
 }
开发者ID:cg123,项目名称:xenko,代码行数:14,代码来源:ParticleMaterial.cs


示例9: ClearRenderTarget

 public void ClearRenderTarget(RenderContext context)
 {
     if (!IsRenderTargetCleared)
     {
         context.GraphicsDevice.Clear(Texture, DepthStencilClearOptions.DepthBuffer);
         IsRenderTargetCleared = true;
     }
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:8,代码来源:ShadowMapAtlasTexture.cs


示例10: ActivateOutput

 /// <summary>
 /// Activates the output to the current <see cref="GraphicsDevice"/>.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="disableDepth">if set to <c>true</c> [disable depth].</param>
 public void ActivateOutput(RenderContext context, bool disableDepth = false)
 {
     var output = GetOutput(context);
     if (output != null)
     {
         ActivateOutputCore(context, output, disableDepth);
     }
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:13,代码来源:SceneRendererBase.cs


示例11: Draw

 /// <summary>
 /// Draws this renderer with the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <exception cref="System.ArgumentNullException">context</exception>
 /// <exception cref="System.InvalidOperationException">Cannot use a different context between Load and Draw</exception>
 public void Draw(RenderContext context)
 {
     if (Enabled)
     {
         PreDrawCoreInternal(context);
         DrawCore(context);
         PostDrawCoreInternal(context);
     }
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:15,代码来源:RendererBase.cs


示例12: PrepareCore

        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
        {
            var cameraState = context.GetCurrentCamera();

            if (cameraState == null)
                return;

            UpdateParameters(context, cameraState);
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:9,代码来源:CameraComponentRenderer.cs


示例13: Draw

 public void Draw(RenderContext context, RenderItemCollection renderItems, int fromIndex, int toIndex)
 {
     if (Enabled)
     {
         PreDrawCoreInternal(context);
         DrawCore(context, renderItems, fromIndex, toIndex);
         PostDrawCoreInternal(context);
     }
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:9,代码来源:EntityComponentRendererBase.cs


示例14: PrepareCore

        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
        {
            skyboxProcessor = SceneInstance.GetProcessor<SkyboxProcessor>();
            if (skyboxProcessor == null)
            {
                return;
            }

            var skybox = skyboxProcessor.ActiveSkyboxBackground;

            // do not draw if no active skybox or the skybox is not included in the current entity group
            if (skybox == null || !CurrentCullingMask.Contains(skybox.Entity.Group))
                return;

            // Copy camera/pass parameters
            context.Parameters.CopySharedTo(skyboxEffect.Parameters);

            // Show irradiance in the background
            if (skybox.Background == SkyboxBackground.Irradiance)
            {
                foreach (var parameterKeyValue in skybox.Skybox.DiffuseLightingParameters)
                {
                    if (parameterKeyValue.Key == SkyboxKeys.Shader)
                    {
                        skyboxEffect.Parameters.Set(SkyboxKeys.Shader, (ShaderSource)parameterKeyValue.Value);
                    }
                    else
                    {
                        skyboxEffect.Parameters.SetObject(parameterKeyValue.Key.ComposeWith("skyboxColor"), parameterKeyValue.Value);
                    }
                }
            }
            else
            {
                // TODO: Should we better use composition on "skyboxColor" for parameters?

                // Copy Skybox parameters
                if (skybox.Skybox != null)
                {
                    foreach (var parameterKeyValue in skybox.Skybox.Parameters)
                    {
                        if (parameterKeyValue.Key == SkyboxKeys.Shader)
                        {
                            skyboxEffect.Parameters.Set(SkyboxKeys.Shader, (ShaderSource)parameterKeyValue.Value);
                        }
                        else
                        {
                            skyboxEffect.Parameters.SetObject(parameterKeyValue.Key, parameterKeyValue.Value);
                        }
                    }
                }
            }

            // Fake as the skybox was in front of all others (as opaque are rendered back to front)
            opaqueList.Add(new RenderItem(this, skybox, float.NegativeInfinity));
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:56,代码来源:SkyboxComponentRenderer.cs


示例15: DrawCore

        protected override void DrawCore(RenderContext context)
        {
            // TODO: Find a better extensibility point for PixelStageSurfaceFilter
            var currentFilter = context.Parameters.Get(MaterialKeys.PixelStageSurfaceFilter);
            if (!ReferenceEquals(currentFilter, MaterialFilter))
            {
                context.Parameters.Set(MaterialKeys.PixelStageSurfaceFilter, MaterialFilter);
            }

            base.DrawCore(context);
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:11,代码来源:CameraRendererModeForward.cs


示例16: Collect

        public override void Collect(RenderContext context)
        {
            base.Collect(context);

            // Update view parameters
            UpdateCameraToRenderView(context, MainRenderView);

            // Collect render objects
            var visibilityGroup = context.Tags.Get(SceneInstance.CurrentVisibilityGroup);
            visibilityGroup.Collect(MainRenderView);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:11,代码来源:CameraRenderModeBase.cs


示例17: LoadContent

        protected override async Task LoadContent()
        {
            await base.LoadContent();

            hdrTexture = Content.Load<Texture>("HdrTexture");
            hdrRenderTexture = Texture.New2D(GraphicsDevice, hdrTexture.Width, hdrTexture.Height, 1, hdrTexture.Description.Format, TextureFlags.ShaderResource | TextureFlags.RenderTarget);
            drawEffectContext = RenderContext.GetShared(Services);
            postProcessingEffects = new PostProcessingEffects(drawEffectContext);
            postProcessingEffects.BrightFilter.Threshold = 100.0f;
            postProcessingEffects.Bloom.DownScale = 2;
            postProcessingEffects.Bloom.Enabled = true;
            postProcessingEffects.Bloom.ShowOnlyBloom = true;
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:13,代码来源:TestImageEffect.cs


示例18: LoadContent

        protected override async Task LoadContent()
        {
            await base.LoadContent();

            spriteBatch = new SpriteBatch(GraphicsDevice);
            
            inputTexture = Asset.Load<Texture>("uv");
            var groupCounts = new Int3(inputTexture.Width / ReductionRatio, inputTexture.Height / ReductionRatio, 1);
            outputTexture = Texture.New2D(GraphicsDevice, groupCounts.X, groupCounts.Y, 1, PixelFormat.R8G8B8A8_UNorm, TextureFlags.UnorderedAccess | TextureFlags.ShaderResource);
            displayedTexture = outputTexture;

            drawEffectContext = RenderContext.GetShared(Services);
            computeShaderEffect = new ComputeEffectShader(drawEffectContext) { ShaderSourceName = "ComputeShaderTestEffect", ThreadGroupCounts = groupCounts };
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:14,代码来源:TestComputeShader.cs


示例19: LoadContent

        protected override async Task LoadContent()
        {
            await base.LoadContent();

            cubemapSpriteEffect = EffectSystem.LoadEffect("CubemapSprite").WaitForResult();

            drawEffectContext = RenderContext.GetShared(Services);
            lamberFilter = new LambertianPrefilteringSH(drawEffectContext);
            renderSHEffect = new SphericalHarmonicsRendererEffect();
            renderSHEffect.Initialize(drawEffectContext);

            spriteBatch = new SpriteBatch(GraphicsDevice);
            inputCubemap = Asset.Load<Texture>("CubeMap");
            outputCubemap = Texture.NewCube(GraphicsDevice, 256, 1, PixelFormat.R8G8B8A8_UNorm, TextureFlags.RenderTarget | TextureFlags.ShaderResource).DisposeBy(this);
            displayedCubemap = outputCubemap;
        }
开发者ID:hsabaleuski,项目名称:paradox,代码行数:16,代码来源:TestLambertPrefilteringSH.cs


示例20: PrepareCore

        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
        {
            var backgroundProcessor = SceneInstance.GetProcessor<BackgroundComponentProcessor>();
            if (backgroundProcessor == null)
                return;

            foreach (var backgroundComponent in backgroundProcessor.Backgrounds)
            {
                // Perform culling on group and accept
                if (!CurrentCullingMask.Contains(backgroundComponent.Entity.Group))
                    continue;

                opaqueList.Add(new RenderItem(this, backgroundComponent, float.NegativeInfinity)); // render background first so that it can replace a clear frame
                return; // draw only one background by group
            }
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:16,代码来源:BackgroundComponentRenderer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Messages.ServerMessage类代码示例发布时间:2022-05-26
下一篇:
C# Graphics.Texture类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap