Object representing one pass or operation in a composition sequence. This provides a method to conviently interleave RenderSystem commands between Render Queues.
Inheritance: DisposableObject
Example #1
0
 /// <summary>
 /// Create's a new Composition technique
 /// </summary>
 /// <param name="parent">parent of this technique</param>
 public CompositionTechnique(Compositor parent)
 {
     this.parent             = parent;
     this.outputTarget       = new CompositionTargetPass(this);
     this.textureDefinitions = new List <TextureDefinition>();
     this.targetPasses       = new List <CompositionTargetPass>();
 }
Example #2
0
 public CompositionPass(CompositionTargetPass parent)
 {
     this.parent                   = parent;
     this.type                     = CompositorPassType.RenderQuad;
     this.identifier               = 0;
     this.firstRenderQueue         = RenderQueueGroupID.Background;
     this.lastRenderQueue          = RenderQueueGroupID.SkiesLate;
     this.materialSchemeName       = string.Empty;
     this.clearBuffers             = FrameBufferType.Color | FrameBufferType.Depth;
     this.clearColor               = new ColorEx(0f, 0f, 0f, 0f);
     this.clearDepth               = 1.0f;
     this.clearStencil             = 0;
     this.stencilCheck             = false;
     this.stencilFunc              = CompareFunction.AlwaysPass;
     this.stencilRefValue          = 0;
     this.stencilMask              = 0x7FFFFFFF;
     this.stencilFailOp            = StencilOperation.Keep;
     this.stencilDepthFailOp       = StencilOperation.Keep;
     this.stencilPassOp            = StencilOperation.Keep;
     this.stencilTwoSidedOperation = false;
     this.quadCornerModified       = false;
     this.quadLeft                 = -1;
     this.quadTop                  = 1;
     this.quadRight                = 1;
     this.quadBottom               = -1;
     this.quadFarCorners           = false;
     this.quadFarCornersViewSpace  = false;
 }
Example #3
0
        /// <summary>
        /// Create's a new target pass.
        /// </summary>
        /// <returns>pointer to a new target pass</returns>
        public virtual CompositionTargetPass CreateTargetPass()
        {
            var t = new CompositionTargetPass(this);

            this.targetPasses.Add(t);
            return(t);
        }
Example #4
0
        ///<summary>
        ///    Create a new target pass, and return a pointer to it.
        ///</summary>
        public CompositionTargetPass CreateTargetPass()
        {
            CompositionTargetPass t = new CompositionTargetPass(this);

            targetPasses.Add(t);
            return(t);
        }
Example #5
0
        /// <summary>
        /// Create "default compositor"
        /// </summary>
        protected void CreateOriginalScene()
        {
            this.originalSceneMaterial = this.viewport.MaterialScheme;
            string compName = "Axiom/Scene/" + this.originalSceneMaterial;
            var    scene    = (Compositor)CompositorManager.Instance.GetByName(compName);

            if (scene == null)
            {
                scene = (Compositor)CompositorManager.Instance.Create(compName, ResourceGroupManager.InternalResourceGroupName);
                CompositionTechnique t = scene.CreateTechnique();
                t.SchemeName = string.Empty;
                CompositionTargetPass tp = t.OutputTarget;
                tp.VisibilityMask = 0xFFFFFFFF;

                {
                    CompositionPass pass = tp.CreatePass();
                    pass.Type = CompositorPassType.Clear;
                }
                {
                    CompositionPass pass = tp.CreatePass();
                    pass.Type = CompositorPassType.RenderScene;
                    //Render everything, including skies
                    pass.FirstRenderQueue = RenderQueueGroupID.Background;
                    pass.LastRenderQueue  = RenderQueueGroupID.SkiesLate;
                }

                scene = (Compositor)CompositorManager.Instance.Load(compName, ResourceGroupManager.InternalResourceGroupName);
            }


            this.originalScene = new CompositorInstance(scene.GetSupportedTechniqueByScheme(), this);
        }
 public CompositionTechnique(Compositor parent)
 {
     this.parent = parent;
     textureDefinitions = new List<CompositionTextureDefinition>();
     targetPasses = new List<CompositionTargetPass>();
     outputTarget = new CompositionTargetPass(this);
     instances = new List<CompositorInstance>();
 }
