Static DOF with blur highlights?

about everything
Post Reply
  • Author
  • Message
Offline
User avatar
*master*
Posts: 188
Joined: 26 Apr 2014, 20:05

Static DOF with blur highlights?

I've been playing with this:

https://www.nexusmods.com/skyrim/mods/54553

and it looks great. I love the glistening highlights thing it does with blurred objects, but I need it to be a fixed blur that I can set the near and far distance of as it blurs everything due to the game being 3rd person and its focus is on the player character.

Does anyone have a enbeffectprepass I could use, or know of a preset on the Nexus which allows this effect on static distant blur?

I don't have the knowledge to modify the code. The last time I programmed a language was using a floppy disk DOS compiler so I'm a bit behind the times.

ta

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17447
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Static DOF with blur highlights?

In the end of code of ReadFocus or WriteFocus functions set constant output value and you will have what you want (after tweaking it).
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
*master*
Posts: 188
Joined: 26 Apr 2014, 20:05

Re: Static DOF with blur highlights?

yeah. I understand what you're saying but I don't understand the syntax.

Like I've told you. I was a PL/1 programmer around 1990 and haven't done any since then. I can just about remember ZX Spectrum basic never mind C.

But thanks anyway.

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17447
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Static DOF with blur highlights?

Every dof shader have PS_WriteFocus function, like the following (but dont expect it unmodified by preset makers):
float4 PS_WriteFocus(VS_OUTPUT_POST IN) : COLOR
{
float2 uvsrc=0.0;//IN.txcoord0.xy;

//const float pixsizex=4.0;
// uvsrc.xy-=(0.5+0.0625)/4.0;
// const float step=0.125/4.0;
float pos=0.0001;
float res=0.0;
float curr=0.0;
float prev=0.0;
float currmax=0.0;
float prevmax=0.0;
for (int ix=0; ix<16; ix++)
{
float tcurr=tex2D(SamplerCurr, (uvsrc.xy*0.25+0.125)).x;//the same for all 4 pixels
float tprev=tex2D(SamplerPrev, (uvsrc.xy*0.25+0.125)).x;//the same for all 4 pixels
currmax=max(currmax, tcurr);
prevmax=max(prevmax, tprev);
curr+=tcurr;
prev+=tprev;
uvsrc.x+=1.0;
if (uvsrc.x>4.0)
{
uvsrc.x=0.0;
uvsrc.y+=1.0;
}
}
curr*=0.0625;
prev*=0.0625;

res=lerp(prev, curr, saturate(FadeFactor));//time elapsed factor
res=max(res, 0.0);

return res;
}

Before "return res;" you should force that res value to some constant, for example:
res = 1.0;
so the final code will be:
float4 PS_WriteFocus(VS_OUTPUT_POST IN) : COLOR
{
float2 uvsrc=0.0;//IN.txcoord0.xy;

//const float pixsizex=4.0;
// uvsrc.xy-=(0.5+0.0625)/4.0;
// const float step=0.125/4.0;
float pos=0.0001;
float res=0.0;
float curr=0.0;
float prev=0.0;
float currmax=0.0;
float prevmax=0.0;
for (int ix=0; ix<16; ix++)
{
float tcurr=tex2D(SamplerCurr, (uvsrc.xy*0.25+0.125)).x;//the same for all 4 pixels
float tprev=tex2D(SamplerPrev, (uvsrc.xy*0.25+0.125)).x;//the same for all 4 pixels
currmax=max(currmax, tcurr);
prevmax=max(prevmax, tprev);
curr+=tcurr;
prev+=tprev;
uvsrc.x+=1.0;
if (uvsrc.x>4.0)
{
uvsrc.x=0.0;
uvsrc.y+=1.0;
}
}
curr*=0.0625;
prev*=0.0625;

res=lerp(prev, curr, saturate(FadeFactor));//time elapsed factor
res=max(res, 0.0);
res = 1.0;
return res;
}

and tweak that value 1.0 to something you need to see on the screen, step by step changing it and see what happens on the screen. This res variable is focusing distance in depth space, so when it is set to 1.0, then horizon should be blurred. If 0, then everything close to camera is blurred.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
*master*
Posts: 188
Joined: 26 Apr 2014, 20:05

Re: Static DOF with blur highlights?

Thank you!!

res=0.85; was all what was needed.

cheers
Post Reply