![Laughing :lol:](./images/smilies/lol.gif)
pass 1: downscale image, put R G and B components as smaller versions of the image on different screen space areas of the alpha channel so that red for example is a small rectangle on the top left corner.
pass 2 and 3: H/V gaussian blur on alpha channel (not needed if you want to mipmap only, I needed that for bloom where the downscale blur isn't powerful enough)
pass 4: upscale the mini versions of the screen again. Voila, downscaled image. If you make sure that nothing overlays, you can even add multiple mipmap stages. Make sure the images are maximum corner to corner, not side to side, otherwise red blurs into green for example. Best solution is to make them completely separated.
After pass 1, the alpha channel looks like the following picture. Although in ME 1.6 I couldn't put any color component to the screen borders because the screen space blur afterwards resulted in strange effects like a loss in red color on the borders where black from outside the screen blurred into the R component while the G and B were unaffected.
![Image](http://abload.de/img/rgbhackz9s99.jpg)
----------------------------------------------------------------------------------------------------
Concerning the DOF, I will do a topic for it here in the next days, does it have time until then?
What I can say about the shape, this is my approach which allows me to keep any big if/else things for circular shape out:
![Image](http://abload.de/img/lenscircular07uvz.jpg)
Divide length of offset "a" though the lengths of current offset "b1", "b2" etc. Output is something greater than 1 because a is always longer than current "b". Now, if you scale the X and Y coordinates of offset "b" with this value, "b" gets automatically as long as "a" -> creating a circular shape.
Code: Select all
#if (CIRCULARBOKEH==1)
float2 tempOffset = sampleOffset.xy*length(EdgeOffset * radiusCoeff)/length(sampleOffset);
sampleOffset.xy = lerp(sampleOffset.xy, tempOffset.xy, fBokehCurvature);
#endif
or in our terms above:
tempOffset = b1 * length(a) / length (b1);
Last line only interpolates between circular and polygonal.
fBokehCurvature = 0.0 means full polygonal shape, 1.0 means full circular shape. This approach also allows polygons whose edges are bent to the inside of the shape, creating some kind of star shape.
This small thing is the only thing in my DOF shader that is responsible for circular DOF.
For the ALF thresholding, I have something else for you.
Code: Select all
float McFlyUnlerp( float from, float to, float pos ){
if ( from == to )
return 1.0;
else
return saturate( ( pos - from ) / ( to - from ) );
}
"From" determines the starter threshold, let's say 1.5.
"to" determines threshold maximum (e.g. 2.0),
"pos" is the luminance of a pixel (as lerp position between "from" and "to".
If a pixel is lower than the "from", you get 0 as output. If a pixel is between "from" and "to", you get something between 0 and 1 and if it's equal or greater than "to", you get 1 as output.
A lensflare with the example values would slightly start to appear if a pixel is >= 1.5 pixel luma and reaches maximum intensity at pixe luma <= 2.0.
Useful if fixed threshold gives too cut-off areas.
I added the ENB lenz to SweetFX where there's no ENB doing the post blur. A fix theshold gives a very cut-off lensflare with visible shape edges while this here gives smooth edges because the edges of a light source cast a weak flare and the center of it a stronger one.
Hope you can use some of the stuff!