DOF extra & ALF effect 3/13 2015

share shaders here
  • Author
  • Message
Offline
User avatar
*blah-blah-blah maniac*
Posts: 1034
Joined: 15 Mar 2013, 10:24
Location: Earth

Re: enbeffectprepass.fx extra GUI & enblens.fx ALF effect

kingeric1992
its definitely your's. i've copied both files from here... ;) maybe the tweaking i did
_________________
cpu Ryzen 5 3600 gpu RTX 3070 ram 32GB os Win11 64

Flickr Gallery

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

Re: enbeffectprepass.fx extra GUI & enblens.fx ALF effect

Ohkay
probably, but enbbloom.fx can also have the ALF effect, and there are scenes where two angled flares and both vertical and horizontal flares are presented.

Apologize if I'm overreact, but the reason I make this ALF is because Masto's flare doesn't stay at the bright spot.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Re: enbeffectprepass.fx extra GUI & enblens.fx ALF effect

Hi,
Thanks for sharing this great file! I have also been playing with the enbeffectpreprocess.fx file for the last week or so and trying to understand it while adding annotations for in game. I had posted another thread in this category about DOF just a few days ago. I am currently trying to understand the focusing code. I am looking at this code in your file:

Code: Select all

float4 PS_ReadFocus(VS_OUTPUT_POST IN) : COLOR
{

float2 uvsrc;
uvsrc.x = FPx;
uvsrc.y = FPy;

float2 pixelSize=ScreenSize.y;
pixelSize.y*=ScreenSize.z;

const float2 offset[4]=
{
float2(0.0, 1.0),
float2(0.0, -1.0),
float2(1.0, 0.0),
float2(-1.0, 0.0)
};

float res=linearlizeDepth(tex2D(SamplerDepth, uvsrc.xy).x);
for (int i=0; i<4; i++)
{
uvsrc.xy=uvsrc.xy;
uvsrc.xy+=offset[i] * pixelSize.xy * FocusSampleRange;
#ifdef NOT_BLURRING_SKY_MODE
res+=linearlizeDepth(tex2D(SamplerDepth, uvsrc).x);
#else
res+=min(linearlizeDepth(tex2D(SamplerDepth, uvsrc).x), DepthClip);
#endif
}
res*=0.2;
return res;
}
What do you make of these lines?

Code: Select all

uvsrc.xy=uvsrc.xy;
uvsrc.xy+=offset[i] * pixelSize.xy * FocusSampleRange;
Doesn't that seem odd to assign uvsrc to itself? The line below it would seem to indicate that uvsrc is continually offset from it's starting point of (FPx, FPy). Do you know if this PS_ReadFocus code is targeting the 4x4 texture in SamplerCurr and SamplerPrev?

Thanks for any help and great job!!
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

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

Re: enbeffectprepass.fx extra GUI & enblens.fx ALF effect

Hi, number6
I didn't write the focusing code, but this is what I thik:

Code: Select all

float res=linearlizeDepth(tex2D(SamplerDepth, uvsrc.xy).x); //get depth at specified uvsrc coordinate.
for (int i=0; i<4; i++)
{
uvsrc.xy=uvsrc.xy; // I think I add this because compiler error.... .
uvsrc.xy+=offset[i] * pixelSize.xy * FocusSampleRange;// offset uvsrc.
#ifdef NOT_BLURRING_SKY_MODE
res+=linearlizeDepth(tex2D(SamplerDepth, uvsrc).x);//combine depth at offset uvsrc with previous result.
#else
res+=min(linearlizeDepth(tex2D(SamplerDepth, uvsrc).x), DepthClip);//combine depth at offset uvsrc with previous result with threshold. 
#endif
}
res*=0.2; //average depth of uvsrc and 4 offset uvsrc.


It calculate the average depth of offset points and original point. I don't know how SamplerCurr and SamplerPerv are generated, but result of ReadFocus probably goes to SamplerCurr first than pass to SamplerPrev at next cycle.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Re: enbeffectprepass.fx extra GUI & enblens.fx ALF effect

uvsrc.xy=uvsrc.xy; // I think I add this because compiler error.... .
Did you add that? I ask because it is also in the file that I started from. I think it originates here:
http://www.nexusmods.com/skyrim/mods/24024

That still seems weird to assign uvsrc to itself which essentially does nothing right? What kind of compiler error did you get?

