DOF extra & ALF effect 3/13 2015

share shaders here
  • Author
  • Message
Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: DOF extra & ALF effect 10/29 update

Yes I have experience with it, in that kind that ENB doesn't support it. MasterEffect 1.6 contains a crazy hack for bloom I fiddled with to bypass that missing function (actually not so genious but at that time I was extremely proud of it :lol: )

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

----------------------------------------------------------------------------------------------------
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

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 )	);
}
I use this for smooth thresholding, it basically inverts the "lerp" function and gives you the relative position of a value between two other values.

"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!

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29

Re: DOF extra & ALF effect 10/29 update

Thanks.
Quite brilliant to put downscaled image diagonally to prevent mixing textures, or one might need some complex boundary test.

The unlerp looks just like smoothstep(), still, not sure if they return same value.

here is my approach to deform circle into polygon
Image
than the length multiplier of polygon would be

cos( leaf angle / 2 ) / cos(delta angle)

Code: Select all

	float 	leafangle = 6.28318530 / ShutterLeaf;//angle of a leaf.    (2pi / polygon)
	float 	shutterShape = smoothstep(Fmin, Fmax, F_Number);//for interpolation use
	float deltaAngle = (sampleAngle + leafangle * shutterShape + LeafOffset) % leafangle;//leafangle * shutterShape is for rotation movement in lens, leafOffset is the offset angle of polygon
	deltaAngle -= leafangle / 2;
	SampleOffset *= lerp( 1, (cos(leafangle/2)/cos(deltaAngle)), shutterShape);
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
Posts: 3
Joined: 03 Nov 2014, 06:33

Re: DOF extra & ALF effect 10/29 update

This is so awesome. Really love the bokeh effect. Is there any place where I can download this? The links in the first post just bring me to the enbdev homepage and I see the coding has developed a lot throughout the topic but since I suck at coding (really, the only thing I understand is turning the spinners in the GUI) I would really love to download this. If anyone could give me a link to the latest version I would be greatly thankful.

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29

Re: DOF extra & ALF effect 10/29 update

There is a enbeffectprepass.fx file attachment in the first post.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
Posts: 3
Joined: 03 Nov 2014, 06:33

Re: DOF extra & ALF effect 10/29 update

I know. But it links me to http://enbdev.com/?id=1132

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29

Re: DOF extra & ALF effect 10/29 update

Odd. here is mediafire link
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
Posts: 3
Joined: 03 Nov 2014, 06:33

Re: DOF extra & ALF effect 10/29 update

The link from your pm worked perfectly. Thank you very much. :D
Going to try it out as soon as I can.

Offline
*master*
Posts: 107
Joined: 19 Mar 2014, 02:11

Re: DOF extra & ALF effect 10/29 update

Wow a god send. I like this Dof alot and I am getting about an extra 5 fps then before.

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29

Re: DOF extra & ALF effect 10/29 update

*update 11/6 :
upload additional dof file for thin lens model, see DoF with Lens control section.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
Posts: 1
Joined: 07 Nov 2014, 00:36

Re: DOF extra & ALF effect 10/29 update

I was wondering, how is this shader licensed? Is it in the public domain?
Post Reply