Example #7
0
        protected override void dispose(bool disposeManagedResources)
        {
            if (!IsDisposed)
            {
                if (disposeManagedResources)
                {
                    return;

                    RemoveAllTextureDefinitions();
                    RemoveAllTargetPasses();
                    this.outputTarget.Dispose();
                    this.outputTarget = null;
                }
            }
            base.dispose(disposeManagedResources);
        }
Example #8
0
        ///<summary>
        ///    Compile the final (output) operation. This is done seperately because this
        ///    is combined with the input in chained filters.
        ///</summary>
        public void CompileOutputOperation(CompositorTargetOperation finalState)
        {
            /// Final target
            CompositionTargetPass tpass = technique.OutputTarget;

            /// Logical-and together the visibilityMask, and multiply the lodBias
            finalState.VisibilityMask &= tpass.VisibilityMask;
            finalState.LodBias        *= tpass.LodBias;

            if (tpass.InputMode == CompositorInputMode.Previous)
            {
                /// Collect target state for previous compositor
                /// The TargetOperation for the final target is collected seperately as it is merged
                /// with later operations
                previousInstance.CompileOutputOperation(finalState);
            }
            /// Collect passes
            CollectPasses(finalState, tpass);
        }
 public CompositionPass(CompositionTargetPass parent)
 {
     this.parent              = parent;
     type                     = CompositorPassType.RenderQuad;
     identifier               = 0;
     firstRenderQueue         = RenderQueueGroupID.SkiesEarly;
     lastRenderQueue          = RenderQueueGroupID.SkiesLate;
     clearBuffers             = FrameBuffer.Color | FrameBuffer.Depth;
     clearColor               = new ColorEx(0f, 0f, 0f, 0f);
     clearDepth               = 1.0f;
     clearStencil             = 0;
     stencilCheck             = false;
     stencilFunc              = CompareFunction.AlwaysPass;
     stencilRefValue          = 0;
     stencilMask              = (int)0x7FFFFFFF;
     stencilFailOp            = StencilOperation.Keep;
     stencilDepthFailOp       = StencilOperation.Keep;
     stencilPassOp            = StencilOperation.Keep;
     stencilTwoSidedOperation = false;
 }
