Realtime Lens Flare
-------------------

You need an obstacle object, "trees" in this example, and an SOP within
it with labelled "obstacle".

You need an object with a small number of points in it which is the
flare source. It needs a SOP with the label "torch". Preferably, this
object has a light object attached to it, like "lighttorch" in this
example.

To play with the lens effect, run lensflare1.bmot. The 2 and 5 beatbox
keys with mouse Y adjust the camera and torch vertical positions. Check
the other beatbox keys. You can go to the cam1/r? channels and modify
camera rotations.

before.bmot is a .bmot file that does not contain the flare objects.
We can add them easily using the create.rc script. create.rc assumes
there is an object that contains a SOP that is the flare source, and
the SOP must be labelled "torch".

create.rc assumes there is also an object containing the obstacle
geometry which is a SOP labelled "obstacle".

To try adding lens flare objects to two cameras of a .bmot, start
before.bmot and run:
	rcread create.rc cam1 torch trees 1
	rcread create.rc cam2 torch trees 2

Switch between the two cameras, cam1 and cam2.  Note that with two sets
of flare objects being displayed, the update rate is slower.

The tricks of lens flare:

Two texture maps are pre-computed to make the shading faster. It is
possible to do the same thing using polygons with point alpha and
color, but the textures shade faster on Onyx and Impact.

The textures are located in the Flare directory.  Here is how texture
maps are made: Two maps, streak2.pic and ring2.pic are created from
elements1.bmot. In Action, type STREAK, then RENDERSTREAK to get
streak1.pic.  Then type RING followed by RENDERRING to get ring1.pic.

Then start elements1.ice. The two output COPs, streak2 and ring2 will
create streak2.pic and ring2.pic.  Make adjustments to the blurring,
maximum alpha and ring color here.

These two maps are used in lensflare1.bmot and after.bmot.

Hidden controls:
	color of ring
		in elements1.ice

	radius of the ring
		In lensflare1.bmot, in flarering's stamp SOP, the scale
		is set. There is a factor that depends on the visibility,
		plus a random flicker factor.

	size of the streaks
		In lensflare1.bmot, flarestreak's stamp SOP, the scale
		is set. There is a factor that depends on the visibility,
		plus a random flicker factor.

	number of spikes in flarestreak object
		In Flare/elements1.bmot, the number of points in the
		circle SOP of the streak object determines the number
		of spikes, 3 points per spike, with a default of 24
		points and 8 spikes. This is rendered and composited as
		streak1.bmot.

	number of spots in flarespots
		In lensflare1.bmot, the flarespots object has a spline SOP
		whose number of divisions determines the number of spots
		plus one.

	spread of spots in flarespots
		In lensflare1.bmot, the flarespots object sets the two
		ends on the line of spots using the scale of its first
		two transform SOPs.
	
	shape of spots in flarespots
		Change from a hexagon to something else in the circle SOP's
		divisions of the flarespots object.

	accuracy of the visibility factor
		The visibility factor is computed in the first feedback SOP
		of the flaretest object. It is both a global parameter #9, 
		set in the paramset() call, and it is put in the texture U
		coordinate of the last point of that feedback SOP.

		The latter needed to keep up to date the alphapara channel
		in flarestreak, which in turn is used by all alpha channels
		of flarestreak, flarering and flarespots.

		The visibility factor is computed by casting a ray from the
		torch source to the camera. In this example, the points of
		the torch are are around the perimeter of the torch because
		it is a circle SOP. Other torch objects may not have their
		points evenly spread.

	how fast the flare comes on
		It is based on how visible the torch is. Check the paramset()
		power (^2) in the first feedback SOP of flaretest. Lowering
		the power from 2 to 1 will make it more visible when the
		torch is partially occluded.

	opacity of maps
		A combination of the ice file, and by the flaretest object.

See README in Flare directory.

Greg H
