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


C# RenderContext类代码示例

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


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

示例1: Render

		public void Render(RenderContext context)
		{
			var value = Template.GetValue(context.RenderModel, this.Key);

			if(context.RenderValue != null)
			{
				var rendered = context.RenderValue(this.Key, value, context);
				if(rendered)
				{
					return;
				}
			}

			if(value == null)
			{
				return;
			}

			var iRenderizable = value as IRenderizable;
			if(iRenderizable != null)
			{
				iRenderizable.Render(context);
			}
			else
			{
				context.Writer.Write(value.ToString());
			}
		}
开发者ID:scorredoira,项目名称:Sfx.Templates,代码行数:28,代码来源:ModelValue.cs

示例2: FrustumCulling

        // TODO: Find a way to replug this

        /// <summary>
        /// Adds a default frustum culling for rendering only meshes that are only inside the frustum/
        /// </summary>
        /// <param name="modelRenderer">The model renderer.</param>
        /// <returns>ModelRenderer.</returns>
        //public static ModelComponentRenderer AddDefaultFrustumCulling(this ModelComponentRenderer modelRenderer)
        //{
        //    modelRenderer.UpdateMeshes = FrustumCulling;
        //    return modelRenderer;
        //}

        private static void FrustumCulling(RenderContext context, FastList<RenderMesh> meshes)
        {
            Matrix viewProjection, mat1, mat2;

            // Compute view * projection
            context.Parameters.Get(TransformationKeys.View, out mat1);
            context.Parameters.Get(TransformationKeys.Projection, out mat2);
            Matrix.Multiply(ref mat1, ref mat2, out viewProjection);

            var frustum = new BoundingFrustum(ref viewProjection);

            for (var i = 0; i < meshes.Count; ++i)
            {
                var renderMesh = meshes[i];

                // Fast AABB transform: http://zeuxcg.org/2010/10/17/aabb-from-obb-with-component-wise-abs/
                // Get world matrix
                renderMesh.Mesh.Parameters.Get(TransformationKeys.World, out mat1);

                // Compute transformed AABB (by world)
                var boundingBoxExt = new BoundingBoxExt(renderMesh.Mesh.BoundingBox);
                boundingBoxExt.Transform(mat1);

                // Perform frustum culling
                if (!frustum.Contains(ref boundingBoxExt))
                {
                    meshes.SwapRemoveAt(i--);
                }
            }
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:43,代码来源:ModelRendererExtensions.cs

示例3: 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:releed,项目名称:paradox,代码行数:29,代码来源:BackgroundComponentRenderer.cs

示例4: OnRenderContent

 protected override void OnRenderContent(RenderContext context)
 {
     if (Head != null)
         Head.OnRender(context);
     if (Body != null)
         Body.OnRender(context);
 }
开发者ID:Kation,项目名称:WebPresentation,代码行数:7,代码来源:HtmlPage.cs

示例5: RadiancePrefilteringGGX

 /// <summary>
 /// Create a new instance of the class.
 /// </summary>
 /// <param name="context">the context</param>
 public RadiancePrefilteringGGX(RenderContext context)
     : base(context, "RadiancePrefilteringGGX")
 {
     computeShader = new ComputeEffectShader(context) { ShaderSourceName = "RadiancePrefilteringGGXEffect" };
     DoNotFilterHighestLevel = true;
     samplingsCount = 1024;
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:11,代码来源:RadiancePrefilteringGGX.cs

示例6: RadiancePrefilteringGGXNoCompute

 /// <summary>
 /// Create a new instance of the class.
 /// </summary>
 /// <param name="context">the context</param>
 public RadiancePrefilteringGGXNoCompute(RenderContext context)
     : base(context, "RadiancePrefilteringGGX")
 {
     shader = new ImageEffectShader("RadiancePrefilteringGGXNoComputeEffect");
     DoNotFilterHighestLevel = true;
     samplingsCount = 1024;
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:11,代码来源:RadiancePrefilteringGGXNoCompute.cs

示例7: Render

 public override bool Render(RenderContext dest)
 {
     dest.ForceLineBreak();
     dest.Append(Comment);
     dest.ForceLineBreak();
     return false;
 }
开发者ID:blyry,项目名称:MiniME,代码行数:7,代码来源:StatementComment.cs

示例8: Render

 public override bool Render(RenderContext dest)
 {
     dest.Append("while(");
     Condition.Render(dest);
     dest.Append(")");
     return Code.RenderIndented(dest);
 }
开发者ID:blyry,项目名称:MiniME,代码行数:7,代码来源:StatementWhile.cs

示例9: renderPixel

        public Color renderPixel(int x, int y)
        {
            Color color;
              HitRecord hitRecord = new HitRecord();
              Ray ray;
              RenderContext renderContext = new RenderContext( this.scene );

              float step = 2 / (float)this.scene.getXResolution();
              float xStart = -1 + ( 0.5f * step );
              float yStart = (-(float)this.scene.getYResolution() * (0.5f * step)) + (0.5f * step);

              ray = this.scene.getCamera().generateRay( xStart + (x * step), yStart + (y * step) );
              this.scene.traceRay( ray, hitRecord, renderContext );

              if ( hitRecord.getT() == float.PositiveInfinity || hitRecord.getMaterial() == null || hitRecord.getPrimitive() == null ) {

             color = this.scene.getBackground().getColor( renderContext, ray );

              } else {

             color = hitRecord.getMaterial().shade( renderContext, ray, hitRecord, 1 );

              }

              return color;
        }
开发者ID:dknutsen,项目名称:dokray,代码行数:26,代码来源:Core.cs

示例10: 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:RainsSoft,项目名称:paradox,代码行数:31,代码来源:CameraComponentRenderer.cs

示例11: Render

        /// <summary>
        /// Clears the current render target (which must be the G-buffer).
        /// </summary>
        /// <param name="context">The render context.</param>
        public void Render(RenderContext context)
        {
            if (context == null)
            throw new ArgumentNullException("context");

              context.Validate(_effect);

              var graphicsDevice = _effect.GraphicsDevice;
              var savedRenderState = new RenderStateSnapshot(graphicsDevice);
              graphicsDevice.DepthStencilState = DepthStencilState.None;
              graphicsDevice.RasterizerState = RasterizerState.CullNone;
              graphicsDevice.BlendState = BlendState.Opaque;

              // Clear to maximum depth.
              _parameterDepth.SetValue(1.0f);

              // The environment is facing the camera.
              // --> Set normal = cameraBackward.
              var cameraNode = context.CameraNode;
              _parameterNormal.SetValue((cameraNode != null) ? (Vector3)cameraNode.ViewInverse.GetColumn(2).XYZ : Vector3.Backward);

              // Clear specular to arbitrary value.
              _parameterSpecularPower.SetValue(1.0f);

              _effect.CurrentTechnique.Passes[0].Apply();

              // Draw full-screen quad using clip space coordinates.
              graphicsDevice.DrawQuad(
            new VertexPositionTexture(new Vector3(-1, 1, 0), new Vector2(0, 0)),
            new VertexPositionTexture(new Vector3(1, -1, 0), new Vector2(1, 1)));

              savedRenderState.Restore();
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:37,代码来源:ClearGBufferRenderer.cs

示例12: Render

 public override bool Render(RenderContext dest)
 {
     dest.Append("with(");
     Expression.Render(dest);
     dest.Append(")");
     return Code.RenderIndented(dest);
 }
开发者ID:blyry,项目名称:MiniME,代码行数:7,代码来源:StatementWith.cs

示例13: Render

        public override void Render(RenderContext context)
        {
            if (renderHost.RenderTechnique == renderHost.RenderTechniquesManager.RenderTechniques.Get(DeferredRenderTechniqueNames.Deferred) ||
                renderHost.RenderTechnique == renderHost.RenderTechniquesManager.RenderTechniques.Get(DeferredRenderTechniqueNames.GBuffer))
            {
                return;
            }

            if (this.IsRendering)
            {
                /// --- turn-on the light
                lightColors[lightIndex] = this.Color;
            }
            else
            {
                // --- turn-off the light
                lightColors[lightIndex] = new global::SharpDX.Color4(0, 0, 0, 0);
            }

            /// --- Set lighting parameters
            lightPositions[lightIndex] = this.Position.ToVector4();
            lightAtt[lightIndex] = new Vector4((float)this.Attenuation.X, (float)this.Attenuation.Y, (float)this.Attenuation.Z, (float)this.Range);

            /// --- Update lighting variables
            this.vLightPos.Set(lightPositions);
            this.vLightColor.Set(lightColors);
            this.vLightAtt.Set(lightAtt);
            this.iLightType.Set(lightTypes);
        }
开发者ID:chantsunman,项目名称:helix-toolkit,代码行数:29,代码来源:PointLight3D.cs

示例14: PrepareCore

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

示例15: DrawCore

        protected override void DrawCore(RenderContext context)
        {
            var input = GetSafeInput(0);

            // TODO: Check that input is power of two
            // input.Size.Width 

            Texture fromTexture = input;
            Texture downTexture = null;
            var nextSize = input.Size;
            bool isFirstPass = true;
            while (nextSize.Width > 3 && nextSize.Height > 3)
            {
                var previousSize = nextSize;
                nextSize = nextSize.Down2();

                // If the next half size of the texture is not an exact *2, make it 1 pixel larger to avoid loosing pixels min/max.
                if ((nextSize.Width * 2) < previousSize.Width)
                {
                    nextSize.Width += 1;
                }
                if ((nextSize.Height * 2) < previousSize.Height)
                {
                    nextSize.Height += 1;
                }

                downTexture = NewScopedRenderTarget2D(nextSize.Width, nextSize.Height, PixelFormat.R32G32_Float, 1);

                effect.Parameters.Set(DepthMinMaxShaderKeys.TextureMap, fromTexture);
                effect.Parameters.Set(DepthMinMaxShaderKeys.TextureReduction, fromTexture);

                effect.SetOutput(downTexture);
                effect.Parameters.Set(IsFirstPassKey, isFirstPass);
                effect.Draw(context);

                fromTexture = downTexture;

                isFirstPass = false;
            }

            readback.SetInput(downTexture);
            readback.Draw();
            IsResultAvailable = readback.IsResultAvailable;
            if (IsResultAvailable)
            {
                float min = float.MaxValue;
                float max = -float.MaxValue;
                var results = readback.Result;
                foreach (var result in results)
                {
                    min = Math.Min(result.X, min);
                    if (result.Y != 1.0f)
                    {
                        max = Math.Max(result.Y, max);
                    }
                }

                Result = new Vector2(min, max);
            }
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:60,代码来源:DepthMinMax.cs


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