GetEffect() public method

Gets the texture effect at the specified index.
public GetEffect ( int index ) : TextureEffect
index int Index of the texture effect to retrieve.
return TextureEffect
コード例 #1
0
ファイル: FFPTexturing.cs プロジェクト: ryan-bunker/axiom3d
		private bool NeedsTextureMatrix( TextureUnitState textureUnitState )
		{
			for ( int i = 0; i < textureUnitState.NumEffects; i++ )
			{
				TextureEffect effi = textureUnitState.GetEffect( i );

				switch ( effi.type )
				{
					case TextureEffectType.EnvironmentMap:
					case TextureEffectType.ProjectiveTexture:
					case TextureEffectType.Rotate:
					case TextureEffectType.Transform:
					case TextureEffectType.UScroll:
					case TextureEffectType.UVScroll:
					case TextureEffectType.VScroll:
						return true;
				}
			}
			//TODO
			var matTexture = new Matrix4(); //textureUnitState.getTextureTransform();

			//Resolve texture matrix parameter
			if ( matTexture != Matrix4.Identity )
			{
				return true;
			}

			return false;
		}
コード例 #2
0
        /// <summary>
        ///		Utility function for setting all the properties of a texture unit at once.
        ///		This method is also worth using over the individual texture unit settings because it
        ///		only sets those settings which are different from the current settings for this
        ///		unit, thus minimising render state changes.
        /// </summary>
        /// <param name="textureUnit">Index of the texture unit to configure</param>
        /// <param name="layer">Reference to a TextureLayer object which defines all the settings.</param>
        public virtual void SetTextureUnit(int unit, TextureUnitState unitState, bool fixedFunction)
        {
            // This method is only ever called to set a texture unit to valid details
            // The method _disableTextureUnit is called to turn a unit off

            // Vertex texture binding?
            if (caps.CheckCap(Capabilities.VertexTextureFetch) &&
                !caps.CheckCap(Capabilities.VertexTextureFetch)) {
                if (unitState.BindingType == GpuProgramType.Vertex) {
                    // Bind vertex texture
                    SetVertexTexture(unit, unitState);
                    // bind nothing to fragment unit (hardware isn't shared but fragment
                    // unit can't be using the same index
                    SetTexture(unit, true, string.Empty);
                }
                else {
                    // vice versa
                    SetVertexTexture(unit, unitState);
                    SetTexture(unit, true, unitState.TextureName);
                }
            }
            else {
                // Shared vertex / fragment textures or no vertex texture support
                // Bind texture (may be blank)
                SetTexture(unit, true, unitState.TextureName);
            }

            // Set texture coordinate set
            // SetTextureCoordSet(unit, unitState.TextureCoordSet);
            if (!fixedFunction)
                // From Direct3D9 error log:
                // Texture coordinate index in the stage must be equal to the stage index when programmable vertex pipeline is used
                SetTextureCoordSet(unit, unit);

            // Texture layer filtering
            SetTextureUnitFiltering(
                unit,
                unitState.GetTextureFiltering(FilterType.Min),
                unitState.GetTextureFiltering(FilterType.Mag),
                unitState.GetTextureFiltering(FilterType.Mip));

            // Texture layer anistropy
            SetTextureLayerAnisotropy(unit, unitState.TextureAnisotropy);

            // Set mipmap biasing
            SetTextureMipmapBias(unit, unitState.MipmapBias);

            // Texture addressing mode
            UVWAddressingMode uvw = unitState.GetTextureAddressingMode();
            SetTextureAddressingMode(unit, uvw);
            // Set texture border colour only if required
            if (uvw.u == TextureAddressing.Border ||
                uvw.v == TextureAddressing.Border ||
                uvw.w == TextureAddressing.Border)
                SetTextureBorderColor(unit, unitState.TextureBorderColor);

            // This stuff only gets done for the fixed function pipeline.  It is not needed
            // if we are using a pixel shader.
            if (fixedFunction)
            {
                // Tex Coord Set
                SetTextureCoordSet(unit, unitState.TextureCoordSet);

                // set the texture blending mode
                SetTextureBlendMode(unit, unitState.ColorBlendMode);

                // set the texture blending mode
                SetTextureBlendMode(unit, unitState.AlphaBlendMode);

                bool anyCalcs = false;

                for (int i = 0; i < unitState.NumEffects; i++)
                {
                    TextureEffect effect = unitState.GetEffect(i);

                    switch (effect.type)
                    {
                        case TextureEffectType.EnvironmentMap:
                            if ((EnvironmentMap)effect.subtype == EnvironmentMap.Curved)
                            {
                                SetTextureCoordCalculation(unit, TexCoordCalcMethod.EnvironmentMap);
                                anyCalcs = true;
                            }
                            else if ((EnvironmentMap)effect.subtype == EnvironmentMap.Planar)
                            {
                                SetTextureCoordCalculation(unit, TexCoordCalcMethod.EnvironmentMapPlanar);
                                anyCalcs = true;
                            }
                            else if ((EnvironmentMap)effect.subtype == EnvironmentMap.Reflection)
                            {
                                SetTextureCoordCalculation(unit, TexCoordCalcMethod.EnvironmentMapReflection);
                                anyCalcs = true;
                            }
                            else if ((EnvironmentMap)effect.subtype == EnvironmentMap.Normal)
                            {
                                SetTextureCoordCalculation(unit, TexCoordCalcMethod.EnvironmentMapNormal);
                                anyCalcs = true;
                            }
                            break;

                        case TextureEffectType.Scroll:
                        case TextureEffectType.Rotate:
                        case TextureEffectType.Transform:
                            break;

                        case TextureEffectType.ProjectiveTexture:
                            SetTextureCoordCalculation(unit, TexCoordCalcMethod.ProjectiveTexture, effect.frustum);
                            anyCalcs = true;
                            break;
                    } // switch
                } // for

                // Ensure any previous texcoord calc settings are reset if there are now none
                if (!anyCalcs)
                {
                    SetTextureCoordCalculation(unit, TexCoordCalcMethod.None);
                }

                // set the texture matrix to that of the current layer for any transformations
                SetTextureMatrix(unit, unitState.TextureMatrix);
            }
        }
