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

SetRunOncePerLight() public method

Sets whether or not this pass should be run once per light which can affect the object being rendered.
The default behavior for a pass (when this option is 'false'), is for a pass to be rendered only once, with all the lights which could affect this object set at the same time (up to the maximum lights allowed in the render system, which is typically 8).

Setting this option to 'true' changes this behavior, such that instead of trying to issue render this pass once per object, it is run once per light which can affect this object. In this case, only light index 0 is ever used, and is a different light every time the pass is issued, up to the total number of lights which is affecting this object. This has 2 advantages:

  • There is no limit on the number of lights which can be supported
  • It's easier to write vertex / fragment programs for this because a single program can be used for any number of lights
However, this technique is a lot more expensive, and typically you will want an additional ambient pass, because if no lights are affecting the object it will not be rendered at all, which will look odd even if ambient light is zero (imagine if there are lit objects behind it - the objects silhouette would not show up). Therefore, use this option with care, and you would be well advised to provide a less expensive fallback technique for use in the distance.

Note: The number of times this pass runs is still limited by the maximum number of lights allowed as set in MaxLights, so you will never get more passes than this.

public SetRunOncePerLight ( bool enabled, bool onlyForOneLightType, LightType lightType ) : void
enabled bool Whether this feature is enabled.
onlyForOneLightType bool /// If true, the pass will only be run for a single type of light, other light types will be ignored. ///
lightType LightType The single light type which will be considered for this pass.
return void
		public void SetRunOncePerLight( bool enabled, bool onlyForOneLightType, LightType lightType )
		{
			_iteratePerLight = enabled;
			_runOnlyForOneLightType = onlyForOneLightType;
			_onlyLightType = lightType;
		}

Same methods

Pass::SetRunOncePerLight ( bool enabled ) : void
Pass::SetRunOncePerLight ( bool enabled, bool onlyForOneLightType ) : void