Example #1
0
        /// <summary>
        /// Creates a LensFlare instance with custom settings. The graphics device
        /// will be reused, but will not be disposed of at instance destruction.
        /// </summary>
        /// <param name="device">The graphics device to use.</param>
        /// <param name="context">The device context to use.</param>
        /// <param name="quality">The required render quality.</param>
        /// <param name="profile">The desired optical profile.</param>
        /// <param name="options">The desired diffraction options.</param>
        public EyeDiffraction(Device device, DeviceContext context, RenderQuality quality, OpticalProfile profile, DiffractionOptions options)
        {
            Pass = new SurfacePass(device);
            composer = new ApertureComposer(device);

            Device = device;            /* Store the device. */
            Context = context;          /* Save the context. */
            Quality = quality;          /* Validate quality. */
            Profile = profile;          /* Use lens profile. */
            Options = options;          /* Save the options. */
        }
Example #2
0
 /// <summary>
 /// Applies the layer to an aperture texture. The output
 /// is to be understood as the transmittance through any
 /// pixel, and will be blended multiplicatively together
 /// with other layers (as such, order does not matter).
 /// </summary>
 /// <param name="context">The device context.</param>
 /// <param name="output">The output aperture.</param>
 /// <param name="profile">An optical profile.</param>
 /// <param name="pass">A SurfacePass instance.</param>
 /// <param name="time">The elapsed time.</param>
 /// <param name="dt">The time since last call.</param>
 public abstract void ApplyLayer(DeviceContext context, GraphicsResource output, OpticalProfile profile, SurfacePass pass, double time, double dt);
Example #3
0
        /// <summary>
        /// Composes an aperture.
        /// </summary>
        /// <param name="context">The device context.</param>
        /// <param name="output">The output render target.</param>
        /// <param name="profile">The optical profile to use.</param>
        /// <param name="pass">A SurfacePass instance to use.</param>
        /// <param name="time">The elapsed time.</param>
        /// <param name="dt">The time since last call.</param>
        public void Compose(DeviceContext context, GraphicsResource output, OpticalProfile profile, SurfacePass pass, double time, double dt)
        {
            context.ClearRenderTargetView(output.RTV, Color4.White);
            context.OutputMerger.SetBlendState(blendState);

            foreach (ApertureLayer layer in layers)
                layer.ApplyLayer(context, output, profile, pass, time, dt);

            context.OutputMerger.SetBlendState(null);
        }