Duplicating Shaders

  • Roxxtar
  • Topic Author
More
8 years 9 months ago #1 by Roxxtar Duplicating Shaders was created by Roxxtar
Is having duplicate "variations" of the same shader possible?

Due to the fact that I'm applying "on key press" activation of certain effects (discussed in my other topic), by nature it then renders each effect that I use in that regard effectively useless for it's normal purpose. For example, if I use Heat Haze and attach it to a key press that will time out after 2000ms, I can not also have an "always on" Heat Haze effect running at all times to add beauty to static light sources and fires in the game world.

Is there any way to have "duplicate" versions of the same effect, like a HeatHaze1 and a HeatHaze2, so the first can be used normally as it was intended, then the second can be used only during the key toggle and timeout?

My concern is that with each shader I set for users to trigger via key press, the less beautiful the overall preset will become, as every effect that is assigned to a key toggle can no longer run at all times as well. Of course doubling up on the same effect is redundant in a typical scenario, but with what I'm doing the on-press variation are extremely strong and "in your face" for a reason, while the normal versions are subtle and add a little spice to the graphics.

Simply put; is there any way I can make multiple versions of the same shader, with each having it's own unique settings?

One other thing:

I notice this in the core ReShade 0.19.1 and I'm very curious as to it's function:

* technique tech3 < toggleTime = 100; > { ... }
* > Toggle this technique at the specified time (seconds after midnight).

Does that apply to in-game time or real life time? Please tell me that it is game time! I'm drooling over the possibility of being able to have different effects toggle on for day and night in the game.

Please Log in or Create an account to join the conversation.

  • Ganossa
More
8 years 9 months ago #2 by Ganossa Replied by Ganossa on topic Duplicating Shaders
If you would use the same values you could duplicate the pass calls in additional techniques but depending on your effects you would every time put a lot of impact on fps unless you time those techniques also with the toggle keys. (Anyway, it will be seriously hand tailored stuff)

I am pretty sure the toggle time refers to system time. There is no general/global game time value that ReShade could access. (Think of VLC or a chess game :P )
The following user(s) said Thank You: Roxxtar

Please Log in or Create an account to join the conversation.

  • crosire
More
8 years 9 months ago - 8 years 9 months ago #3 by crosire Replied by crosire on topic Duplicating Shaders
Correct, it is system time. There is no way for ReShade to generically access something as the game time (not every game even has its own separate clock).

About duplicate shaders: You could alternativly duplicate the entire shader file plus config file entries and rename all variables in the copy so there are no naming clashes ("fHeatHazeSpeed" to "fHeatHazeSpeed2" etc. for example). Then just add that copy to "ReShade\EffectOrdering.cfg" too and you now have the same shader twice.
Last edit: 8 years 9 months ago by crosire.
The following user(s) said Thank You: Roxxtar

Please Log in or Create an account to join the conversation.

  • Roxxtar
  • Topic Author
More
8 years 9 months ago #4 by Roxxtar Replied by Roxxtar on topic Duplicating Shaders
I figured it would work like that, thanks for the clarification Crosire.

Shouldn't be too much of a hassle at all to duplicate the shaders now, just a bit of copying and renaming files, using find and replace tactically to change the variables with haste, and punching the new entries for the dupes into the config files so they can have separate settings.
The following user(s) said Thank You: crosire

Please Log in or Create an account to join the conversation.

  • Roxxtar
  • Topic Author
More
8 years 9 months ago - 8 years 9 months ago #5 by Roxxtar Replied by Roxxtar on topic Duplicating Shaders
Lucifer notified me that distributing the duped shaders would be a violation of the redistribution rules, which makes sense.

I have a possible solution...

Would you perhaps consider activating the "Upload Attachments" feature of Kunena, then changing the distribution terms to prohibit redistribution everywhere except on the reshade.me domain?

That would solve more problems than just this one. You'd spend a lot less time traveling around to enforce the policies, and would have full admin control to approve/remove all ReShade related files. Shader authors would no longer need to use third party file hosting services, which means less outgoing links and more incoming deep links - which are the best kind - such as in my case where I could attach my duplicate effects to a post I make here, then link to it from my mod page for users to head over here and download the required files.

The only possible drawback is bandwidth usage, but if you're on a decent host that should be a non-issue considering that virtually all uploaded files would be smaller in size than the framework. If necessary you can also set a file size limit with Kunena, just to be sure someone doesn't try to upload a prohibitively large file.

What do you think?
Last edit: 8 years 9 months ago by Roxxtar.

Please Log in or Create an account to join the conversation.

  • Ganossa
More
8 years 9 months ago #6 by Ganossa Replied by Ganossa on topic Duplicating Shaders
I actually wrote your directly and in person because I wanted to discuss possible solutions to the duplication issue first. However, I am a little surprised that you turned the conversation I just started with you to the forum and not to me? (If there is something that makes a direct conversation with me uncomfortable, please let me know)

