Oooooh. So if I wanted a performance boost, I would do complicated float calculations in the vertex shader (that don't use any colour data), then use the result in the pixel shader?ENBSeries wrote:Vertex shader is faster, because it have only 6 vertices of two triangles for computing anything, instead of each pixel on the screen for pixel shader. For example:
Converting SweetFX Effects To ENB
- Author
- Message
-
Offline
- *sensei*
- Posts: 316
- Joined: 12 Aug 2013, 18:55
- Location: Scotland
Re: Converting SweetFX Effects To ENB
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
-
Offline
- *sensei*
- Posts: 316
- Joined: 12 Aug 2013, 18:55
- Location: Scotland
Re: Converting SweetFX Effects To ENB
Decided to take a gander ReShade's GemFX motion blur...Yeah, I'm a bit lost.
One of the first roadblocks is getting the screen resolution. To do that, would I just need to do something like:
Or is that not what res is for?
There is the float4 Screensize, but it doesn't have a way to access the height; just the width. So ya have to do this:
Then there are these Texture2D and Sampler2D lines. I've not much clue how to port these; we're not to add/remove any of these as stated in the enbeffect.fx file. There's probably no need for these, since ENB has it's own Texture2D's and stuff, but...Yeah, dunno how to go about that.
One of the first roadblocks is getting the screen resolution. To do that, would I just need to do something like:
Code: Select all
float FyTyMotionBlueScreenWidth = res.x;
float FyTyMotionBlueScreenHeight = res.y;
There is the float4 Screensize, but it doesn't have a way to access the height; just the width. So ya have to do this:
Code: Select all
float FyTyMotionBlurScreenHeight = ScreenSize.x * ScreenSize.z;
Then there are these Texture2D and Sampler2D lines. I've not much clue how to port these; we're not to add/remove any of these as stated in the enbeffect.fx file. There's probably no need for these, since ENB has it's own Texture2D's and stuff, but...Yeah, dunno how to go about that.
Code: Select all
texture2D ambCurrBlurTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
texture2D ambPrevBlurTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
texture2D ambPrevTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
sampler2D ambCurrBlurColor { Texture = ambCurrBlurTex; };
sampler2D ambPrevBlurColor { Texture = ambPrevBlurTex; };
sampler2D ambPrevColor { Texture = ambPrevTex; };
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
-
Offline
- *blah-blah-blah maniac*
- Posts: 17562
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: Converting SweetFX Effects To ENB
If those textures are for previous frame too, you can't do such code in ENBSeries, because i use the same textures everywhere to reduce video memory usage, only temporal antialiasing have cross frame textures. Also if that motion blur is what i'm thinking about, you don't have access to current and previous camera positions and time when it's rendered is not synced with game timer when camera is set and frame time is captured, so blur will be annoying distance flickering crap. But if this blur is just accumulative, similar to long exposure mode in Skyrim mod, still no data saved as old frame. At this moment you may use render targets provided in enbeffectpostpass, they are not cleared, but when i'll use them for any other purposes effect will be ruined. The last, sli/crossfire have poor performance with textures from previous frame.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
-
Offline
- *sensei*
- Posts: 316
- Joined: 12 Aug 2013, 18:55
- Location: Scotland
Re: Converting SweetFX Effects To ENB
Aye, the shader appears to use the current and previous frames to make the motion blur.ENBSeries wrote:If those textures are for previous frame too, you can't do such code in ENBSeries, because i use the same textures everywhere to reduce video memory usage, only temporal antialiasing have cross frame textures. Also if that motion blur is what i'm thinking about, you don't have access to current and previous camera positions and time when it's rendered is not synced with game timer when camera is set and frame time is captured, so blur will be annoying distance flickering crap. But if this blur is just accumulative, similar to long exposure mode in Skyrim mod, still no data saved as old frame. At this moment you may use render targets provided in enbeffectpostpass, they are not cleared, but when i'll use them for any other purposes effect will be ruined. The last, sli/crossfire have poor performance with textures from previous frame.
Oh well. I'll see what else looks cool to bugger around with.
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
-
Offline
- *sensei*
- Posts: 316
- Joined: 12 Aug 2013, 18:55
- Location: Scotland
Re: Converting SweetFX Effects To ENB
Found a DOS shader from an old ENB preset. Sadly, it's not a straight port; the preset is broken up into individual shader files. Naturally, I attempted to get it to work.
ENB seems happy with my port; no errors are outputted, but it does nothing; when enabled/disabled, there is no change to the screen.
Here's the original shader:
Here are the variables & my port:
Just to clarify, outputting the shader can be mixed with rgb and xyz, like so? :
Or
Or
etc.
ENB seems happy with my port; no errors are outputted, but it does nothing; when enabled/disabled, there is no change to the screen.
Here's the original shader:
Code: Select all
//===================================================================
// DOS game effect originally by Boris Vorontsov (http://enbdev.com)
//===================================================================
#include "common.fxh"
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Configuration flags
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// DO NOT CHANGE THESE HERE, CHANGE THEM IN effect.txt
// The pixel size, larger = more pixelated. A value of 1 should be identical to the original game,
// but a bug in ENBSeries currently means some lines might still be blended vertically (AR bug)
#ifndef PIXELSIZE
#define PIXELSIZE 6
#endif
// Change all of the colors to feel more like a limited color palette
// #define DOSCOLORS
// The additional post brightness curve to apply, to make things less dark - only with DOSCOLORS
#ifndef POSTCURVE
#define POSTCURVE 0.5
#endif
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Post-processing pixel shader
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
float4 PS_DosGame(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float4 coord=0.0;
coord.xy=IN.txcoord.xy;
float4 origcolor;
coord.w=0.0;
float2 xs = ScreenRect / PIXELSIZE;
float EColorsCount=16.0001;
coord.xy=floor(IN.txcoord.xy * xs)/xs;
origcolor=tex2Dlod(SamplerColor, coord);
#ifdef DOSCOLORS
origcolor+=0.0001;
// origcolor=lerp(origcolor, normalize(origcolor), 0.5);
float graymax=max(origcolor.x, max(origcolor.y, origcolor.z));
float3 ncolor=origcolor.xyz/graymax;
graymax=floor(graymax * EColorsCount)/EColorsCount;
origcolor.xyz*=graymax;
// origcolor=floor(origcolor * EColorsCount)/EColorsCount;
origcolor.xyz = pow(origcolor.xyz, POSTCURVE);
#endif
origcolor.w=1.0;
return origcolor;
}
#define SHADER PS_DosGame
#include "technique.fxh"
Code: Select all
#define FIFTYTIFTY_DOS_GUI
Code: Select all
bool bFiftyTiftyDOS
<
string UIName = "DOS: Enable";
> = {false};
#ifdef FIFTYTIFTY_DOS_GUI
float DOSPixelSize
<
string UIName="DOS: Pixel Size";
string UIWidget="spinner";
float UIMin=0.00;
float UIMax=100.00;
float UIStep=0.01;
> = {1.00};
#endif
Code: Select all
if(bFiftyTiftyDOS)
{
float ScreenWidth = ScreenSize.x;
float ScreenWidthInv = ScreenSize.y;
float ScreenScaleY = ScreenSize.z;
float ScreenScaleYInv = ScreenSize.w;
float ScreenHeight = (ScreenWidth / ScreenScaleY);
float ScreenHeightInv = (ScreenScaleY / ScreenWidth);
float2 ScreenRect = float2(ScreenWidth, ScreenHeight);
float4 coord=0.0;
coord.xy=IN.txcoord0.xy;
float4 origcolor = color.xyzw;
coord.w=0.0;
float2 xs = ScreenRect / DOSPixelSize;
float EColorsCount=16.0001;
coord.xy=floor(IN.txcoord0.xy * xs)/xs;
/* if(bDOSCOLORS)
{
origcolor+=0.0001;
// origcolor=lerp(origcolor, normalize(origcolor), 0.5);
float graymax=max(origcolor.x, max(origcolor.y, origcolor.z));
float3 ncolor=origcolor.xyz/graymax;
graymax=floor(graymax * EColorsCount)/EColorsCount;
origcolor.xyz*=graymax;
// origcolor=floor(origcolor * EColorsCount)/EColorsCount;
origcolor.xyz = pow(origcolor.xyz, POSTCURVE);
}
*/
origcolor.w=1.0;
color.xyzw = origcolor.xyzw;
}
Just to clarify, outputting the shader can be mixed with rgb and xyz, like so? :
Code: Select all
color.rgb = ChangedColor.xyz
Code: Select all
color.rgba = ChangedColor.xyzw
Code: Select all
color.xyz = ChangedColor.rgb
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
-
Offline
- *blah-blah-blah maniac*
- Posts: 565
- Joined: 05 Apr 2014, 10:29
- Location: Taiwan
Re: Converting SweetFX Effects To ENB
you missed this line:
to
I suppose no need for lod.
Code: Select all
origcolor=tex2Dlod(SamplerColor, coord);
Code: Select all
origcolor=TextureColor.Sample(Sampler1, coord);
Code: Select all
if(bFiftyTiftyDOS)
{
float2 ScreenRect = float2(ScreenSize.x, ScreenSize.x * ScreenSize.w);
float2 xs = ScreenRect / DOSPixelSize;
float2 coord = floor(IN.txcoord0.xy * xs)/xs;
float4 origcolor = TextureColor.Sample(Sampler1, coord);
float EColorsCount=16.0001;
/* if(bDOSCOLORS)
{
origcolor+=0.0001;
// origcolor=lerp(origcolor, normalize(origcolor), 0.5);
float graymax=max(origcolor.x, max(origcolor.y, origcolor.z));
float3 ncolor=origcolor.xyz/graymax;
graymax=floor(graymax * EColorsCount)/EColorsCount;
origcolor.xyz*=graymax;
// origcolor=floor(origcolor * EColorsCount)/EColorsCount;
origcolor.xyz = pow(origcolor.xyz, POSTCURVE);
}
*/
origcolor.w=1.0;
color.xyzw = origcolor.xyzw;
}
-
Offline
- *sensei*
- Posts: 316
- Joined: 12 Aug 2013, 18:55
- Location: Scotland
Re: Converting SweetFX Effects To ENB
I changed the two lines:kingeric1992 wrote:you missed this line:toCode: Select all
origcolor=tex2Dlod(SamplerColor, coord);
I suppose no need for lod.Code: Select all
origcolor=TextureColor.Sample(Sampler1, coord);
Code: Select all
float4 origcolor;
...
origcolor=tex2Dlod(SamplerColor, coord);
Code: Select all
float4 origcolor = color.xyzw;
I'll punt it in and see if it works.
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
-
Offline
- *sensei*
- Posts: 316
- Joined: 12 Aug 2013, 18:55
- Location: Scotland
Re: Converting SweetFX Effects To ENB
Tried fluffing with it myself, didn't work out so well. The colour changed, but there was no pixelation.
Your version works, but also has the same colour change; everything is blackened. I think this is because the prior shaders are being "skipped", so to speak, because we're not using the color.rgb shader output.
But adding in:
Causes the image to be unchanged, as if the effect were disabled. Ergh.
Your version works, but also has the same colour change; everything is blackened. I think this is because the prior shaders are being "skipped", so to speak, because we're not using the color.rgb shader output.
But adding in:
Code: Select all
OrigColor.rgb = color.rgb;
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
-
Offline
- *blah-blah-blah maniac*
- Posts: 565
- Joined: 05 Apr 2014, 10:29
- Location: Taiwan
Re: Converting SweetFX Effects To ENB
it modified where to sample color, not just changing current color,
so it should be place into enbeffectpostpass.
so it should be place into enbeffectpostpass.
-
Offline
- *sensei*
- Posts: 316
- Joined: 12 Aug 2013, 18:55
- Location: Scotland
Re: Converting SweetFX Effects To ENB
Isn't Postpass.fx a lesser form of ENBEffect.fx, as was the case of effect.txt (with enbeffectpostpass.fx being the newer version of effect.txt)? Surely it's possible to implement the shader in enbeffect.fx?kingeric1992 wrote:it modified where to sample color, not just changing current color,
so it should be place into enbeffectpostpass.
We have this code here:
Code: Select all
float2 ScreenRect = float2(ScreenSize.x, ScreenSize.x * ScreenSize.w);
float2 xs = ScreenRect / DOSPixelSize;
float2 coord = floor(IN.txcoord0.xy * xs)/xs;
Code: Select all
float4 origcolor = Color.Sample(Sampler1, IN.coord);
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming