enblens.fx WeatherFX

share shaders here
  • Author
  • Message
Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Re: Raindrop on Lens effect in enblens.fx

Brilliant idea there! That way you have full control in the shader.

One thing you would have to watch out for though is hitting the limit for the number of floats. For example, if you made gui controls for each of the weathers for the shader and each weather had 5 parameters you could run out quick.

Would you just code that with "if/then" statements for each weather or is there a more efficient way to do it?
_________________
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

I'm no experience programmer, but a lot of if is probably not a good idea? something like this may help

Code: Select all

step(n-0.5, x)*step(x, n+0.5)
will return 1 only when n-0.5 < x < n+0.5, and since x will be integer, it actually check if x == n.
probably do it this way:

Code: Select all

float# parameters = 0;
float x = CurrentWeatherID;

for(i = 1; i <= 100; i++)
      parameters += step(i-0.5, x )*step( x, i+0.5) * weatherParameters[i];
or use while loop?

update*
After a quick test, I found that weather inis can actually change the extension to .h header file, and it also ignore /* and */ as in INI format. (tested with ingame read/wright function)
So, I am thinking adding shader weather parameters to the weather files.

Code: Select all

//01_clear.h

/*
[BLOOM]
.
.
[ENVIRONMENT]
.
.
*/
//start shader part
float P1 = ...;
float P2 = ...;
.etc

and in the .fx

Code: Select all


#if WeatherID == 0
    #include "enbseries\01_Clear.h"
#elif WeatherID == 1
    #include "enbseries\01_Clear_02.h"
.etc

#endif
This way, there is no worry about # of floats.
Still, I don't know how to properly setup preprosessor.....Can anyone help me with this?
_________________
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 for the explanation of the step function, that is a great way to approach the if/then issue it I think.

Your idea with the weather files is very clever. However, I don't think using preprocessor directives to conditionally include the .h files will work since that only happens at compile time. Wouldn't this need to be happening as the shader is running? Also, how would you handle weather transitions since, AFAIK, there is no way in the shader to determine what the weather interpolation variable is set to. ENB would interpolate the weather IDs that you have set which is meaningless I think. Maybe your original idea of storing the values in the float components of lens parameters was better since ENB will interpolate those values for you. Although I'm not sure the interpolation would work with your decoding scheme.

Really interesting ideas here.
_________________
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

I haven't thought of any real solution to deal with transition,
If only boris can add Current Weather FileID and Ongoing Weather FileID and Transition Factor as external parameters available for shader file.
_________________
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: Weather Lens effect in enblens.fx [WIP]

That would indeed be the ideal solution. Make a note to ask for that when he's done with the clouds :lol: .
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

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

Re: Weather Lens effect in enblens.fx [WIP]

Looks like the new version addresses this issue. Thanks Boris!
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

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

Re: Weather Lens effect in enblens.fx [WIP]

This will not anyway.

Code: Select all

#if WeatherID == 0
    #include "enbseries\01_Clear.h"
#elif WeatherID == 1
    #include "enbseries\01_Clear_02.h"
.etc
These above is precompilation stage, can't work.

Code: Select all

float# parameters = 0;
float x = CurrentWeatherID;
for(i = 1; i <= 100; i++)
      parameters += step(i-0.5, x )*step( x, i+0.5) * weatherParameters[i];
These can't work, because i don't believe parameters is just one variable or vector, even two vectors means very close to shader constants limit, but actually there are much more parameters and if ignore them, then what's the reason to bother with all indexing? And of course this must be done in vertex shader and result passed as vertex data (texture coordinates, colors, etc).
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

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

Re: Weather Lens effect in enblens.fx [WIP]

I know.... that was stupid.

How about this,
since most of the weathers can be grouped and arrange by intensity (for example, from cloudy to heavy rain),
instead of setting constants per index based, using .min .max with interpolation or even curves should reduced constants count greatly.

Code: Select all

if(weatherIndex >= 62 && weatherIndex <= 70)//rain with cloud
{
	rain = lerp(RnC_RainMin, RnC_RainMax, (weatherIndex - 62) / 8);
	cloud = lerp(RnC_CloudMin, RnC_CloudMax, (weatherIndex - 62) / 8);
}
or this

Code: Select all

rain = lerp(RnC_RainMin, RnC_RainMax, (weatherIndex - 62) / 8) * (step(62, weatherIndex) + step(weatherIndex, 70) - 1);
_________________
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: Weather Lens effect in enblens.fx [WIP]

Boris also mentioned not to compute in pixel shader... unless I misunderstood this is about the weather ids.

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

Re: Weather Lens effect in enblens.fx [WIP]

prod80
Vertex shader have just 4 vertices, so 4 computations for entire screen, while pixel shader require computation for each pixel. Vertex shader allow to transfer data to pixel shader via interpolators, a lot of them (texture coordinate from 0 to 7, in first one is used 2 floats, so 30 floats still available, plus 2 colors also as 4 floats each, binormal as 4 floats, etc.). Another good thing in vertex shader is indexing to constants, pixel shader can't do this and just read all constants.

kingeric1992

Code: Select all

if(weatherIndex >= 62 && weatherIndex <= 70)//rain with cloud
...
Code like this simply reduce amount of constants used and allow to make much more parameters per weather index or amount of indices. If it's ok for you - np. Just do tests according to non perfect precision of float variables, like this:

Code: Select all

if(weatherIndex >= 61.9 && weatherIndex <= 70.1)//rain with cloud
And operation like this:

Code: Select all

(weatherIndex - 62) / 8
isn't great solution, better to make another internal table, f.e. indices 1-61 are value 1, 62-70 are value 2, then use such index for two interpolations. At least this is simpler to modify and understand.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
Post Reply