/// <summary> /// Gets an array of render targets based on the specified types. /// </summary> /// <remarks> /// Render targets are added to the array in the default order: /// Color Map /// Normal Map /// Light Map /// Options Map /// Shadow Map /// </remarks> /// <param name="renderTargetTypes">The render target types.</param> /// <param name="outTargets">A <see cref="RenderTargetBinding"/> array to populate.</param> /// <returns>The number of render targets added to the array.</returns> public int GetRenderTargets(RenderTargetTypes renderTargetTypes, ref RenderTargetBinding[] outTargets) { int arrayOffset = 0; if ((renderTargetTypes & RenderTargetTypes.ColorMap) != 0) { outTargets[arrayOffset++] = this.colorMap; } if ((renderTargetTypes & RenderTargetTypes.NormalMap) != 0) { outTargets[arrayOffset++] = this.normalMap; } if ((renderTargetTypes & RenderTargetTypes.LightMap) != 0) { outTargets[arrayOffset++] = this.lightMap; } if ((renderTargetTypes & RenderTargetTypes.OptionsMap) != 0) { outTargets[arrayOffset++] = this.optionsMap; } return(arrayOffset); }
/// <summary> /// Sets the active render targets in this order (Color, Normal, Light). /// </summary> /// <param name="renderTargetTypes">The render target types requested.</param> /// <param name="count">The number of render targets requested.</param> public void SetRenderTargets(RenderTargetTypes renderTargetTypes, int count) { if (renderTargetTypes == RenderTargetTypes.None) { this.GraphicsDevice.SetRenderTarget(null); } else { RenderTargetBinding[] renderTargets = new RenderTargetBinding[count]; if (this.renderTargets.GetRenderTargets(renderTargetTypes, ref renderTargets) != count) { Logger.Throw(Logger.Level.Fatal, new InvalidOperationException("Specified render target count differs from count received.")); } this.GraphicsDevice.SetRenderTargets(renderTargets); } }