SetSceneBlending() public méthode

Allows very fine control of blending every Pass with the existing contents of the scene.
This property has been moved to the Pass class, which is accessible via the Technique. For simplicity, this method allows you to set these properties for every current Technique, and for every current Pass within those Techniques. If you need more precision, retrieve the Technique and Pass instances and set the property there.
public SetSceneBlending ( SceneBlendFactor src, SceneBlendFactor dest ) : void
src SceneBlendFactor
dest SceneBlendFactor
Résultat void
Exemple #1
0
		protected override void load()
		{
			// clarabie - nov 18, 2008
			// modified this to check for an existing material instead of always
			// creating a new one. Allows more flexibility, but also specifically allows us to
			// solve the problem of XNA not having fixed function support

			_material = (Material)MaterialManager.Instance.GetByName( "Fonts/" + _name );

			if ( _material == null )
			{

				// create a material for this font
				_material = (Material)MaterialManager.Instance.Create( "Fonts/" + _name, Group );

				TextureUnitState unitState = null;
				bool blendByAlpha = false;

				if ( _fontType == FontType.TrueType )
				{
#if !( XBOX || XBOX360 )
					// create the font bitmap on the fly
					createTexture();

					// a texture layer was added in CreateTexture
					unitState = _material.GetTechnique( 0 ).GetPass( 0 ).GetTextureUnitState( 0 );

					blendByAlpha = true;
#endif
				}
				else
				{
					// load this texture
					// TODO In general, modify any methods like this that throw their own exception rather than returning null, so the caller can decide how to handle a missing resource.
					_texture = TextureManager.Instance.Load( Source, Group, TextureType.TwoD, 0 );

					blendByAlpha = texture.HasAlpha;
					// pre-created font images
					unitState = Material.GetTechnique( 0 ).GetPass( 0 ).CreateTextureUnitState( Source );
				}

				// set texture addressing mode to Clamp to eliminate fuzzy edges
                if ( unitState != null )
                    unitState.SetTextureAddressingMode( TextureAddressing.Clamp );

				// set up blending mode
				if ( blendByAlpha )
				{
					_material.SetSceneBlending( SceneBlendType.TransparentAlpha );
				}
				else
				{
					// assume black background here
					_material.SetSceneBlending( SceneBlendType.Add );
				}
			}
		}
        /// <summary>
        ///    Loads either an image based font, or creates one on the fly from a TrueType font file.
        /// </summary>
        protected override void LoadImpl()
        {
            // create a material for this font
            material = (Material)MaterialManager.Instance.Create("Fonts/" + name);

            TextureUnitState unitState = null;
            bool blendByAlpha = false;

            if (fontType == FontType.TrueType) {
                // create the font bitmap on the fly
                CreateTexture();
                // a texture layer was added in CreateTexture
                unitState = material.GetTechnique(0).GetPass(0).GetTextureUnitState(0);
                blendByAlpha = true;
            }
            else {
                // pre-created font images
                unitState = material.GetTechnique(0).GetPass(0).CreateTextureUnitState(source);
                // load this texture
                // TODO: In general, modify any methods like this that throw their own exception rather than returning null, so the caller can decide how to handle a missing resource.
                Texture texture = TextureManager.Instance.Load(source);
                blendByAlpha = texture.HasAlpha;
            }

            // set texture addressing mode to Clamp to eliminate fuzzy edges
            unitState.TextureAddressing = TextureAddressing.Clamp;

            // set up blending mode
            if(blendByAlpha) {
                material.SetSceneBlending(SceneBlendType.TransparentAlpha);
            }
            else {
                // assume black background here
                material.SetSceneBlending(SceneBlendType.Add);
            }
        }