Axiom.Graphics.Pass.Split C# (CSharp) Method

Split() public method

Splits this Pass to one which can be handled in the number of texture units specified.
public Split ( int numUnits ) : Pass
numUnits int /// The target number of texture units. ///
return Pass
		public Pass Split( int numUnits )
		{
			// can't split programmable passes
			if ( _fragmentProgramUsage != null )
			{
				throw new Exception( "Passes with fragment programs cannot be automatically split.  Define a fallback technique instead" );
			}

			if ( textureUnitStates.Count > numUnits )
			{
				int start = textureUnitStates.Count - numUnits;

				Pass newPass = _parent.CreatePass();

				// get a reference ot the texture unit state at the split position
				TextureUnitState state = (TextureUnitState)textureUnitStates[ start ];

				// set the new pass to fallback using scene blending
				newPass.SetSceneBlending( state.ColorBlendFallbackSource, state.ColorBlendFallbackDest );

				// add the rest of the texture units to the new pass
				for ( int i = start; i < textureUnitStates.Count; i++ )
				{
					state = (TextureUnitState)textureUnitStates[ i ];
					newPass.AddTextureUnitState( state );
				}

				// remove the extra texture units from this pass
				textureUnitStates.RemoveRange( start, textureUnitStates.Count - start );

				return newPass;
			}

			return null;
		}