O'Reilly logo

Microsoft XNA 4.0 Game Development Cookbook by Luke Drumm

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing lens flare within the HiDef profile

Modern GPUs are very good at determining whether one set of polygons is obscured by another set. We can use this to our advantage when creating lens flares within a HiDef profile.

Getting ready

This recipe assumes that you've already got a scene, rendering correctly, albeit without a lens flare.

How to do it...

To create a lens flare within the HiDef profile:

  1. Create a new class to hold the lens flare behavior:
    class HiDefLensFlare
    {
    
  2. Add some instance-level variables to hold the details of the occlusion test, the lighting, and the glow image:
    SpriteBatch spriteBatch; GraphicsDevice graphicsDevice; public BasicEffect ShadowCaptureEffect; OcclusionQuery occlusionQuery; bool occlusionQueryActive; float occlusionAlpha; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required