| LensFlareOnGetSizeAndIntensity Method |
Called when the size and intensity of a lens flare is determined.
Namespace: DigitalRune.GraphicsAssembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax protected virtual void OnGetSizeAndIntensity(
LensFlareNode node,
RenderContext context,
int visiblePixels,
int totalPixels,
out float size,
out float intensity
)
Protected Overridable Sub OnGetSizeAndIntensity (
node As LensFlareNode,
context As RenderContext,
visiblePixels As Integer,
totalPixels As Integer,
<OutAttribute> ByRef size As Single,
<OutAttribute> ByRef intensity As Single
)
protected:
virtual void OnGetSizeAndIntensity(
LensFlareNode^ node,
RenderContext^ context,
int visiblePixels,
int totalPixels,
[OutAttribute] float% size,
[OutAttribute] float% intensity
)
abstract OnGetSizeAndIntensity :
node : LensFlareNode *
context : RenderContext *
visiblePixels : int *
totalPixels : int *
size : float32 byref *
intensity : float32 byref -> unit
override OnGetSizeAndIntensity :
node : LensFlareNode *
context : RenderContext *
visiblePixels : int *
totalPixels : int *
size : float32 byref *
intensity : float32 byref -> unit
Parameters
- node
- Type: DigitalRune.Graphics.SceneGraphLensFlareNode
The lens flare node. - context
- Type: DigitalRune.GraphicsRenderContext
The render context. - visiblePixels
- Type: SystemInt32
The number of visible pixels as determined by the last hardware occlusion query.
(Not available in Reach profile.)
- totalPixels
- Type: SystemInt32
The total number of pixels tested in the hardware occlusion query.
(Not available in Reach profile.)
- size
- Type: SystemSingle
Out: The actual size of the lens flare in relative to the viewport.
- intensity
- Type: SystemSingle
Out: The actual intensity of the lens flare.
Remarks Notes to Inheritors:
This method can be overridden in derived types to adjust the size and intensity of the lens
flare. The base implementation creates a lens flare with constant size. The intensity
depends on the number of visible pixels and the fog.
protected virtual void OnGetSizeAndIntensity(LensFlareNode node, RenderContext context, int visiblePixels, int totalPixels, out float size, out float intensity)
{
var size = Size;
intensity = node.Intensity * Intensity;
if (context.GraphicsService.GraphicsDevice.GraphicsProfile == GraphicsProfile.HiDef)
intensity *= (float)visiblePixels / totalPixels;
var scene = context.Scene;
var cameraNode = context.CameraNode;
if (scene != null && cameraNode != null)
{
var query = scene.Query<FogQuery>(cameraNode);
foreach (var fogNode in query.FogNodes)
{
var flarePosition = IsDirectional
? cameraNode.PoseWorld.Position + node.PoseWorld.Orientation.GetColumn(2) * cameraNode.Camera.Projection.Far
: node.PoseWorld.Position;
intensity *= (1 - fogNode.Fog.GetIntensity(fogNode, cameraNode, flarePosition));
}
}
}
See Also