I personally think there are very likely a few better solutions than duplicating entire shaders X times just to have the same effect X times.
It would be important to discuss and consider those first.

Please Log in or Create an account to join the conversation.

  • kingeric1992
More
8 years 9 months ago #7 by kingeric1992 Replied by kingeric1992 on topic Duplicating Shaders
for duplicate "variations" of the same shader,
just move variables to shader arguments, for example

in shader:
float4 PS_Haze( uniform float pra, uniform bool boolean....etc.)
{
...
}

and in technique

P0
pixelshader = compile PS_Haze( custum_value1, custom_bolean1...)

P1
pixelshader = compile PS_Haze( custum_value2, custom_bolean2...)

...

use multiple technique or pass to draw same effect any times you want without copying entire shader.

Also probably need to change blending mode.
The following user(s) said Thank You: Ganossa

Please Log in or Create an account to join the conversation.

  • crosire
More
8 years 9 months ago - 8 years 9 months ago #8 by crosire Replied by crosire on topic Duplicating Shaders
Please note again that those distribution regulations apply to the framework shaders only, which are a separate project and not ReShade, so this website is not responsible for them.

kingeric1992 wrote: for duplicate "variations" of the same shader,
just move variables to shader arguments, for example

Good idea =). That's HLSL though, not ReShade effect code, so to achieve the same with ReShade, do something like this:
float4 PS_Haze(float param1, float param2, ...)
{
    ...
}

float4 PS_Haze_Variation1()
{
    return PS_Haze(custom_value1, custom_value2, ...);
}
float4 PS_Haze_Variation2()
{
    return PS_Haze(custom_value3, custom_value4, ...);
}

...

PixelShader = PS_Haze_Variation1;

...

PixelShader = PS_Haze_Variation2;
Last edit: 8 years 9 months ago by crosire.
The following user(s) said Thank You: Ganossa

Please Log in or Create an account to join the conversation.

  • Ganossa
More
8 years 9 months ago - 8 years 9 months ago #9 by Ganossa Replied by Ganossa on topic Duplicating Shaders
That is one possibility. One that would still need you to adjust the shader code though for X variations.

To have it 100% independent from shader code you can simply #define and #undef your variables before each time you call the effect for however often you want to do it.

(that would only need a little adjustment by us for the general includes in the specific shader files that then can be shipped with the Framework to anyone just like before)

Here a concept:

(very weak pseudo code :P)
effect ordering:
#include(gemfx, bloom2) 

bloom2:
#define ThisIsADublicate
#define Y
//might need to put a namespace around this include to deal with conflicts
#include bloom

#undef ThisIsADublicate
#undef Y

bloom:
#ifndef ThisIsADublicate 
#include gemFx_settings.cfg
Last edit: 8 years 9 months ago by Ganossa.
The following user(s) said Thank You: Roxxtar

Please Log in or Create an account to join the conversation.

  • Ganossa
More
8 years 9 months ago #10 by Ganossa Replied by Ganossa on topic Duplicating Shaders
Added this feature in a first concept for the new release (which means it is not supported by the mediator)

Anyway, you can freely play around with it :)

There is an example duplicate shader in CustomFX for TiltShift called "TiltShiftDuplicateExample.h" with the following content:
//This is an example on how to create a duplicate Shader
//This is possible for the following shader
/*
TilftShift from CustomFX Suite

All shader in GemFX Suite

HeatHaze and FishEye in McFX Suite

Explosion and CA in SweetFX Suite
*/
//Include the duplicate shader in EffectOrdering.cfg -> e.g. #include EFFECT(CustomFX, TiltShiftDuplicateExample)
//Note that values for duplicate shader are not yet configurable in the mediator -> changes in the EffectOrdering.cfg will be overwritten in the mediator

#define RFX_duplicate
////-------------//
///**TILTSHIFT**///
//-------------////
#define USE_TILTSHIFT 0 //[TiltShift] //-TiltShift effect based of GEMFX

//>TiltShift Settings<\\
#define TiltShiftPower 5.0 //[0.0:100.0] //-Amount of blur applied to the screen edges
#define TiltShiftCurve 3.0 //[0.0:10.0] //-Defines the sharp focus / blur radius
#define TiltShiftOffset -0.6 //[-5.0:5.0] //-Defines the sharp focus aligned to the y-axis
#define TiltShift_TimeOut 0 //[0:100000] //-Defined Toggle Key will activate the shader until time (in ms) runs out. "0" deactivates the timeout feature.
#define TiltShift_ToggleKey VK_SPACE //[undef] //-

#include "ReShade/CustomFX/TiltShift.h

#undef USE_TILTSHIFT
#undef TiltShiftPower
#undef TiltShiftCurve
#undef TiltShiftOffset
#undef TiltShift_TimeOut
#undef TiltShift_ToggleKey
#undef RFX_duplicate

This should give you an idea how to implement it for the other supported shader :)
Please ask if there are any questions.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.