Ejemplo n.º 1
0
        public static D3D9.TextureOperation ConvertEnum(LayerBlendOperationEx lbo, D3D9.Capabilities devCaps)
        {
            switch (lbo)
            {
            case LayerBlendOperationEx.Source1:
                return(D3D9.TextureOperation.SelectArg1);

            case LayerBlendOperationEx.Source2:
                return(D3D9.TextureOperation.SelectArg2);

            case LayerBlendOperationEx.Modulate:
                return(D3D9.TextureOperation.Modulate);

            case LayerBlendOperationEx.ModulateX2:
                return(D3D9.TextureOperation.Modulate2X);

            case LayerBlendOperationEx.ModulateX4:
                return(D3D9.TextureOperation.Modulate4X);

            case LayerBlendOperationEx.Add:
                return(D3D9.TextureOperation.Add);

            case LayerBlendOperationEx.AddSigned:
                return(D3D9.TextureOperation.AddSigned);

            case LayerBlendOperationEx.AddSmooth:
                return(D3D9.TextureOperation.AddSmooth);

            case LayerBlendOperationEx.Subtract:
                return(D3D9.TextureOperation.Subtract);

            case LayerBlendOperationEx.BlendDiffuseAlpha:
                return(D3D9.TextureOperation.BlendDiffuseAlpha);

            case LayerBlendOperationEx.BlendTextureAlpha:
                return(D3D9.TextureOperation.BlendTextureAlpha);

            case LayerBlendOperationEx.BlendCurrentAlpha:
                return(D3D9.TextureOperation.BlendCurrentAlpha);

            case LayerBlendOperationEx.BlendManual:
                return(D3D9.TextureOperation.BlendFactorAlpha);

            case LayerBlendOperationEx.DotProduct:
                return((devCaps.TextureOperationCaps & D3D9.TextureOperationCaps.DotProduct3) != 0
                                                ? D3D9.TextureOperation.DotProduct3
                                                : D3D9.TextureOperation.Modulate);

            case LayerBlendOperationEx.BlendDiffuseColor:
                return((devCaps.TextureOperationCaps & D3D9.TextureOperationCaps.Lerp) != 0
                                                ? D3D9.TextureOperation.Lerp
                                                : D3D9.TextureOperation.Modulate);
            }

            return(0);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        private void ToggleBlending()
        {
            if (++currentLbxIndex == blendModes.Length)
            {
                currentLbxIndex = 0;
            }

            // get the current color blend mode to use
            currentLbx =
                (LayerBlendOperationEx)Enum.Parse(typeof(LayerBlendOperationEx), blendModes[currentLbxIndex], true);

            PrepareEntity(meshes[currentMeshIndex]);

            // update the UI
            OverlayElementManager.Instance.GetElement("Example/CubeMapping/Material").Text =
                string.Format("[M] Material: {0}", blendModes[currentLbxIndex]);
        }
        /// <summary>
        ///    
        /// </summary>
        private void ToggleBlending()
        {
            if(++currentLbxIndex == blendModes.Length) {
                currentLbxIndex = 0;
            }

            // get the current color blend mode to use
            currentLbx =
                (LayerBlendOperationEx)Enum.Parse(typeof(LayerBlendOperationEx), blendModes[currentLbxIndex], true);

            PrepareEntity(meshes[currentMeshIndex]);

            // update the UI
            OverlayElementManager.Instance.GetElement("Example/CubeMapping/Material").Text =
                string.Format("[M] Material: {0}", blendModes[currentLbxIndex]);
        }
Ejemplo n.º 4
0
		/// <summary>
		///		Static method for converting LayerBlendOperationEx enum values to the Direct3D 
		///		TextureOperation enum.
		/// </summary>
		/// <param name="blendop"></param>
		/// <returns></returns>
		public static XFG.BlendFunction Convert( LayerBlendOperationEx blendop )
		{
			XFG.BlendFunction xnaTexOp = 0;


			// figure out what is what
			switch ( blendop )
			{

				/*case LayerBlendOperationEx.Source1:
					d3dTexOp = XFG.Blend.BlendFunction.SelectArg1;
					break;

				case LayerBlendOperationEx.Source2:
					d3dTexOp = XFG.TextureOperation.SelectArg2;
					break;
				
				case LayerBlendOperationEx.Modulate:
					d3dTexOp = BlendFunction.moXFG.TextureOperation.Modulate;
					break;

				case LayerBlendOperationEx.ModulateX2:
					d3dTexOp = XFG.TextureOperation.Modulate2X;
					break;

				case LayerBlendOperationEx.ModulateX4:
					d3dTexOp = XFG.TextureOperation.Modulate4X;
					break;*/

				case LayerBlendOperationEx.Add:
					xnaTexOp = XFG.BlendFunction.Add;
					break;

				case LayerBlendOperationEx.AddSigned:
					xnaTexOp = XFG.BlendFunction.Add;
					break;

				case LayerBlendOperationEx.AddSmooth:
					xnaTexOp = XFG.BlendFunction.Add;
					break;

				case LayerBlendOperationEx.Subtract:
					xnaTexOp = XFG.BlendFunction.Subtract;
					break;
				default:
					xnaTexOp = XFG.BlendFunction.Add;
					break;

				/*  case LayerBlendOperationEx.BlendDiffuseAlpha:
					  d3dTexOp = XFG.BlendFunction..BlendDiffuseAlpha;
					  break;

				  case LayerBlendOperationEx.BlendTextureAlpha:
					  d3dTexOp = XFG.TextureOperation.BlendTextureAlpha;
					  break;

				  case LayerBlendOperationEx.BlendCurrentAlpha:
					  d3dTexOp = XFG.TextureOperation.BlendCurrentAlpha;
					  break;

				  case LayerBlendOperationEx.BlendManual:
					  d3dTexOp = XFG.TextureOperation.BlendFactorAlpha;
					  break;

				  case LayerBlendOperationEx.DotProduct:
					  if ( Root.Instance.RenderSystem.Caps.CheckCap( Capabilities.Dot3 ) )
					  {
						  d3dTexOp = XFG.TextureOperation.DotProduct3;
					  }
					  else
					  {
						  d3dTexOp = XFG.TextureOperation.Modulate;
					  }
					  break;*/
			} // end switch

			return xnaTexOp;
		}
Ejemplo n.º 5
0
		/// <summary>
		///		Static method for converting LayerBlendOperationEx enum values to the Direct3D
		///		TextureOperation enum.
		/// </summary>
		/// <param name="blendop"></param>
		/// <returns></returns>
		public static D3D.TextureOperation ConvertEnum( LayerBlendOperationEx blendop )
		{
			D3D.TextureOperation d3dTexOp = 0;

			// figure out what is what
			switch ( blendop )
			{
				case LayerBlendOperationEx.Source1:
					d3dTexOp = D3D.TextureOperation.SelectArg1;
					break;

				case LayerBlendOperationEx.Source2:
					d3dTexOp = D3D.TextureOperation.SelectArg2;
					break;

				case LayerBlendOperationEx.Modulate:
					d3dTexOp = D3D.TextureOperation.Modulate;
					break;

				case LayerBlendOperationEx.ModulateX2:
					d3dTexOp = D3D.TextureOperation.Modulate2X;
					break;

				case LayerBlendOperationEx.ModulateX4:
					d3dTexOp = D3D.TextureOperation.Modulate4X;
					break;

				case LayerBlendOperationEx.Add:
					d3dTexOp = D3D.TextureOperation.Add;
					break;

				case LayerBlendOperationEx.AddSigned:
					d3dTexOp = D3D.TextureOperation.AddSigned;
					break;

				case LayerBlendOperationEx.AddSmooth:
					d3dTexOp = D3D.TextureOperation.AddSmooth;
					break;

				case LayerBlendOperationEx.Subtract:
					d3dTexOp = D3D.TextureOperation.Subtract;
					break;

				case LayerBlendOperationEx.BlendDiffuseAlpha:
					d3dTexOp = D3D.TextureOperation.BlendDiffuseAlpha;
					break;

				case LayerBlendOperationEx.BlendTextureAlpha:
					d3dTexOp = D3D.TextureOperation.BlendTextureAlpha;
					break;

				case LayerBlendOperationEx.BlendCurrentAlpha:
					d3dTexOp = D3D.TextureOperation.BlendCurrentAlpha;
					break;

				case LayerBlendOperationEx.BlendManual:
					d3dTexOp = D3D.TextureOperation.BlendFactorAlpha;
					break;

				case LayerBlendOperationEx.DotProduct:
					if ( Root.Instance.RenderSystem.Capabilities.HasCapability( Capabilities.Dot3 ) )
					{
						d3dTexOp = D3D.TextureOperation.DotProduct3;
					}
					else
					{
						d3dTexOp = D3D.TextureOperation.Modulate;
					}
					break;
			} // end switch

			return d3dTexOp;
		}
Ejemplo n.º 6
0
        public static TextureOperation ConvertEnum(LayerBlendOperationEx lbo, SlimDX.Direct3D9.Capabilities devCaps)
	    {
            switch (lbo)
            {
                case LayerBlendOperationEx.Source1:
                    return TextureOperation.SelectArg1;
                case LayerBlendOperationEx.Source2:
                    return TextureOperation.SelectArg2;
                case LayerBlendOperationEx.Modulate:
                    return TextureOperation.Modulate;
                case LayerBlendOperationEx.ModulateX2:
                    return TextureOperation.Modulate2X;
                case LayerBlendOperationEx.ModulateX4:
                    return TextureOperation.Modulate4X;
                case LayerBlendOperationEx.Add:
                    return TextureOperation.Add;
                case LayerBlendOperationEx.AddSigned:
                    return TextureOperation.AddSigned;
                case LayerBlendOperationEx.AddSmooth:
                    return TextureOperation.AddSmooth;
                case LayerBlendOperationEx.Subtract:
                    return TextureOperation.Subtract;
                case LayerBlendOperationEx.BlendDiffuseAlpha:
                    return TextureOperation.BlendDiffuseAlpha;
                case LayerBlendOperationEx.BlendTextureAlpha:
                    return TextureOperation.BlendTextureAlpha;
                case LayerBlendOperationEx.BlendCurrentAlpha:
                    return TextureOperation.BlendCurrentAlpha;
                case LayerBlendOperationEx.BlendManual:
                    return TextureOperation.BlendFactorAlpha;
                case LayerBlendOperationEx.DotProduct:
                    return (devCaps.TextureOperationCaps & TextureOperationCaps.DotProduct3) != 0 ? TextureOperation.DotProduct3 : TextureOperation.Modulate;
                case LayerBlendOperationEx.BlendDiffuseColor:
                    return (devCaps.TextureOperationCaps & TextureOperationCaps.Lerp) != 0 ? TextureOperation.Lerp : TextureOperation.Modulate;
            }
            return 0;
	    }
Ejemplo n.º 7
0
		/// <summary>
		///    Overloaded method.
		/// </summary>
		/// <param name="operation">The operation to be used, e.g. modulate (multiply), add, subtract.</param>
		public void SetAlphaOperation( LayerBlendOperationEx operation )
		{
			SetAlphaOperation( operation, LayerBlendSource.Texture, LayerBlendSource.Current, 1.0f, 1.0f, 0.0f );
		}
Ejemplo n.º 8
0
		/// <summary>
		///    Sets the alpha operation to be applied to this texture.
		/// </summary>
		/// <remarks>
		///    This works in exactly the same way as SetColorOperation, except
		///    that the effect is applied to the level of alpha (i.e. transparency)
		///    of the texture rather than its color. When the alpha of a texel (a pixel
		///    on a texture) is 1.0, it is opaque, wheras it is fully transparent if the
		///    alpha is 0.0. Please refer to the SetColorOperation method for more info.
		/// </remarks>
		/// <param name="operation">The operation to be used, e.g. modulate (multiply), add, subtract.</param>
		/// <param name="source1">The source of the first alpha value to the operation e.g. texture alpha.</param>
		/// <param name="source2">The source of the second alpha value to the operation e.g. current surface alpha.</param>
		/// <param name="arg1">Manually supplied alpha value (only required if source1 = LayerBlendSource.Manual).</param>
		/// <param name="arg2">Manually supplied alpha value (only required if source2 = LayerBlendSource.Manual).</param>
		/// <param name="blendFactor">Manually supplied 'blend' value - only required for operations
		///    which require manual blend e.g. LayerBlendOperationEx.BlendManual.
		/// </param>
		public void SetAlphaOperation( LayerBlendOperationEx operation, LayerBlendSource source1, LayerBlendSource source2,
		                               Real arg1, Real arg2, Real blendFactor )
		{
			this.alphaBlendMode.operation = operation;
			this.alphaBlendMode.source1 = source1;
			this.alphaBlendMode.source2 = source2;
			this.alphaBlendMode.alphaArg1 = arg1;
			this.alphaBlendMode.alphaArg2 = arg2;
			this.alphaBlendMode.blendFactor = blendFactor;
		}
Ejemplo n.º 9
0
		/// <summary>
		///		Overloaded method.
		/// </summary>
		/// <param name="operation">The operation to be used, e.g. modulate (multiply), add, subtract.</param>
		/// <param name="source1">The source of the first color to the operation e.g. texture color.</param>
		/// <param name="source2">The source of the second color to the operation e.g. current surface color.</param>
		/// <param name="arg1">Manually supplied color value (only required if source1 = Manual).</param>		
		public void SetColorOperationEx( LayerBlendOperationEx operation, LayerBlendSource source1, LayerBlendSource source2,
		                                 ColorEx arg1 )
		{
			SetColorOperationEx( operation, source1, source2, arg1, ColorEx.White, 0.0f );
		}
Ejemplo n.º 10
0
		/// <summary>
		///		Overloaded method.
		/// </summary>
		/// <param name="operation">The operation to be used, e.g. modulate (multiply), add, subtract.</param>
		public void SetColorOperationEx( LayerBlendOperationEx operation )
		{
			SetColorOperationEx( operation, LayerBlendSource.Texture, LayerBlendSource.Current, ColorEx.White, ColorEx.White,
			                     0.0f );
		}
Ejemplo n.º 11
0
		/// <summary>
		///    For setting advanced blending options.
		/// </summary>
		/// <remarks>
		///    This is an extended version of the <see cref="TextureUnitState.SetColorOperation"/> method which allows
		///    extremely detailed control over the blending applied between this and earlier layers.
		///    See the IMPORTANT note below about the issues between mulitpass and multitexturing that
		///    using this method can create.
		///    <p/>
		///    Texture color operations determine how the final color of the surface appears when
		///    rendered. Texture units are used to combine color values from various sources (ie. the
		///    diffuse color of the surface from lighting calculations, combined with the color of
		///    the texture). This method allows you to specify the 'operation' to be used, ie. the
		///    calculation such as adds or multiplies, and which values to use as arguments, such as
		///    a fixed value or a value from a previous calculation.
		///    <p/>
		///    The defaults for each layer are:
		///    <ul>
		///    <li>op = Modulate</li>
		///    <li>source1 = Texture</li>
		///    <li>source2 = Current</li>
		///    </ul>
		///    ie. each layer takes the color results of the previous layer, and multiplies them
		///    with the new texture being applied. Bear in mind that colors are RGB values from
		///    0.0 - 1.0 so multiplying them together will result in values in the same range,
		///    'tinted' by the multiply. Note however that a straight multiply normally has the
		///    effect of darkening the textures - for this reason there are brightening operations
		///    like ModulateX2. See the LayerBlendOperation and LayerBlendSource enumerated
		///    types for full details.
		///    <p/>
		///    Because of the limitations on some underlying APIs (Direct3D included)
		///    the Texture argument can only be used as the first argument, not the second.
		///    <p/>
		///    The final 3 parameters are only required if you decide to pass values manually
		///    into the operation, i.e. you want one or more of the inputs to the color calculation
		///    to come from a fixed value that you supply. Hence you only need to fill these in if
		///    you supply <code>Manual</code> to the corresponding source, or use the 
		///    <code>BlendManual</code> operation.
		///    <p/>
		///    The engine tries to use multitexturing hardware to blend texture layers
		///    together. However, if it runs out of texturing units (e.g. 2 of a GeForce2, 4 on a
		///    GeForce3) it has to fall back on multipass rendering, i.e. rendering the same object
		///    multiple times with different textures. This is both less efficient and there is a smaller
		///    range of blending operations which can be performed. For this reason, if you use this method
		///    you MUST also call <see cref="TextureUnitState.SetColorOpMultipassFallback"/> to specify which effect you
		///    want to fall back on if sufficient hardware is not available.
		///    <p/>
		///    If you wish to avoid having to do this, use the simpler <see cref="TextureUnitState.SetColorOperation"/> method
		///    which allows less flexible blending options but sets up the multipass fallback automatically,
		///    since it only allows operations which have direct multipass equivalents.
		///    <p/>
		///    This has no effect in the programmable pipeline.
		/// </remarks>
		/// <param name="operation">The operation to be used, e.g. modulate (multiply), add, subtract.</param>
		/// <param name="source1">The source of the first color to the operation e.g. texture color.</param>
		/// <param name="source2">The source of the second color to the operation e.g. current surface color.</param>
		/// <param name="arg1">Manually supplied color value (only required if source1 = Manual).</param>
		/// <param name="arg2">Manually supplied color value (only required if source2 = Manual)</param>
		/// <param name="blendFactor">
		///    Manually supplied 'blend' value - only required for operations
		///    which require manual blend e.g. LayerBlendOperationEx.BlendManual
		/// </param>
		public void SetColorOperationEx( LayerBlendOperationEx operation, LayerBlendSource source1, LayerBlendSource source2,
		                                 ColorEx arg1, ColorEx arg2, float blendFactor )
		{
			this.colorBlendMode.operation = operation;
			this.colorBlendMode.source1 = source1;
			this.colorBlendMode.source2 = source2;
			this.colorBlendMode.colorArg1 = arg1;
			this.colorBlendMode.colorArg2 = arg2;
			this.colorBlendMode.blendFactor = blendFactor;
		}
 /// <summary>
 ///    Overloaded method.
 /// </summary>
 public void SetAlphaOperation(LayerBlendOperationEx operation, LayerBlendSource source1, LayerBlendSource source2)
 {
     SetAlphaOperation(operation, source1, source2, 1.0f, 1.0f, 0.0f);
 }
 /// <summary>
 ///    Sets the alpha operation to be applied to this texture.
 /// </summary>
 /// <remarks>
 ///    This works in exactly the same way as SetColorOperation, except
 ///    that the effect is applied to the level of alpha (i.e. transparency)
 ///    of the texture rather than its color. When the alpha of a texel (a pixel
 ///    on a texture) is 1.0, it is opaque, wheras it is fully transparent if the
 ///    alpha is 0.0. Please refer to the SetColorOperation method for more info.
 /// </remarks>
 /// <param name="operation">The operation to be used, e.g. modulate (multiply), add, subtract.</param>
 /// <param name="source1">The source of the first alpha value to the operation e.g. texture alpha.</param>
 /// <param name="source2">The source of the second alpha value to the operation e.g. current surface alpha.</param>
 /// <param name="arg1">Manually supplied alpha value (only required if source1 = LayerBlendSource.Manual).</param>
 /// <param name="arg2">Manually supplied alpha value (only required if source2 = LayerBlendSource.Manual).</param>
 /// <param name="blendFactor">Manually supplied 'blend' value - only required for operations
 ///    which require manual blend e.g. LayerBlendOperationEx.BlendManual.
 /// </param>
 public void SetAlphaOperation(LayerBlendOperationEx operation, LayerBlendSource source1, LayerBlendSource source2, float arg1, float arg2, float blendFactor)
 {
     alphaBlendMode.operation = operation;
     alphaBlendMode.source1 = source1;
     alphaBlendMode.source2 = source2;
     alphaBlendMode.alphaArg1 = arg1;
     alphaBlendMode.alphaArg2 = arg2;
     alphaBlendMode.blendFactor = blendFactor;
 }
Ejemplo n.º 14
0
		/// <summary>
		///		Static method for converting LayerBlendOperationEx enum values to the Direct3D 
		///		TextureOperation enum.
		/// </summary>
		/// <param name="blendop"></param>
		/// <returns></returns>
		public static BlendFunction Convert( LayerBlendOperationEx blendop )
		{
			BlendFunction xnaTexOp = 0;


			// figure out what is what
			switch ( blendop )
			{
				//case LayerBlendOperationEx.Source1:
				//    xnaTexOp = BlendFunction.SelectArg1;
				//    break;

				//case LayerBlendOperationEx.Source2:
				//    xnaTexOp = BlendFunction.SelectArg2;
				//    break;

				//case LayerBlendOperationEx.Modulate:
				//    xnaTexOp = BlendFunction.moXFG.TextureOperation.Modulate;
				//    break;

				//case LayerBlendOperationEx.ModulateX2:
				//    xnaTexOp = BlendFunction.Modulate2X;
				//    break;

				//case LayerBlendOperationEx.ModulateX4:
				//    xnaTexOp = BlendFunction.Modulate4X;
				//    break;

				case LayerBlendOperationEx.Add:
					xnaTexOp = BlendFunction.Add;
					break;

				case LayerBlendOperationEx.AddSigned:
					xnaTexOp = BlendFunction.Add;
					break;

				case LayerBlendOperationEx.AddSmooth:
					xnaTexOp = BlendFunction.Add;
					break;

				case LayerBlendOperationEx.Subtract:
					xnaTexOp = BlendFunction.Subtract;
					break;

				//case LayerBlendOperationEx.BlendDiffuseAlpha:
				//    xnaTexOp = BlendFunction.BlendDiffuseAlpha;
				//    break;

				//case LayerBlendOperationEx.BlendTextureAlpha:
				//    xnaTexOp = BlendFunction.BlendTextureAlpha;
				//    break;

				//case LayerBlendOperationEx.BlendCurrentAlpha:
				//    xnaTexOp = BlendFunction.BlendCurrentAlpha;
				//    break;

				//case LayerBlendOperationEx.BlendManual:
				//    xnaTexOp = BlendFunction.BlendFactorAlpha;
				//    break;

				//case LayerBlendOperationEx.DotProduct:
				//    if ( Root.Instance.RenderSystem.Capabilities.HasCapability( Capabilities.Dot3 ))
				//        xnaTexOp = BlendFunction.DotProduct3;
				//    else
				//        xnaTexOp = BlendFunction.Modulate;
				//    break;

				default:
					xnaTexOp = BlendFunction.Add;
					break;
			} // end switch

			return xnaTexOp;
		}
Ejemplo n.º 15
0
        /// <summary>
        ///		Static method for converting LayerBlendOperationEx enum values to the Direct3D
        ///		TextureOperation enum.
        /// </summary>
        /// <param name="blendop"></param>
        /// <returns></returns>
        public static D3D.TextureOperation ConvertEnum(LayerBlendOperationEx blendop, D3D.Caps devCaps)
        {
            D3D.TextureOperation d3dTexOp = 0;

            // figure out what is what
            switch (blendop)
            {
            case LayerBlendOperationEx.Source1:
                d3dTexOp = D3D.TextureOperation.SelectArg1;
                break;

            case LayerBlendOperationEx.Source2:
                d3dTexOp = D3D.TextureOperation.SelectArg2;
                break;

            case LayerBlendOperationEx.Modulate:
                d3dTexOp = D3D.TextureOperation.Modulate;
                break;

            case LayerBlendOperationEx.ModulateX2:
                d3dTexOp = D3D.TextureOperation.Modulate2X;
                break;

            case LayerBlendOperationEx.ModulateX4:
                d3dTexOp = D3D.TextureOperation.Modulate4X;
                break;

            case LayerBlendOperationEx.Add:
                d3dTexOp = D3D.TextureOperation.Add;
                break;

            case LayerBlendOperationEx.AddSigned:
                d3dTexOp = D3D.TextureOperation.AddSigned;
                break;

            case LayerBlendOperationEx.AddSmooth:
                d3dTexOp = D3D.TextureOperation.AddSmooth;
                break;

            case LayerBlendOperationEx.Subtract:
                d3dTexOp = D3D.TextureOperation.Subtract;
                break;

            case LayerBlendOperationEx.BlendDiffuseAlpha:
                d3dTexOp = D3D.TextureOperation.BlendDiffuseAlpha;
                break;

            case LayerBlendOperationEx.BlendTextureAlpha:
                d3dTexOp = D3D.TextureOperation.BlendTextureAlpha;
                break;

            case LayerBlendOperationEx.BlendCurrentAlpha:
                d3dTexOp = D3D.TextureOperation.BlendCurrentAlpha;
                break;

            case LayerBlendOperationEx.BlendManual:
                d3dTexOp = D3D.TextureOperation.BlendFactorAlpha;
                break;

            case LayerBlendOperationEx.DotProduct:
                if (Root.Instance.RenderSystem.Caps.CheckCap(Capabilities.Dot3))
                {
                    d3dTexOp = D3D.TextureOperation.DotProduct3;
                }
                else
                {
                    d3dTexOp = D3D.TextureOperation.Modulate;
                }
                break;

            case LayerBlendOperationEx.BlendDiffuseColor:
                if (devCaps.TextureOperationCaps.SupportsLerp)
                {
                    d3dTexOp = D3D.TextureOperation.Lerp;
                }
                else
                {
                    d3dTexOp = D3D.TextureOperation.Modulate;
                }
                break;
            } // end switch

            return(d3dTexOp);
        }
Ejemplo n.º 16
0
        /// <summary>
        ///		Static method for converting LayerBlendOperationEx enum values to the Direct3D
        ///		TextureOperation enum.
        /// </summary>
        /// <param name="blendop"></param>
        /// <returns></returns>
        public static BlendFunction Convert(LayerBlendOperationEx blendop)
        {
            BlendFunction xnaTexOp = 0;


            // figure out what is what
            switch (blendop)
            {
            //case LayerBlendOperationEx.Source1:
            //    xnaTexOp = BlendFunction.SelectArg1;
            //    break;

            //case LayerBlendOperationEx.Source2:
            //    xnaTexOp = BlendFunction.SelectArg2;
            //    break;

            //case LayerBlendOperationEx.Modulate:
            //    xnaTexOp = BlendFunction.moXFG.TextureOperation.Modulate;
            //    break;

            //case LayerBlendOperationEx.ModulateX2:
            //    xnaTexOp = BlendFunction.Modulate2X;
            //    break;

            //case LayerBlendOperationEx.ModulateX4:
            //    xnaTexOp = BlendFunction.Modulate4X;
            //    break;

            case LayerBlendOperationEx.Add:
                xnaTexOp = BlendFunction.Add;
                break;

            case LayerBlendOperationEx.AddSigned:
                xnaTexOp = BlendFunction.Add;
                break;

            case LayerBlendOperationEx.AddSmooth:
                xnaTexOp = BlendFunction.Add;
                break;

            case LayerBlendOperationEx.Subtract:
                xnaTexOp = BlendFunction.Subtract;
                break;

            //case LayerBlendOperationEx.BlendDiffuseAlpha:
            //    xnaTexOp = BlendFunction.BlendDiffuseAlpha;
            //    break;

            //case LayerBlendOperationEx.BlendTextureAlpha:
            //    xnaTexOp = BlendFunction.BlendTextureAlpha;
            //    break;

            //case LayerBlendOperationEx.BlendCurrentAlpha:
            //    xnaTexOp = BlendFunction.BlendCurrentAlpha;
            //    break;

            //case LayerBlendOperationEx.BlendManual:
            //    xnaTexOp = BlendFunction.BlendFactorAlpha;
            //    break;

            //case LayerBlendOperationEx.DotProduct:
            //    if ( Root.Instance.RenderSystem.Capabilities.HasCapability( Capabilities.Dot3 ))
            //        xnaTexOp = BlendFunction.DotProduct3;
            //    else
            //        xnaTexOp = BlendFunction.Modulate;
            //    break;

            default:
                xnaTexOp = BlendFunction.Add;
                break;
            }             // end switch

            return(xnaTexOp);
        }