コード例 #3
0
ファイル: FFPTexturing.cs プロジェクト: ryan-bunker/axiom3d
		private TexCoordCalcMethod GetCalcMethod( TextureUnitState textureUnitState )
		{
			TexCoordCalcMethod texCoordCalcMethod = TexCoordCalcMethod.None;
			var effectMap = new List<TextureEffect>();
			for ( int i = 0; i < textureUnitState.NumEffects; i++ )
			{
				effectMap.Add( textureUnitState.GetEffect( i ) );
			}

			foreach ( var effi in effectMap )
			{
				switch ( effi.type )
				{
					case TextureEffectType.EnvironmentMap:
						//TODO
						//if (effi.subtype == Curved)
						//{
						//    texCoordCalcMethod = TexCoordCalcMethod.EnvironmentMap;
						//}
						//else if (effi.subtype == Planar)
						//{
						//    texCoordCalcMethod = TexCoordCalcMethod.EnvironmentMapPlanar;
						//}
						//else if (effi.subtype == Reflection)
						//{
						//    texCoordCalcMethod = TexCoordCalcMethod.EnvironmentMapReflection;
						//}
						//else if (effi.subtype == Normal)
						//{
						//    texCoordCalcMethod = TexCoordCalcMethod.EnvironmentMapNormal;
						//}

						break;
					case TextureEffectType.ProjectiveTexture:
						texCoordCalcMethod = TexCoordCalcMethod.ProjectiveTexture;
						break;
					case TextureEffectType.Rotate:
					case TextureEffectType.Transform:
					case TextureEffectType.UScroll:
					case TextureEffectType.UVScroll:
					case TextureEffectType.VScroll:
						break;
				}
			}

			return texCoordCalcMethod;
		}