Example #10
0
        ///<summary>
        ///    Intialises the Compositor manager, which also triggers it to
        ///    parse all available .compositor scripts.
        ///</summary>
        public void Initialize()
        {
            Compositor            scene = (Compositor)Create("Ogre/Scene");
            CompositionTechnique  t     = scene.CreateTechnique();
            CompositionTargetPass tp    = t.OutputTarget;

            tp.VisibilityMask = 0xFFFFFFFF;
            CompositionPass pass = tp.CreatePass();

            pass.Type = CompositorPassType.Clear;
            CompositionPass nextPass = tp.CreatePass();

            nextPass.Type = CompositorPassType.RenderScene;
            /// Render everything, including skies
            pass.FirstRenderQueue = RenderQueueGroupID.SkiesEarly;
            pass.LastRenderQueue  = RenderQueueGroupID.SkiesLate;

            chains = new Dictionary <Viewport, CompositorChain>();

            // parse all compositing scripts
            ParseAllSources();
        }
 public CompositionPass(CompositionTargetPass parent)
 {
     this.parent = parent;
     type = CompositorPassType.RenderQuad;
     identifier = 0;
     firstRenderQueue = RenderQueueGroupID.SkiesEarly;
     lastRenderQueue = RenderQueueGroupID.SkiesLate;
     clearBuffers = FrameBuffer.Color | FrameBuffer.Depth;
     clearColor = new ColorEx(0f, 0f, 0f, 0f);
     clearDepth = 1.0f;
     clearStencil = 0;
     stencilCheck = false;
     stencilFunc = CompareFunction.AlwaysPass;
     stencilRefValue = 0;
     stencilMask = (int)0x7FFFFFFF;
     stencilFailOp = StencilOperation.Keep;
     stencilDepthFailOp = StencilOperation.Keep;
     stencilPassOp = StencilOperation.Keep;
     stencilTwoSidedOperation = false;
 }
			/// <see cref="Translator.Translate"/>
			public override void Translate( ScriptCompiler compiler, AbstractNode node )
			{
				var obj = (ObjectAbstractNode)node;

				var technique = (CompositionTechnique)obj.Parent.Context;
				if ( obj.Id == (uint)Keywords.ID_TARGET )
				{
					this._Target = technique.CreateTargetPass();
					if ( !string.IsNullOrEmpty( obj.Name ) )
					{
						this._Target.OutputName = obj.Name;
					}
				}
				else if ( obj.Id == (uint)Keywords.ID_TARGET_OUTPUT )
				{
					this._Target = technique.OutputTarget;
				}
				obj.Context = this._Target;

				foreach ( var i in obj.Children )
				{
					if ( i is ObjectAbstractNode )
					{
						processNode( compiler, i );
					}
					else if ( i is PropertyAbstractNode )
					{
						var prop = (PropertyAbstractNode)i;
						switch ( (Keywords)prop.Id )
						{
								#region ID_INPUT

							case Keywords.ID_INPUT:
								if ( prop.Values.Count == 0 )
								{
									compiler.AddError( CompileErrorCode.StringExpected, prop.File, prop.Line );
									return;
								}
								else if ( prop.Values.Count > 1 )
								{
									compiler.AddError( CompileErrorCode.FewerParametersExpected, prop.File, prop.Line );
									return;
								}
								else
								{
									if ( prop.Values[ 0 ] is AtomAbstractNode )
									{
										var atom = (AtomAbstractNode)prop.Values[ 0 ];
										switch ( (Keywords)atom.Id )
										{
											case Keywords.ID_NONE:
												this._Target.InputMode = CompositorInputMode.None;
												break;

											case Keywords.ID_PREVIOUS:
												this._Target.InputMode = CompositorInputMode.Previous;
												break;

											default:
												compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line );
												break;
										}
									}
									else
									{
										compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line );
									}
								}
								break;

								#endregion ID_INPUT

								#region ID_ONLY_INITIAL

							case Keywords.ID_ONLY_INITIAL:
								if ( prop.Values.Count == 0 )
								{
									compiler.AddError( CompileErrorCode.StringExpected, prop.File, prop.Line );
									return;
								}
								else if ( prop.Values.Count > 1 )
								{
									compiler.AddError( CompileErrorCode.FewerParametersExpected, prop.File, prop.Line );
									return;
								}
								else
								{
									var val = false;
									if ( getBoolean( prop.Values[ 0 ], out val ) )
									{
										this._Target.OnlyInitial = val;
									}
									else
									{
										compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line );
									}
								}
								break;

								#endregion ID_ONLY_INITIAL

								#region ID_VISIBILITY_MASK

							case Keywords.ID_VISIBILITY_MASK:
								if ( prop.Values.Count == 0 )
								{
									compiler.AddError( CompileErrorCode.StringExpected, prop.File, prop.Line );
									return;
								}
								else if ( prop.Values.Count > 1 )
								{
									compiler.AddError( CompileErrorCode.FewerParametersExpected, prop.File, prop.Line );
									return;
								}
								else
								{
									uint val;
									if ( getUInt( prop.Values[ 0 ], out val ) )
									{
										this._Target.VisibilityMask = val;
									}
									else
									{
										compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line );
									}
								}
								break;

								#endregion ID_VISIBILITY_MASK

								#region ID_LOD_BIAS

							case Keywords.ID_LOD_BIAS:
								if ( prop.Values.Count == 0 )
								{
									compiler.AddError( CompileErrorCode.StringExpected, prop.File, prop.Line );
									return;
								}
								else if ( prop.Values.Count > 1 )
								{
									compiler.AddError( CompileErrorCode.FewerParametersExpected, prop.File, prop.Line );
									return;
								}
								else
								{
									float val;
									if ( getFloat( prop.Values[ 0 ], out val ) )
									{
										this._Target.LodBias = val;
									}
									else
									{
										compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line );
									}
								}
								break;

								#endregion ID_LOD_BIAS

								#region ID_MATERIAL_SCHEME

							case Keywords.ID_MATERIAL_SCHEME:
								if ( prop.Values.Count == 0 )
								{
									compiler.AddError( CompileErrorCode.StringExpected, prop.File, prop.Line );
									return;
								}
								else if ( prop.Values.Count > 1 )
								{
									compiler.AddError( CompileErrorCode.FewerParametersExpected, prop.File, prop.Line );
									return;
								}
								else
								{
									string val;
									if ( getString( prop.Values[ 0 ], out val ) )
									{
										this._Target.MaterialScheme = val;
									}
									else
									{
										compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line );
									}
								}
								break;

								#endregion ID_MATERIAL_SCHEME

								#region ID_SHADOWS_ENABLED

							case Keywords.ID_SHADOWS_ENABLED:
								if ( prop.Values.Count == 0 )
								{
									compiler.AddError( CompileErrorCode.StringExpected, prop.File, prop.Line );
									return;
								}
								else if ( prop.Values.Count > 1 )
								{
									compiler.AddError( CompileErrorCode.FewerParametersExpected, prop.File, prop.Line );
									return;
								}
								else
								{
									bool val;
									if ( getBoolean( prop.Values[ 0 ], out val ) )
									{
										this._Target.ShadowsEnabled = val;
									}
									else
									{
										compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line );
									}
								}
								break;

								#endregion ID_SHADOWS_ENABLED

							default:
								compiler.AddError( CompileErrorCode.UnexpectedToken, prop.File, prop.Line,
								                   "token \"" + prop.Name + "\" is not recognized" );
								break;
						}
					}
				}
			}
			public CompositionTargetPassTranslator()
				: base()
			{
				this._Target = null;
			}
        ///<summary>
        ///    Collect rendering passes. Here, passes are converted into render target operations
        ///    and queued with queueRenderSystemOp.
        ///</summary>
        protected void CollectPasses(CompositorTargetOperation finalState, CompositionTargetPass target)
        {
            /// Here, passes are converted into render target operations
            Pass targetpass;
            Technique srctech;
            Material srcmat;

            foreach (CompositionPass pass in target.Passes) {
                switch(pass.Type) {
                case CompositorPassType.Clear:
                    QueueRenderSystemOp(finalState, new RSClearOperation(
                        pass.ClearBuffers,
                        pass.ClearColor,
                        pass.ClearDepth,
                        pass.ClearStencil));
                    break;
                case CompositorPassType.Stencil:
                    QueueRenderSystemOp(finalState, new RSStencilOperation(
                        pass.StencilCheck, pass.StencilFunc, pass.StencilRefValue,
                        pass.StencilMask, pass.StencilFailOp, pass.StencilDepthFailOp,
                        pass.StencilPassOp, pass.StencilTwoSidedOperation
                        ));
                    break;
                case CompositorPassType.RenderScene:
                    if((int)pass.FirstRenderQueue < (int)finalState.CurrentQueueGroupID) {
                        /// Mismatch -- warn user
                        /// XXX We could support repeating the last queue, with some effort
                        LogManager.Instance.Write("Warning in compilation of Compositor "
                            + compositor.Name + ": Attempt to render queue " +
                            pass.FirstRenderQueue + " before "+
                            finalState.CurrentQueueGroupID);
                    }
                    /// Add render queues
                    for(RenderQueueGroupID x=pass.FirstRenderQueue; x<=pass.LastRenderQueue; ++x) {
                        Debug.Assert(x>=0);
                        finalState.RenderQueues[(int)x] = true;
                    }
                    finalState.CurrentQueueGroupID = (RenderQueueGroupID)((int)pass.LastRenderQueue + 1);
                    finalState.FindVisibleObjects = true;
                    finalState.MaterialScheme = target.MaterialScheme;

                    break;
                case CompositorPassType.RenderQuad:
                    srcmat = pass.Material;
                    if(srcmat == null) {
                        /// No material -- warn user
                        LogManager.Instance.Write("Warning in compilation of Compositor "
                            + compositor.Name + ": No material defined for composition pass");
                        break;
                    }
                    srcmat.Load();
                    if(srcmat.SupportedTechniques.Count == 0) {
                        /// No supported techniques -- warn user
                        LogManager.Instance.Write("Warning in compilation of Compositor "
                            + compositor.Name + ": material " + srcmat.Name + " has no supported techniques");
                        break;
                    }
                    srctech = srcmat.GetBestTechnique(0);
                    /// Create local material
                    Material localMat = CreateLocalMaterial();
                    /// Copy and adapt passes from source material
                    for (int i=0; i<srctech.NumPasses; i++) {
                        Pass srcpass = srctech.GetPass(i);
                        /// Create new target pass
                        targetpass = localMat.GetTechnique(0).CreatePass();
                        srcpass.CopyTo(targetpass);
                        /// Set up inputs
                        int numInputs = pass.GetNumInputs();
                        for (int x = 0; x < numInputs; x++) {
                            string inp = pass.Inputs[x];
                            if (inp != string.Empty) {
                                if (x < targetpass.NumTextureUnitStages)
                                    targetpass.GetTextureUnitState(x).SetTextureName(GetSourceForTex(inp));
                                else {
                                    /// Texture unit not there
                                    LogManager.Instance.Write("Warning in compilation of Compositor "
                                             + compositor.Name + ": material " + srcmat.Name + " texture unit "
                                             + x + " out of bounds");
                                }
                            }
                        }
                    }
                    QueueRenderSystemOp(finalState, new RSQuadOperation(this, pass.Identifier, localMat));
                    break;
                }
            }
        }