The next line:
uvsrc.xy+=offset * pixelSize.xy * FocusSampleRange;// offset uvsrc.


This seems strange also. Instead of resetting uvsrc to (FPx, FPy) every iteration and offsetting from there, it is offset from it's previous loop value using +=.
If we use the values from the offset[] array (previously posted), this means that, since uvsrc is not reset, it has the following offsets in the loop (not accounting for pixelSize and FocusSampleRange):
(0.0, 1.0) + (0.0, -1.0) =
(0.0, 0.0) + (1.0, 0.0) =
(1.0, 0.0) + (-1.0, 0.0) =
(0.0, 0.0)

Instead, consider the below code which offsets from your FP point:

Code: Select all

uvsrc.xy = float2(FPx, FPy) + offset[i] * pixelSize.xy * FocusSampleRange;
I think this would give you the intended sampling from the four offsets around the FP point instead of the above example where you get two points at (0.0, 0.0).

The other part I find strange is that the offset is multiplied by pixelSize. This means that, unless the FocusSampleRange is huge, the offsets are only a few pixel from each other. This is why I think the difference between the original and my change above is not noticable since FocusSampleRange is typically set to 1.0. Contrast this to Boris' version of the loop code from the default version of the file:

Code: Select all

float2 tdir=offset[i].xy;
coord.xy=IN.txcoord.xy+tdir.xy*invscreensize;
Notice a few things here:
1. He uses = and not += for the coord.xy so it is not updating, but resetting each iteration
2. Instead of offsetting from a single input point (i.e . FP) he is offsetting from each input uv coordinate (i.e. IN.txcoord)
3. He is not multiplying by pixelSize (only invscreensize to correct for aspect ratio). So the offsets are much larger since they are in uv space and not pixel space.

So, it seems like this version would return blurred depth values for each region of the screen as opposed to the above versions that return the blurred depth values for a very small region around the FP point, which would typically be set to the center of the screen (0.5, 0.5).

Maybe a nice compromise is something like this?

Code: Select all

uvsrc.xy = float2(FPx, FPy) + offset[i] * FocusSampleRange;
It's around the fixed FP point, but is offset in uv space so that FocusSampleRange is much more sensitive.

I'd be interested to hear anyone's thoughts on this. Thanks for reading!
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

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

Re: enbeffectprepass.fx extra GUI & enblens.fx ALF effect

ok, I thought something like uvsrc.xy=uvsrc.xy is not from the original file, apparently I'was wrong. And I think you are right about the offset calculation, while gp65cj04's original intend is unknown, you can probably do some adjustment.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Re: enbeffectprepass.fx extra GUI & enblens.fx ALF effect

Thanks for the response. I'm going to keep working with the code and I'll update with any findings.
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

Offline
User avatar
*sensei*
Posts: 446
Joined: 17 Apr 2014, 22:12
Location: Schweden

Re: enbeffectprepass.fx extra GUI & enblens.fx ALF effect

The DoF is just wonderful! Manual focusing really creates some cool images. :)

Image

Image
_________________
| i5 3350p @3.1 | 16 GB RAM | GTX1060 | Skyrim on SSD |
My Flickr
My Soundcloud
CGI ENB

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

Re: DOF extra & ALF effect 7/9 update

7/9 update

add custom bokeh shape [WIP]
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*sensei*
Posts: 446
Joined: 17 Apr 2014, 22:12
Location: Schweden

Re: DOF extra & ALF effect 7/9 update

Thanks for update! :)

kingeric1992 wrote: Is there anyway to add custom texture file instead of using enbpalette??
Perhaps I'm shooting in dark here, with a blindfold, hanging upside down, with a BB gun at 200 meters. But.....
Can this work?

Code: Select all

texture2D texExampleTexture
<
   string ResourceName="ExampleTexture.tga";
>;
sampler2D SamplerExampleTexture = sampler_state
{
   Texture   = <texExampleTexture>;
   MinFilter = LINEAR;
   MagFilter = LINEAR;
   MipFilter = NONE;
   AddressU  = Wrap;
   AddressV  = Wrap;
   SRGBTexture=FALSE;
   MaxMipLevel=0;
   MipMapLodBias=0;
};
_________________
| i5 3350p @3.1 | 16 GB RAM | GTX1060 | Skyrim on SSD |
My Flickr
My Soundcloud
CGI ENB
Post Reply