I'm looking for a way to port letterbox vignette/cinematic black bars to effect.txt. I've tried to port Matsos letterbox, HD6 and MTichenor's - ENB Evolved letterbox bars, but to no result.
Nothing happens. ENB simply won't load the file.
I'm not a coder so it's difficult for me to port effects.
I did manage to port Boris old standard round vignette (yay!) into my effect.txt. Can that effect be used to create letterbox effect?
I would be very, very happy if there would be someone who could port this effect for me, or help me doing it!
Thanks for reading!
Edit: Attaching my effect.txt for anyone who want to look.
[REQ] Letterbox vignette in effect.txt
- Author
- Message
-
Offline
- *sensei*
- Posts: 420
- Joined: 10 Jun 2012, 12:31
- Location: Sweden
[REQ] Letterbox vignette in effect.txt
- Attachments
-
- effect.txt.rar
- (2.97 KiB) Downloaded 251 times
_________________
| i5 | 8gb RAM | GTX660 | Windows 8 | Skyrim on SSD |
My music project, Akira Project, website at Sound Cloud
| i5 | 8gb RAM | GTX660 | Windows 8 | Skyrim on SSD |
My music project, Akira Project, website at Sound Cloud
-
Offline
- *blah-blah-blah maniac*
- Posts: 17564
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: [REQ] Letterbox vignette in effect.txt
Here is mine vignette and letterbox (color=function_Masking(color, uvsrc.xy); used to compute)
Code: Select all
//++++++++++++++++++++++++++++++++++++++++++++
// ENBSeries effect file
// visit http://enbdev.com for updates
// Copyright (c) 2007-2013 Boris Vorontsov
//++++++++++++++++++++++++++++++++++++++++++++
#ifndef EDEFINEDVARS
#include "effect_variables.txt"
#endif
//+++++++++++++++++++++++++++++
//internal parameters, can be modified
//+++++++++++++++++++++++++++++
//Comment any of these to disable
#define EMASKING_VIGNETTE
//#define EMASKING_VIGNETTETEXTURE
#define EMASKING_LETTERBOX
#ifdef EMASKING_VIGNETTETEXTURE
texture2D texVignetteMask
<
string ResourceName="enbvignettemask.tga";
>;
sampler2D SamplerVignetteMask = sampler_state
{
Texture = <texVignetteMask>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = Wrap;
AddressV = Wrap;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
#endif //EMASKING_VIGNETTETEXTURE
float ELBVLetterboxImageArea
<
string UIName="LBV: Letterbox image area";
string UIWidget="Spinner";
float UIMin=0.1;//not zero!!!
float UIMax=1.0;
> = {0.75};
float ELBVVignetteImageArea
<
string UIName="LBV: Vignette image area";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=8.0;
> = {1.8};
float ELBVVignetteAmount
<
string UIName="LBV: Vignette amount";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=1.0;
> = {0.6};
float ELBVVignetteCurve
<
string UIName="LBV: Vignette curve";
string UIWidget="Spinner";
float UIMin=0.5;
float UIMax=4.0;
> = {2.0};
float3 ELBVVignetteColor <
string UIName="LBV: Vignette color";
string UIWidget="Color";
> = {0.0, 0.0, 0.0};
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//vignette and letterbox black bars for top/bottom
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
float3 function_Masking(float3 color, float2 coord)
{
float4 tempvar;
#ifdef EMASKING_VIGNETTE
//+++ vignette
float2 uv=coord.xy;
uv=(uv.xy-0.5)*ELBVVignetteImageArea;
#ifdef EMASKING_LETTERBOX
//uv.y/=ELBVLetterboxImageArea;
uv.x*=ELBVLetterboxImageArea;//this looks better and perform faster
#endif
float vignette=saturate(dot(uv.xy, uv.xy));
vignette=pow(vignette, ELBVVignetteCurve);
color=lerp(color, ELBVVignetteColor, vignette*ELBVVignetteAmount);
#endif
#ifdef EMASKING_VIGNETTETEXTURE
float4 mask=tex2D(SamplerVignetteMask, coord);
//color=lerp(color, mask, mask.a);
color*=mask;
#endif
#ifdef EMASKING_LETTERBOX
//+++ letterbox
tempvar.x=abs(coord.y*2.0-1.0)-ELBVLetterboxImageArea;
color=tempvar.x>=0.0 ? 0.0 : color;
#endif
return color;
}
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
-
Offline
- *sensei*
- Posts: 420
- Joined: 10 Jun 2012, 12:31
- Location: Sweden
Re: [REQ] Letterbox vignette in effect.txt
Ok, it's official. I love you!
Seriously thanks! Now I need to port this into my effect.txt.
Your round vignette is way better than the rest of the FXAA/SweetFX versions IMO so I have high hopes for the letterbox.
Cheers!
Seriously thanks! Now I need to port this into my effect.txt.
Your round vignette is way better than the rest of the FXAA/SweetFX versions IMO so I have high hopes for the letterbox.
Cheers!
_________________
| i5 | 8gb RAM | GTX660 | Windows 8 | Skyrim on SSD |
My music project, Akira Project, website at Sound Cloud
| i5 | 8gb RAM | GTX660 | Windows 8 | Skyrim on SSD |
My music project, Akira Project, website at Sound Cloud
-
Offline
- *sensei*
- Posts: 420
- Joined: 10 Jun 2012, 12:31
- Location: Sweden
Re: [REQ] Letterbox vignette in effect.txt
Hmm... effect.txt loads like usual, all the GUI parameters show up, I have made a black texture so the string ResourceName="enbvignettemask.tga"; have something to load.
But nothing show up... :?:
I didn't understood the (color=function_Masking(color, uvsrc.xy); used to compute) thing.
I probably did something wrong but don't know where.
But nothing show up... :?:
I didn't understood the (color=function_Masking(color, uvsrc.xy); used to compute) thing.
I probably did something wrong but don't know where.
Code: Select all
//++++++++++++++++++++++++++++++++++++++++++//
// ENBSeries effect file //
// visit http://enbdev.com for updates //
// Copyright (c) 2007-2013 Boris Vorontsov //
//++++++++++++++++++++++++++++++++++++++++++//
//++CREDITS++++DO NOT REMOVE!!++++++++++++++++++++++++//
// JawZ: assembling and implementing the GUI feature //
// & redesigned file layout. //
// //
// Modified by InsomniaJT //
// Vignette by Boris Vorontsov //
//++++++++++++++++++++++++++++++++++++++++++++++++++++//
//THIS IS HLSL FILE FORMAT FOR EXECUTING ADDITIONAL
//POST PROCESSING EFFECTS. MAKE THE COPY BEFORE CHANGING IT!
//Comment any of these to disable
#define EMASKING_VIGNETTE
//#define EMASKING_VIGNETTETEXTURE
#define EMASKING_LETTERBOX
#ifdef EMASKING_VIGNETTETEXTURE
texture2D texVignetteMask
<
string ResourceName="enbvignettemask.tga";
>;
sampler2D SamplerVignetteMask = sampler_state
{
Texture = <texVignetteMask>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = Wrap;
AddressV = Wrap;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
#endif //EMASKING_VIGNETTETEXTURE
float ELBVLetterboxImageArea
<
string UIName="LBV: Letterbox image area";
string UIWidget="Spinner";
float UIMin=0.1;//not zero!!!
float UIMax=1.0;
> = {0.75};
float ELBVVignetteImageArea
<
string UIName="LBV: Vignette image area";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=8.0;
> = {1.8};
float ELBVVignetteAmount
<
string UIName="LBV: Vignette amount";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=1.0;
> = {0.6};
float ELBVVignetteCurve
<
string UIName="LBV: Vignette curve";
string UIWidget="Spinner";
float UIMin=0.5;
float UIMax=4.0;
> = {2.0};
float3 ELBVVignetteColor <
string UIName="LBV: Vignette color";
string UIWidget="Color";
> = {0.0, 0.0, 0.0};
//+++++++++++++++++++++++++
// End Vignette
//+++++++++++++++++++++++++
//enable sharpening
#define ESHARPENING
//enable color
#define ECOLORSHIFT
bool ESHARPENINGCOLOR <
string UIName = "Enable Sharpening by Color";
> = {true};
bool EDYNAMICNOISE <
string UIName = "Enable Dynamic Noise";
> = {true};
bool ESTATICNOISE <
string UIName = "Enable Static Noise";
> = {false};
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
float BlurSamplingRange <
string UIName="Blur Range";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=3.0;
> = {0.6};
float ShiftSamplingRange <
string UIName="Color Shift Range";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=3.0;
> = {0.25};
float SharpSamplingRange <
string UIName="Sharpening Range";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=1.0;
> = {0.5};
float SharpeningAmount <
string UIName="Sharpening Amount";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=10.0;
> = {1.25};
float DynamicNoiseAmount <
string UIName="Dynamic Noise Amount";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=3.0;
> = {0.125};
float StaticNoiseAmount <
string UIName="Static Noise Amount";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=3.0;
> = {0.125};
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// EXTERNAL PARAMETERS BEGINS HERE, SHOULD NOT BE MODIFIED UNLESS YOU KNOW WHAT YOU ARE DOING!!!
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//keyboard controlled temporary variables (in some versions exists in the config file). Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
float4 tempF1; //0,1,2,3
float4 tempF2; //5,6,7,8
float4 tempF3; //9,0
float4 Timer; //x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
float4 ScreenSize; //x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
//textures
texture2D texColor;
texture2D texDepth;
texture2D texNoise;
sampler2D SamplerColor = sampler_state
{
Texture = <texColor>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;//NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
sampler2D SamplerDepth = sampler_state
{
Texture = <texDepth>;
MinFilter = POINT;
MagFilter = POINT;
MipFilter = NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
sampler2D SamplerNoise = sampler_state
{
Texture = <texNoise>;
MinFilter = POINT;
MagFilter = POINT;
MipFilter = NONE;//NONE;
AddressU = Wrap;
AddressV = Wrap;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
struct VS_OUTPUT_POST
{
float4 vpos : POSITION;
float2 txcoord : TEXCOORD0;
};
struct VS_INPUT_POST
{
float3 pos : POSITION;
float2 txcoord : TEXCOORD0;
};
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
{
VS_OUTPUT_POST OUT;
float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
OUT.vpos=pos;
OUT.txcoord.xy=IN.txcoord.xy;
return OUT;
}
//1 blur
float4 PS_ProcessBlur(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float4 res;
float4 coord=0.0;
coord.xy=IN.txcoord.xy;
float4 origcolor;
coord.w=0.0;
origcolor=tex2Dlod(SamplerColor, coord);
float2 offset[16]=
{
float2(1.0, 1.0),
float2(-1.0, -1.0),
float2(-1.0, 1.0),
float2(1.0, -1.0),
float2(1.0, 0.0),
float2(-1.0, 0.0),
float2(0.0, 1.0),
float2(0.0, -1.0),
float2(1.41, 0.0),
float2(-1.41, 0.0),
float2(0.0, 1.41),
float2(0.0, -1.41),
float2(1.41, 1.41),
float2(-1.41, -1.41),
float2(-1.41, 1.41),
float2(1.41, -1.41)
};
int i=0;
float4 tcol=origcolor;
float2 invscreensize=1.0/ScreenSize.x;
invscreensize.y=invscreensize.y/ScreenSize.z;
//for (i=0; i<8; i++) //higher quality
//for (i=0; i<4; i++)
for (i=0; i<16; i++)
{
float2 tdir=offset[i].xy;
coord.xy=IN.txcoord.xy+tdir.xy*invscreensize*BlurSamplingRange;//*1.0;
float4 ct=tex2Dlod(SamplerColor, coord);
tcol+=ct;
}
//tcol*=0.2; // 1.0/(4+1)
//tcol*=0.111; // 1.0/(8+1) //higher quality
tcol*=0.05882353;
res.xyz=tcol.xyz;
res.w=1.0;
return res;
}
//2 sharp
float4 PS_ProcessSharp(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float4 res;
float4 coord=0.0;
coord.xy=IN.txcoord.xy;
float4 origcolor;
coord.w=0.0;
origcolor=tex2Dlod(SamplerColor, coord);
float2 offset[8]=
{
float2(1.0, 1.0),
float2(-1.0, -1.0),
float2(-1.0, 1.0),
float2(1.0, -1.0),
float2(1.41, 0.0),
float2(-1.41, 0.0),
float2(0.0, 1.41),
float2(0.0, -1.41)
};
int i=0;
float4 tcol=origcolor;
float2 invscreensize=1.0/ScreenSize.x;
invscreensize.y=invscreensize.y/ScreenSize.z;
//for (i=0; i<8; i++) //higher quality
for (i=0; i<4; i++)
{
float2 tdir=offset[i].xy;
coord.xy=IN.txcoord.xy+tdir.xy*invscreensize*SharpSamplingRange;//tempF3;//*1.0;
float4 ct=tex2Dlod(SamplerColor, coord);
tcol+=ct;
}
tcol*=0.2; // 1.0/(4+1)
//tcol*=0.111; // 1.0/(8+1) //higher quality
//sharp
#ifdef ESHARPENING
if (ESHARPENINGCOLOR==true) {
//color
res=origcolor*(1.0+((origcolor-tcol)*SharpeningAmount));
} else {
//non color
float difffact=dot((origcolor.xyz-tcol.xyz), 0.333);
res=origcolor*(1.0+difffact*SharpeningAmount);
}
//less sharpening for bright pixels
float rgray=origcolor.z; //blue fit well
//float rgray=max(origcolor.x, max(origcolor.y, origcolor.z));
rgray=pow(rgray, 3.0);
res=lerp(res, origcolor, saturate(rgray));
#endif
//Dynamic noise
if (EDYNAMICNOISE==true) {
float origgray=max(res.x, res.y);//dot(res.xyz, 0.333);
origgray=max(origgray, res.z);
coord.xy=IN.txcoord.xy*16.0 + frac(Timer.x * 400000.0 + Timer.x);
float4 cnoi=tex2Dlod(SamplerNoise, coord);
res=lerp(res, (cnoi.x+0.5)*res, DynamicNoiseAmount*saturate(1.0-origgray*1.8));
}
//Static noise
if (ESTATICNOISE==true) {
float origgray=max(res.x, res.y);//dot(res.xyz, 0.333);
origgray=max(origgray, res.z);
coord.xy=IN.txcoord.xy*16.0; // + frac(Timer.x * 400000.0 + Timer.x);
float4 cnoi=tex2Dlod(SamplerNoise, coord);
res=lerp(res, (cnoi.x+0.5)*res, StaticNoiseAmount*saturate(1.0-origgray*1.8));
}
res.w=1.0;
return res;
}
//3
float4 PS_ProcessShift(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float4 res;
float4 coord=0.0;
coord.xy=IN.txcoord.xy;
float4 origcolor;
coord.w=0.0;
origcolor=tex2Dlod(SamplerColor, coord);
int i=0;
float4 tcol=origcolor;
float2 invscreensize=1.0/ScreenSize.x;
invscreensize.y=invscreensize.y/ScreenSize.z;
coord.xy=IN.txcoord.xy;
origcolor=tex2Dlod(SamplerColor, coord);
res.y=origcolor.y;
coord.xy=IN.txcoord.xy;
coord.y-=invscreensize*ShiftSamplingRange;
origcolor=tex2Dlod(SamplerColor, coord);
res.x=origcolor.x;
coord.xy=IN.txcoord.xy;
coord.y+=invscreensize*ShiftSamplingRange;
origcolor=tex2Dlod(SamplerColor, coord);
res.z=origcolor.z;
res.w=1.0;
return res;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//vignette and letterbox black bars for top/bottom
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
float3 function_Masking(float3 color, float2 coord)
{
float4 tempvar;
#ifdef EMASKING_VIGNETTE
//+++ vignette
float2 uv=coord.xy;
uv=(uv.xy-0.5)*ELBVVignetteImageArea;
#ifdef EMASKING_LETTERBOX
//uv.y/=ELBVLetterboxImageArea;
uv.x*=ELBVLetterboxImageArea;//this looks better and perform faster
#endif
float vignette=saturate(dot(uv.xy, uv.xy));
vignette=pow(vignette, ELBVVignetteCurve);
color=lerp(color, ELBVVignetteColor, vignette*ELBVVignetteAmount);
#endif
#ifdef EMASKING_VIGNETTETEXTURE
float4 mask=tex2D(SamplerVignetteMask, coord);
//color=lerp(color, mask, mask.a);
color*=mask;
#endif
#ifdef EMASKING_LETTERBOX
//+++ letterbox
tempvar.x=abs(coord.y*2.0-1.0)-ELBVLetterboxImageArea;
color=tempvar.x>=0.0 ? 0.0 : color;
#endif
return color;
}
//first must blur
technique PostProcess
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 PS_ProcessBlur();
DitherEnable=FALSE;
ZEnable=FALSE;
CullMode=NONE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
StencilEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}
//second must sharp
technique PostProcess2
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 PS_ProcessSharp();
DitherEnable=FALSE;
ZEnable=FALSE;
CullMode=NONE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
StencilEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}
#ifdef ECOLORSHIFT
//third must shift
technique PostProcess3
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 PS_ProcessShift();
DitherEnable=FALSE;
ZEnable=FALSE;
CullMode=NONE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
StencilEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}
#endif
_________________
| i5 | 8gb RAM | GTX660 | Windows 8 | Skyrim on SSD |
My music project, Akira Project, website at Sound Cloud
| i5 | 8gb RAM | GTX660 | Windows 8 | Skyrim on SSD |
My music project, Akira Project, website at Sound Cloud
-
Offline
- *blah-blah-blah maniac*
- Posts: 17564
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: [REQ] Letterbox vignette in effect.txt
#define EMASKING_VIGNETTETEXTURE
must be enabled to run texture mask (i wanted to make it animated, but gave up with editing cell-film images to multiple frames).
color=function_Masking(color, uvsrc.xy); - must be used in the last pass, at the end, so no other processing taking place, for example in your current code it's PS_ProcessShift shader if i not missed something, so before this:
insert this:
and move entire function at the top (but after parameters it's using), to make it "visible" to pixel shaders. For example insert it after this:
must be enabled to run texture mask (i wanted to make it animated, but gave up with editing cell-film images to multiple frames).
color=function_Masking(color, uvsrc.xy); - must be used in the last pass, at the end, so no other processing taking place, for example in your current code it's PS_ProcessShift shader if i not missed something, so before this:
Code: Select all
return res;
Code: Select all
res.xyz=function_Masking(res.xyz, uvsrc.xy);
Code: Select all
float3 function_Masking(float3 color, float2 coord)
Code: Select all
struct VS_INPUT_POST
{
float3 pos : POSITION;
float2 txcoord : TEXCOORD0;
};
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
-
Offline
- *sensei*
- Posts: 420
- Joined: 10 Jun 2012, 12:31
- Location: Sweden
Re: [REQ] Letterbox vignette in effect.txt
Thanks for helping me out Boris!
It seems that res.xyz=function_Masking(res.xyz, uvsrc.xy); can't fetch the masking function. Effect.txt won't load. Commenting res.xyz=function_Masking(res.xyz, uvsrc.xy); will make effect.txt to load but no vignette is visible though. Hmm...
I've tried to put the color=function line to other functions as well as moving around the masking function to other places.
Sorry for failing!
It seems that res.xyz=function_Masking(res.xyz, uvsrc.xy); can't fetch the masking function. Effect.txt won't load. Commenting res.xyz=function_Masking(res.xyz, uvsrc.xy); will make effect.txt to load but no vignette is visible though. Hmm...
I've tried to put the color=function line to other functions as well as moving around the masking function to other places.
Sorry for failing!
Code: Select all
//++++++++++++++++++++++++++++++++++++++++++//
// ENBSeries effect file //
// visit http://enbdev.com for updates //
// Copyright (c) 2007-2013 Boris Vorontsov //
//++++++++++++++++++++++++++++++++++++++++++//
//++CREDITS++++DO NOT REMOVE!!++++++++++++++++++++++++//
// JawZ: assembling and implementing the GUI feature //
// & redesigned file layout. //
// //
// Modified by InsomniaJT //
// Vignette by Boris Vorontsov //
//++++++++++++++++++++++++++++++++++++++++++++++++++++//
//THIS IS HLSL FILE FORMAT FOR EXECUTING ADDITIONAL
//POST PROCESSING EFFECTS. MAKE THE COPY BEFORE CHANGING IT!
//Comment any of these to disable
#define EMASKING_VIGNETTE
#define EMASKING_VIGNETTETEXTURE
#define EMASKING_LETTERBOX
#ifdef EMASKING_VIGNETTETEXTURE
texture2D texVignetteMask
<
string ResourceName="enbvignettemask.tga";
>;
sampler2D SamplerVignetteMask = sampler_state
{
Texture = <texVignetteMask>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = Wrap;
AddressV = Wrap;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
#endif //EMASKING_VIGNETTETEXTURE
float ELBVLetterboxImageArea <
string UIName="LBV: Letterbox image area";
string UIWidget="Spinner";
float UIMin=0.1;//not zero!!!
float UIMax=1.0;
> = {0.75};
float ELBVVignetteImageArea <
string UIName="LBV: Vignette image area";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=8.0;
> = {1.8};
float ELBVVignetteAmount <
string UIName="LBV: Vignette amount";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=1.0;
> = {0.6};
float ELBVVignetteCurve <
string UIName="LBV: Vignette curve";
string UIWidget="Spinner";
float UIMin=0.5;
float UIMax=4.0;
> = {2.0};
float3 ELBVVignetteColor <
string UIName="LBV: Vignette color";
string UIWidget="Color";
> = {0.0, 0.0, 0.0};
//+++++++++++++++++++++++++
// End Vignette
//+++++++++++++++++++++++++
//enable sharpening
#define ESHARPENING
//enable color
#define ECOLORSHIFT
bool ESHARPENINGCOLOR <
string UIName = "Enable Sharpening by Color";
> = {true};
bool EDYNAMICNOISE <
string UIName = "Enable Dynamic Noise";
> = {true};
bool ESTATICNOISE <
string UIName = "Enable Static Noise";
> = {false};
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
float BlurSamplingRange <
string UIName="Blur Range";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=3.0;
> = {0.6};
float ShiftSamplingRange <
string UIName="Color Shift Range";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=3.0;
> = {0.25};
float SharpSamplingRange <
string UIName="Sharpening Range";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=1.0;
> = {0.5};
float SharpeningAmount <
string UIName="Sharpening Amount";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=10.0;
> = {1.25};
float DynamicNoiseAmount <
string UIName="Dynamic Noise Amount";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=3.0;
> = {0.125};
float StaticNoiseAmount <
string UIName="Static Noise Amount";
string UIWidget="Spinner";
float UIMin=0.0;
float UIMax=3.0;
> = {0.125};
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// EXTERNAL PARAMETERS BEGINS HERE, SHOULD NOT BE MODIFIED UNLESS YOU KNOW WHAT YOU ARE DOING!!!
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//keyboard controlled temporary variables (in some versions exists in the config file). Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
float4 tempF1; //0,1,2,3
float4 tempF2; //5,6,7,8
float4 tempF3; //9,0
float4 Timer; //x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
float4 ScreenSize; //x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
//textures
texture2D texColor;
texture2D texDepth;
texture2D texNoise;
sampler2D SamplerColor = sampler_state
{
Texture = <texColor>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;//NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
sampler2D SamplerDepth = sampler_state
{
Texture = <texDepth>;
MinFilter = POINT;
MagFilter = POINT;
MipFilter = NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
sampler2D SamplerNoise = sampler_state
{
Texture = <texNoise>;
MinFilter = POINT;
MagFilter = POINT;
MipFilter = NONE;//NONE;
AddressU = Wrap;
AddressV = Wrap;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
struct VS_OUTPUT_POST
{
float4 vpos : POSITION;
float2 txcoord : TEXCOORD0;
};
struct VS_INPUT_POST
{
float3 pos : POSITION;
float2 txcoord : TEXCOORD0;
};
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//vignette and letterbox black bars for top/bottom
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
float3 function_Masking(float3 color, float2 coord)
{
float4 tempvar;
#ifdef EMASKING_VIGNETTE
//+++ vignette
float2 uv=coord.xy;
uv=(uv.xy-0.5)*ELBVVignetteImageArea;
#ifdef EMASKING_LETTERBOX
//uv.y/=ELBVLetterboxImageArea;
uv.x*=ELBVLetterboxImageArea;//this looks better and perform faster
#endif
float vignette=saturate(dot(uv.xy, uv.xy));
vignette=pow(vignette, ELBVVignetteCurve);
color=lerp(color, ELBVVignetteColor, vignette*ELBVVignetteAmount);
#endif
#ifdef EMASKING_VIGNETTETEXTURE
float4 mask=tex2D(SamplerVignetteMask, coord);
//color=lerp(color, mask, mask.a);
color*=mask;
#endif
#ifdef EMASKING_LETTERBOX
//+++ letterbox
tempvar.x=abs(coord.y*2.0-1.0)-ELBVLetterboxImageArea;
color=tempvar.x>=0.0 ? 0.0 : color;
#endif
//color.xyz=function_Masking(color.xyz, uvsrc.xy); //Just for trying
return color;
}
VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
{
VS_OUTPUT_POST OUT;
float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
OUT.vpos=pos;
OUT.txcoord.xy=IN.txcoord.xy;
return OUT;
}
//1 blur
float4 PS_ProcessBlur(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float4 res;
float4 coord=0.0;
coord.xy=IN.txcoord.xy;
float4 origcolor;
coord.w=0.0;
origcolor=tex2Dlod(SamplerColor, coord);
float2 offset[16]=
{
float2(1.0, 1.0),
float2(-1.0, -1.0),
float2(-1.0, 1.0),
float2(1.0, -1.0),
float2(1.0, 0.0),
float2(-1.0, 0.0),
float2(0.0, 1.0),
float2(0.0, -1.0),
float2(1.41, 0.0),
float2(-1.41, 0.0),
float2(0.0, 1.41),
float2(0.0, -1.41),
float2(1.41, 1.41),
float2(-1.41, -1.41),
float2(-1.41, 1.41),
float2(1.41, -1.41)
};
int i=0;
float4 tcol=origcolor;
float2 invscreensize=1.0/ScreenSize.x;
invscreensize.y=invscreensize.y/ScreenSize.z;
//for (i=0; i<8; i++) //higher quality
//for (i=0; i<4; i++)
for (i=0; i<16; i++)
{
float2 tdir=offset[i].xy;
coord.xy=IN.txcoord.xy+tdir.xy*invscreensize*BlurSamplingRange;//*1.0;
float4 ct=tex2Dlod(SamplerColor, coord);
tcol+=ct;
}
//tcol*=0.2; // 1.0/(4+1)
//tcol*=0.111; // 1.0/(8+1) //higher quality
tcol*=0.05882353;
res.xyz=tcol.xyz;
res.w=1.0;
return res;
}
//2 sharp
float4 PS_ProcessSharp(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float4 res;
float4 coord=0.0;
coord.xy=IN.txcoord.xy;
float4 origcolor;
coord.w=0.0;
origcolor=tex2Dlod(SamplerColor, coord);
float2 offset[8]=
{
float2(1.0, 1.0),
float2(-1.0, -1.0),
float2(-1.0, 1.0),
float2(1.0, -1.0),
float2(1.41, 0.0),
float2(-1.41, 0.0),
float2(0.0, 1.41),
float2(0.0, -1.41)
};
int i=0;
float4 tcol=origcolor;
float2 invscreensize=1.0/ScreenSize.x;
invscreensize.y=invscreensize.y/ScreenSize.z;
//for (i=0; i<8; i++) //higher quality
for (i=0; i<4; i++)
{
float2 tdir=offset[i].xy;
coord.xy=IN.txcoord.xy+tdir.xy*invscreensize*SharpSamplingRange;//tempF3;//*1.0;
float4 ct=tex2Dlod(SamplerColor, coord);
tcol+=ct;
}
tcol*=0.2; // 1.0/(4+1)
//tcol*=0.111; // 1.0/(8+1) //higher quality
//sharp
#ifdef ESHARPENING
if (ESHARPENINGCOLOR==true) {
//color
res=origcolor*(1.0+((origcolor-tcol)*SharpeningAmount));
} else {
//non color
float difffact=dot((origcolor.xyz-tcol.xyz), 0.333);
res=origcolor*(1.0+difffact*SharpeningAmount);
}
//less sharpening for bright pixels
float rgray=origcolor.z; //blue fit well
//float rgray=max(origcolor.x, max(origcolor.y, origcolor.z));
rgray=pow(rgray, 3.0);
res=lerp(res, origcolor, saturate(rgray));
#endif
//Dynamic noise
if (EDYNAMICNOISE==true) {
float origgray=max(res.x, res.y);//dot(res.xyz, 0.333);
origgray=max(origgray, res.z);
coord.xy=IN.txcoord.xy*16.0 + frac(Timer.x * 400000.0 + Timer.x);
float4 cnoi=tex2Dlod(SamplerNoise, coord);
res=lerp(res, (cnoi.x+0.5)*res, DynamicNoiseAmount*saturate(1.0-origgray*1.8));
}
//Static noise
if (ESTATICNOISE==true) {
float origgray=max(res.x, res.y);//dot(res.xyz, 0.333);
origgray=max(origgray, res.z);
coord.xy=IN.txcoord.xy*16.0; // + frac(Timer.x * 400000.0 + Timer.x);
float4 cnoi=tex2Dlod(SamplerNoise, coord);
res=lerp(res, (cnoi.x+0.5)*res, StaticNoiseAmount*saturate(1.0-origgray*1.8));
}
res.w=1.0;
return res;
}
//3
float4 PS_ProcessShift(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float4 res;
float4 coord=0.0;
coord.xy=IN.txcoord.xy;
float4 origcolor;
coord.w=0.0;
origcolor=tex2Dlod(SamplerColor, coord);
int i=0;
float4 tcol=origcolor;
float2 invscreensize=1.0/ScreenSize.x;
invscreensize.y=invscreensize.y/ScreenSize.z;
coord.xy=IN.txcoord.xy;
origcolor=tex2Dlod(SamplerColor, coord);
res.y=origcolor.y;
coord.xy=IN.txcoord.xy;
coord.y-=invscreensize*ShiftSamplingRange;
origcolor=tex2Dlod(SamplerColor, coord);
res.x=origcolor.x;
coord.xy=IN.txcoord.xy;
coord.y+=invscreensize*ShiftSamplingRange;
origcolor=tex2Dlod(SamplerColor, coord);
res.z=origcolor.z;
//
res.w=1.0;
//res.xyz=function_Masking(res.xyz, uvsrc.xy);
return res;
}
//first must blur
technique PostProcess
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 PS_ProcessBlur();
DitherEnable=FALSE;
ZEnable=FALSE;
CullMode=NONE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
StencilEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}
//second must sharp
technique PostProcess2
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 PS_ProcessSharp();
DitherEnable=FALSE;
ZEnable=FALSE;
CullMode=NONE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
StencilEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}
#ifdef ECOLORSHIFT
//third must shift
technique PostProcess3
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 PS_ProcessShift();
DitherEnable=FALSE;
ZEnable=FALSE;
CullMode=NONE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
StencilEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}
#endif
_________________
| i5 | 8gb RAM | GTX660 | Windows 8 | Skyrim on SSD |
My music project, Akira Project, website at Sound Cloud
| i5 | 8gb RAM | GTX660 | Windows 8 | Skyrim on SSD |
My music project, Akira Project, website at Sound Cloud