Example #15
0
		///<summary>
		///    Collect rendering passes. Here, passes are converted into render target operations
		///    and queued with queueRenderSystemOp.
		///</summary>
		protected void CollectPasses( CompositeTargetOperation finalState, CompositionTargetPass target )
		{
			// Here, passes are converted into render target operations
			Pass targetPass = null;
			Technique srctech = null;
			Material mat = null, srcmat = null;

			foreach ( var pass in target.Passes )
			{
				switch ( pass.Type )
				{
					case CompositorPassType.Clear:
					{
						QueueRenderSystemOp( finalState,
						                     new RSClearOperation( pass.ClearBuffers, pass.ClearColor, pass.ClearDepth, pass.ClearStencil ) );
					}
						break;
					case CompositorPassType.Stencil:
					{
						QueueRenderSystemOp( finalState,
						                     new RSStencilOperation( pass.StencilCheck, pass.StencilFunc, pass.StencilRefValue,
						                                             pass.StencilMask, pass.StencilFailOp, pass.StencilDepthFailOp,
						                                             pass.StencilPassOp, pass.StencilTwoSidedOperation ) );
					}
						break;
					case CompositorPassType.RenderScene:
					{
						if ( pass.FirstRenderQueue < finalState.CurrentQueueGroupId )
						{
							// Mismatch -- warn user
							// XXX We could support repeating the last queue, with some effort
							LogManager.Instance.Write( "Warning in compilation of Compositor {0}: Attempt to render queue {1} before {2}.",
							                           this.compositor.Name, pass.FirstRenderQueue, finalState.CurrentQueueGroupId );
						}
						RSSetSchemeOperation setSchemeOperation = null;
						if ( pass.MaterialScheme != string.Empty )
						{
							//Add the triggers that will set the scheme and restore it each frame
							finalState.CurrentQueueGroupId = pass.FirstRenderQueue;
							setSchemeOperation = new RSSetSchemeOperation( pass.MaterialScheme );
							QueueRenderSystemOp( finalState, setSchemeOperation );
						}
						// Add render queues
						for ( var x = (int)pass.FirstRenderQueue; x < (int)pass.LastRenderQueue; x++ )
						{
							Debug.Assert( x >= 0 );
							finalState.RenderQueues.Set( x, true );
						}
						finalState.CurrentQueueGroupId = pass.LastRenderQueue + 1;
						if ( setSchemeOperation != null )
						{
							//Restoring the scheme after the queues have been rendered
							QueueRenderSystemOp( finalState, new RSRestoreSchemeOperation( setSchemeOperation ) );
						}
						finalState.FindVisibleObjects = true;
						finalState.MaterialScheme = target.MaterialScheme;
						finalState.ShadowsEnabled = target.ShadowsEnabled;
					}
						break;
					case CompositorPassType.RenderQuad:
					{
						srcmat = pass.Material;
						if ( srcmat == null )
						{
							// No material -- warn user
							LogManager.Instance.Write(
								"Warning in compilation of Compositor {0}: No material defined for composition pass.", this.compositor.Name );
							break;
						}
						srcmat.Load();
						if ( srcmat.SupportedTechniques.Count == 0 )
						{
							// No supported techniques -- warn user
							LogManager.Instance.Write(
								"Warning in compilation of Compositor {0}: material {1} has no supported techniques.", this.compositor.Name,
								srcmat.Name );
							break;
						}

						srctech = srcmat.GetBestTechnique( 0 );
						// Create local material
						mat = CreateLocalMaterial( srcmat.Name );
						// Copy and adapt passes from source material
						for ( var i = 0; i < srctech.PassCount; i++ )
						{
							var srcpass = srctech.GetPass( i );
							// Create new target pass
							targetPass = mat.GetTechnique( 0 ).CreatePass();
							srcpass.CopyTo( targetPass );
							// Set up inputs
							for ( var x = 0; x < pass.InputsCount; x++ )
							{
								var inp = pass.GetInput( x );
								if ( !string.IsNullOrEmpty( inp.Name ) )
								{
									if ( x < targetPass.TextureUnitStatesCount )
									{
										targetPass.GetTextureUnitState( x ).SetTextureName( GetTextureInstance( inp.Name, inp.MrtIndex ).Name );
									}
									else
									{
										// Texture unit not there
										LogManager.Instance.Write(
											"Warning in compilation of Compositor {0}: material {1} texture unit {2} out of bounds.",
											this.compositor.Name,
											srcmat.Name, x );
									}
								}
							} //end for inputs.length
						} //end for passcount

						var rsQuadOperation = new RSQuadOperation( this, pass.Identifier, mat );
						float left, top, right, bottom;
						if ( pass.GetQuadCorners( out left, out top, out right, out bottom ) )
						{
							rsQuadOperation.SetQuadCorners( left, top, right, bottom );
						}
						rsQuadOperation.SetQuadFarCorners( pass.QuadFarCorners, pass.QuadFarCornersViewSpace );
						QueueRenderSystemOp( finalState, rsQuadOperation );
					}
						break;
					case CompositorPassType.RenderCustom:
					{
						var customOperation = CompositorManager.Instance.CustomCompositionPasses[ pass.CustomType ].CreateOperation(
							this, pass );
						QueueRenderSystemOp( finalState, customOperation );
					}
						break;
				}
			}
		}
 ///<summary>
 ///    Create a new target pass, and return a pointer to it.
 ///</summary>
 public CompositionTargetPass CreateTargetPass()
 {
     CompositionTargetPass t = new CompositionTargetPass(this);
     targetPasses.Add(t);
     return t;
 }
		protected override void dispose( bool disposeManagedResources )
		{
			if ( !IsDisposed )
			{
				if ( disposeManagedResources )
				{
					return;
					RemoveAllTextureDefinitions();
					RemoveAllTargetPasses();
					this.outputTarget.Dispose();
					this.outputTarget = null;
				}
			}
			base.dispose( disposeManagedResources );
		}
