enblens.fx WeatherFX

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

enblens.fx WeatherFX

Hi everyone,
this enblens.fx contains Boris' stock lens reflection/dirt & following weather specific effects.


Detail instructions are in the file.
Requirement:
enb 264+
WeatherFX.rar
update: Dec 9, 2016
(1000.84 KiB) Downloaded 1404 times
It also contains .psd photoshop resource for creating droplets.
Use smudge tool and liquid filter to deform droplets.
video demo
and arrange them like this (will add more variant in the future....)
Image
(alpha channel is for alpha mask)

Thanks to number6 for discussing with me.
Thanks to abc for inputs and helping me testing weather settings.
Thanks to Boris making this possible with new parameters.

======= Additional Demos =========

Dynamic Lens Dirt:

Normal mapped Droplet:
amazing demo made by abc75179778300 (CR ENB)

Frost vignette for snow
Image


=======history version=========
ENBweatherFX.rar
update: Jan 17, 2015
(819.56 KiB) Downloaded 1804 times
=======update history=========

12/9/2016 update
Upload new file, allows more flexiblity and easy management.

1/20 update
change file host to enbdev
add a demo made by abc

1/17 update
update weatherFX.rar
add normal map droplet

12/7 update
Add WeatherFX.rar
description change
Topic change

9/5 update
Add link to CR ENB
update post Subject

8/30 update
testing weather trainsition
Rain:https://www.youtube.com/watch?v=CtcJKgOYcMk
Frost:https://www.youtube.com/watch?v=GGnwTLvR_fA
8/7 update
Frost vignette suggested by Insomnia
Last edited by kingeric1992 on 08 Dec 2016, 18:40, edited 16 times 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
*sensei*
Posts: 372
Joined: 28 Jul 2013, 23:26

Re: Raindrop on Lens effect in enblens.fx

Not that I know an answer to your question, but just curious... you can configure different lens effects based on weather type? Does LensParameters contain the weather type somehow? That would actually be nice. If something like that is possible I may actually spend some hours into that shader.

Would anyway be great to have a parameter in the globals that has something like 0=sunny, 1=cloudy, 2=rain, 3=snow, etc

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

Re: Raindrop on Lens effect in enblens.fx

Currently the LensParameters has 4 components, x=reflection intensity, y=reflection power, z=dirt intensity, w=dirt power, which are controlled by enbseries.ini. In order to pass weather parameters, the additional weather info need to encode to the floats, and since lens reflection and dirt effect don't necessary require high precision in my experience, I just utilize decimal parts( < 1.0 ).

for example
int is for original lens parameter
0.0~0.9 is rain parameter
0.00~0.09 is fog parameter
....etc

then

Code: Select all

float orginalpara = floor(input);
float weatherTemp = frac(input); //utilize 0.1, 0.01, 0.001

float3 weatherpara = float3( floor( 10 * frac(weatherTemp)), floor( 10 * frac(weatherTemp * 10)), floor( 10 * frac(weatherTemp * 100)));
// x = 0.1, y = 0.01, z = 0.001
in this case, float4 LensParameter can save 12 weather info, it can also use BloomParameters instead in bloom.fx.
So for the raindrop effect, .0 is off, .1 ~ .9 is frequency parameter which can set according to the magnitude of rain.

cheers
_________________
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: Raindrop on Lens effect in enblens.fx

This looks very interesting. You are showing us how you decode the LensParameters back into the weather values, but how do you encode the weather values into LensParameters in the first place?

Your blending values of SRCALPHA and INVSRCALPHA look correct for an over composite, so it's weird that color still shows through with an alpha of 1. Could it be something later in the pipeline like enbeffect.fx or effect.txt? Sorry I am also no more help there.

Thanks for posting, I am learning a lot! The effect looks great!
_________________
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: Raindrop on Lens effect in enblens.fx

Sorry I didn't clear that out, this is encode method.
for example
int is for original lens parameter
0.0~0.9 is rain parameter
0.00~0.09 is fog parameterr
just set lens parameters in weahter ini files.

so if I set lens intensity to 25.237, after decoding I will get

Code: Select all

weatherpara.x = 2
weatherpara.y = 3
weatherpara.z = 7
_________________
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: Raindrop on Lens effect in enblens.fx

Thanks, now I get it, LOL. Nice job!

As for making it more realistic here's a few suggestions:

- warp the uv coordinates based on a normal map to simulate refraction
- blur the affected area under a drop
- use more than one texture that is selected randomly
- make the drops grow slightly as they fade out

Just some ideas. It already looks pretty great!
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

Offline
*sensei*
Posts: 372
Joined: 28 Jul 2013, 23:26

Re: Raindrop on Lens effect in enblens.fx

thanks. I never thought of using ENB weather system to pass weather info to the fx files. Would require quite elaborate coding for smooth transitions though... well not yours, but when for instance influencing other effects like bloom, sharpening and/or color related weather transition could be challenging. But I guess for lens effects it could do quite nicely :)

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

Re: Raindrop on Lens effect in enblens.fx

I did a simple test shader like this:

Code: Select all

float4 PS_LensPostPass(VS_OUTPUT_POST In) : COLOR
{
	float4 res = 0.0;
	res = tex2D(SamplerColor, In.txcoord0.xy);
	res.rgb = min(res.rgb, 32768.0);
	res.rgb = max(res.rgb, 0.0);

	if (In.txcoord0.x < 0.5)
		return float4(1.0, 0.0, 0.0, 1.0);
	else
		return res;
}
The technique uses:

Code: Select all

SrcBlend=SRCALPHA;
DestBlend=INVSRCALPHA;
If I turn off bloom and adapatation in the main settings, I get the left hand of the screen completely red. If bloom is on, then I see the bloom over the red. If adaptation is on then the red goes to white. Maybe enblens.fx is not the best place for your raindrops. You could pass the lens values down the pipeline by writing to a pixel and then reading the value in later shaders like effect.txt, but that is tedious.

Edit: On second thought, I don't think you can pass the values down like I suggested. Any value you write will be modified by the bloom and adaptation just like is currently happening. I have only done it between enbeffect.fx and effect.txt which are last in the pipline I think.

Can anyone confirm that this is the correct order?
enbeffectprepass.fx
enblens.fx
enbsunsprite.fx
enbbloom.fx
enbeffect.fx
effect.txt

Thanks
_________________
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: Raindrop on Lens effect in enblens.fx

prod80, another major challenge would be preventing D-N-I values from weathers ini interpolating with each others, I'm not sure how sunrise, day, sunset, night are calculated to generate final result. I am thinking that discarding the original value in weahter.ini so that its only purpose is to pass weather info, then do DNI in the .fx with predefined sets of DNI values which will switch according to the weather.

I'm sure there exist more advance method then my naive approach.

number6, thanks for the testing and suggestions. Currently the drops is only simple fish eye lens on bloom texture with random size and positions.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

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

Re: Raindrop on Lens effect in enblens.fx

on second thought, the better way to do this would be using the original lens parameters to set weather ini ID, and just switch between weather parameters according to weather ID in the shader file. about weather ID, I mean the # in _weatherlist.ini
_________________
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