Пример #1
0
		/// <summary>
		///  Sets the global alpha rejection approach for future renders.
		/// </summary>
		/// <param name="func">The comparison function which must pass for a pixel to be written.</param>
		/// <param name="value">The value to compare each pixels alpha value to (0-255)</param>
		/// <param name="alphaToCoverage">Whether to enable alpha to coverage, if supported</param>
		public override void SetAlphaRejectSettings(CompareFunction func, byte value, bool alphaToCoverage)
		{
			var a2c = false;
			if (func != CompareFunction.AlwaysPass)
			{
				a2c = alphaToCoverage;
			}

			StateManager.BlendState.AlphaBlendFunction = BlendFunction.Add /* XnaHelper.Convert( func )*/;
			//StateManager.BlendState.ReferenceAlpha = val;

			// Alpha to coverage
			if (lasta2c != a2c && Capabilities.HasCapability(Graphics.Capabilities.AlphaToCoverage))
			{
				lasta2c = a2c;
			}
		}
Пример #2
0
		/// <summary>
		/// Sets the mode of operation for depth buffer tests from this point onwards.
		/// </summary>
		/// <remarks>
		/// Sometimes you may wish to alter the behavior of the depth buffer to achieve
		/// special effects. Because it's unlikely that you'll set these options for an entire frame,
		/// but rather use them to tweak settings between rendering objects, this is intended for internal
		/// uses, which will be used by a <see cref="SceneManager"/> implementation rather than directly from 
		/// the client application.
		/// </remarks>
		/// <param name="depthTest">
		/// If true, the depth buffer is tested for each pixel and the frame buffer is only updated
		/// if the depth function test succeeds. If false, no test is performed and pixels are always written.
		/// </param>
		/// <param name="depthWrite">
		/// If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
		/// If false, the depth buffer is left unchanged even if a new pixel is written.
		/// </param>
		/// <param name="depthFunction">Sets the function required for the depth test.</param>
		public override void SetDepthBufferParams(bool depthTest, bool depthWrite, CompareFunction depthFunction)
		{
			StateManager.DepthStencilState.DepthBufferEnable = depthTest;
			StateManager.DepthStencilState.DepthBufferWriteEnable = depthWrite;
			StateManager.DepthStencilState.DepthBufferFunction = XnaHelper.Convert(depthFunction);
		}
Пример #3
0
		/// <summary>
		///    Converts our CompareFunction enum to the XFG.Compare equivalent.
		/// </summary>
		/// <param name="func"></param>
		/// <returns></returns>
		public static XFG.CompareFunction Convert( CompareFunction func )
		{
			switch ( func )
			{
				case CompareFunction.AlwaysFail:
					return XFG.CompareFunction.Never;

				case CompareFunction.AlwaysPass:
					return XFG.CompareFunction.Always;

				case CompareFunction.Equal:
					return XFG.CompareFunction.Equal;

				case CompareFunction.Greater:
					return XFG.CompareFunction.Greater;

				case CompareFunction.GreaterEqual:
					return XFG.CompareFunction.GreaterEqual;

				case CompareFunction.Less:
					return XFG.CompareFunction.Less;

				case CompareFunction.LessEqual:
					return XFG.CompareFunction.LessEqual;

				case CompareFunction.NotEqual:
					return XFG.CompareFunction.NotEqual;
			}

			return 0;
		}