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


C# Rendering.RenderContext类代码示例

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


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


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