Example #18
0
        ///<summary>
        ///    Collect rendering passes. Here, passes are converted into render target operations
        ///    and queued with queueRenderSystemOp.
        ///</summary>
        protected void CollectPasses(CompositorTargetOperation finalState, CompositionTargetPass target)
        {
            /// Here, passes are converted into render target operations
            Pass      targetpass;
            Technique srctech;
            Material  srcmat;

            foreach (CompositionPass pass in target.Passes)
            {
                switch (pass.Type)
                {
                case CompositorPassType.Clear:
                    QueueRenderSystemOp(finalState, new RSClearOperation(
                                            pass.ClearBuffers,
                                            pass.ClearColor,
                                            pass.ClearDepth,
                                            pass.ClearStencil));
                    break;

                case CompositorPassType.Stencil:
                    QueueRenderSystemOp(finalState, new RSStencilOperation(
                                            pass.StencilCheck, pass.StencilFunc, pass.StencilRefValue,
                                            pass.StencilMask, pass.StencilFailOp, pass.StencilDepthFailOp,
                                            pass.StencilPassOp, pass.StencilTwoSidedOperation
                                            ));
                    break;

                case CompositorPassType.RenderScene:
                    if ((int)pass.FirstRenderQueue < (int)finalState.CurrentQueueGroupID)
                    {
                        /// Mismatch -- warn user
                        /// XXX We could support repeating the last queue, with some effort
                        LogManager.Instance.Write("Warning in compilation of Compositor "
                                                  + compositor.Name + ": Attempt to render queue " +
                                                  pass.FirstRenderQueue + " before " +
                                                  finalState.CurrentQueueGroupID);
                    }
                    /// Add render queues
                    for (RenderQueueGroupID x = pass.FirstRenderQueue; x <= pass.LastRenderQueue; ++x)
                    {
                        Debug.Assert(x >= 0);
                        finalState.RenderQueues[(int)x] = true;
                    }
                    finalState.CurrentQueueGroupID = (RenderQueueGroupID)((int)pass.LastRenderQueue + 1);
                    finalState.FindVisibleObjects  = true;
                    finalState.MaterialScheme      = target.MaterialScheme;

                    break;

                case CompositorPassType.RenderQuad:
                    srcmat = pass.Material;
                    if (srcmat == null)
                    {
                        /// No material -- warn user
                        LogManager.Instance.Write("Warning in compilation of Compositor "
                                                  + compositor.Name + ": No material defined for composition pass");
                        break;
                    }
                    srcmat.Load();
                    if (srcmat.SupportedTechniques.Count == 0)
                    {
                        /// No supported techniques -- warn user
                        LogManager.Instance.Write("Warning in compilation of Compositor "
                                                  + compositor.Name + ": material " + srcmat.Name + " has no supported techniques");
                        break;
                    }
                    srctech = srcmat.GetBestTechnique(0);
                    /// Create local material
                    Material localMat = CreateLocalMaterial();
                    /// Copy and adapt passes from source material
                    for (int i = 0; i < srctech.NumPasses; i++)
                    {
                        Pass srcpass = srctech.GetPass(i);
                        /// Create new target pass
                        targetpass = localMat.GetTechnique(0).CreatePass();
                        srcpass.CopyTo(targetpass);
                        /// Set up inputs
                        int numInputs = pass.GetNumInputs();
                        for (int x = 0; x < numInputs; x++)
                        {
                            string inp = pass.Inputs[x];
                            if (inp != string.Empty)
                            {
                                if (x < targetpass.NumTextureUnitStages)
                                {
                                    targetpass.GetTextureUnitState(x).SetTextureName(GetSourceForTex(inp));
                                }
                                else
                                {
                                    /// Texture unit not there
                                    LogManager.Instance.Write("Warning in compilation of Compositor "
                                                              + compositor.Name + ": material " + srcmat.Name + " texture unit "
                                                              + x + " out of bounds");
                                }
                            }
                        }
                    }
                    QueueRenderSystemOp(finalState, new RSQuadOperation(this, pass.Identifier, localMat));
                    break;
                }
            }
        }
Example #19
0
		public CompositionPass( CompositionTargetPass parent )
		{
			this.parent = parent;
			type = CompositorPassType.RenderQuad;
			identifier = 0;
			firstRenderQueue = RenderQueueGroupID.Background;
			lastRenderQueue = RenderQueueGroupID.SkiesLate;
			materialSchemeName = string.Empty;
			clearBuffers = FrameBufferType.Color | FrameBufferType.Depth;
			clearColor = new ColorEx( 0f, 0f, 0f, 0f );
			clearDepth = 1.0f;
			clearStencil = 0;
			stencilCheck = false;
			stencilFunc = CompareFunction.AlwaysPass;
			stencilRefValue = 0;
			stencilMask = 0x7FFFFFFF;
			stencilFailOp = StencilOperation.Keep;
			stencilDepthFailOp = StencilOperation.Keep;
			stencilPassOp = StencilOperation.Keep;
			stencilTwoSidedOperation = false;
			quadCornerModified = false;
			quadLeft = -1;
			quadTop = 1;
			quadRight = 1;
			quadBottom = -1;
			quadFarCorners = false;
			quadFarCornersViewSpace = false;
		}
		/// <summary>
		/// Create's a new target pass.
		/// </summary>
		/// <returns>pointer to a new target pass</returns>
		public virtual CompositionTargetPass CreateTargetPass()
		{
			var t = new CompositionTargetPass( this );
			this.targetPasses.Add( t );
			return t;
		}