Page 1 of 3
[FO4] Flares enblens.fx
Posted: 19 Dec 2016, 13:53
by kingeric1992
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:
Select "lens" in technique under [ENBLENS.FX]
- enblens.fx
- update: Dec.19.2016
- (18.5 KiB) Downloaded 892 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)
Re: [FO4] Flares enblens.fx
Posted: 19 Dec 2016, 15:00
by Marty McFly
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.
Re: [FO4] Flares enblens.fx
Posted: 19 Dec 2016, 15:10
by kingeric1992
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.
Re: [FO4] Flares enblens.fx
Posted: 19 Dec 2016, 15:22
by Marty McFly
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.
Re: [FO4] Flares enblens.fx
Posted: 19 Dec 2016, 17:19
by kingeric1992
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.
Re: [FO4] Flares enblens.fx
Posted: 19 Dec 2016, 17:44
by Oyama
Fantastic. No other word.
Ah, yes : THANK YOU.
Re: [FO4] Flares enblens.fx
Posted: 19 Dec 2016, 18:19
by Oyama
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...
Re: [FO4] Flares enblens.fx
Posted: 19 Dec 2016, 18:40
by kingeric1992
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.
Re: [FO4] Flares enblens.fx
Posted: 19 Dec 2016, 18:51
by Oyama
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 ?
Re: [FO4] Flares enblens.fx
Posted: 19 Dec 2016, 20:26
by kingeric1992
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.