[FO4] Flares enblens.fx

share shaders here
  • Author
  • Message
Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

[FO4] Flares enblens.fx

Code: Select all

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
//                                                                  //
//  Flares enblens.fx by kingeric1992                               //
//                                                                  //
//  Featuring:                                                      //
//      Fully customizable lens flare with the capability of        //
//  achieving multiple visual representation of various lens flares //
//  observed in physical cameras.                                   //
//                                                                  //
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
demo shots:
Image
Image
Image
Image

Select "lens" in technique under [ENBLENS.FX]
enblens.fx
update: Dec.19.2016
(18.5 KiB) Downloaded 857 times
For noise dispersion, download noise texture here http://i.imgur.com/zPkMJyb.png and rename it to enbGrain.png
(will try to do procedural noise in the future)
_________________
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
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: [FO4] Flares enblens.fx

Great work once again!
For procedural noise, try simplex noise or radical inverse, both have noise profiles that fit this purpose very well. For simplex, Cryengine V source had a short and clean implementation as opposed to some shadertoys. Just in case you don't want to write it yourself, that is.

Don't use radians(), it's slow and generates dozens of instructions, just multiply by pi/180 and you're fine. I know you're not micro optimizing your shaders but that's what jumped my eye.

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

Re: [FO4] Flares enblens.fx

The thing is, I need to wrap this thing right now before I lose my interest and buried it in my hard drive forever...along with several other 90% finished effects...

About radians(), it is multiply the input by 0.017453, which is PI / 180.

To optimize further, I can move the vertices computation to vertex shader, but probably not much to gain on frame rate wide.

Btw, in dx9 static computation such as this is handled by preshader and only execute once per frame, in dx10 and later, it is computed per pixel, including DNI separation ops.
Last edited by kingeric1992 on 19 Dec 2016, 15:23, edited 1 time in total.
_________________
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
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: [FO4] Flares enblens.fx

Heh, I know that. Trying some super complex project: ah yiss.
Once you manage to do it, interest drops to 0. I have a metric ton of shader stuff on my HDD that isn't really polished enough for release so I'm too lazy to finish it.

About radians, according to Pherson's Low level thinking, it doesn't do that, but creates dozens of instructions instead and that's coherent with some tests I did a while back with my old DOF.

At least we have a lot more instructions etc possible in DX11 so one could theoretically do all DNI TOD separation in vertex shader.

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

Re: [FO4] Flares enblens.fx

Code: Select all

float4 PS_Test( float4 pos : SV_POSITION, float2 txcoord : TEXCOORD0) : SV_Target
{
    return radians(test);
}
is just a single mul instruction.

Code: Select all

mul o0.xyzw, cb0[0].xxxx, l(0.017453, 0.017453, 0.017453, 0.017453)
The same goes to dx9.

(btw, atan takes 32 instructions)

I guess they just said that for preference, thinking the operation is easy enough that using build-in function is a shame or something.
_________________
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
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: [FO4] Flares enblens.fx

Fantastic. No other word.
Ah, yes : THANK YOU.
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: [FO4] Flares enblens.fx

One question, though : can we set your passes of techniques after those from original enb lens shader, renaming them to continue after

technique11 MultiPassLens3
{
pass p0
{
SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
SetPixelShader(CompileShader(ps_5_0, PS_LensMix()));
}
}

as ' MultiPassLens 4, 5, and so on ? and modifying their VS and PS shaders, of course.
Guess that yes, as vertex shader and structures are different...
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop

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

Re: [FO4] Flares enblens.fx

you need to set render target here to store the frame at somewhere else,

technique11 MultiPassLens3 <string RenderTarget="RenderTargetRGBA64F";>

then blend it back later on with

color += RenderTargetRGBA64F.Sample(Sampler1, coord);

As I'm using the swap chain, anything written on it will be overwritten during the process.
_________________
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
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: [FO4] Flares enblens.fx

Ok. I see. Thank you !
Do you advice setting your passes of technique after Enb's or the other way around ?
I guess yours after, right ?
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop

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

Re: [FO4] Flares enblens.fx

It doesn't matters, both ways are fine.

It is also possible to have them running parallel.
I might as well add it in future update.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube
Post Reply