-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#define FXAA_REDUCE_MIN (1.0/256.0) | ||
#define FXAA_REDUCE_MUL (1.0/8.0) | ||
#define FXAA_SPAN_MAX 8.0 | ||
#define FXAA_SUBPIX_SHIFT (1.0/8.0) | ||
|
||
struct input | ||
{ | ||
float2 video_size; | ||
float2 texture_size; | ||
float2 output_size; | ||
float frame_count; | ||
float frame_direction; | ||
float frame_rotation; | ||
}; | ||
|
||
|
||
struct out_vertex { | ||
float4 position : POSITION; | ||
float2 texCoord : TEXCOORD0; | ||
float4 vpos : TEXCOORD1; | ||
}; | ||
|
||
/* FRAGMENT SHADER */ | ||
float4 main(in out_vertex VAR, uniform input IN, uniform sampler2D decal : TEXUNIT0) : COLOR | ||
{ | ||
//yes Cg is THIS retarded, passing position as texturecoord | ||
VAR.vpos /= VAR.vpos.w; | ||
|
||
float2 inverse_resolution=1/IN.video_size.xy; | ||
float4 coords; | ||
coords.xy = VAR.texCoord; | ||
coords.zw = coords.xy - (inverse_resolution.xy * (0.5 + FXAA_SUBPIX_SHIFT)); | ||
float3 rgbNW = tex2D(decal, (VAR.texCoord + float2(-1.0,-1.0)) * inverse_resolution).xyz; | ||
float3 rgbNE = tex2D(decal, (VAR.texCoord + float2(1.0,-1.0)) * inverse_resolution).xyz; | ||
float3 rgbSW = tex2D(decal, (VAR.texCoord + float2(-1.0,1.0)) * inverse_resolution).xyz; | ||
float3 rgbSE = tex2D(decal, (VAR.texCoord + float2(1.0,1.0)) * inverse_resolution).xyz; | ||
float3 rgbM = tex2D(decal, VAR.texCoord ).xyz; | ||
float3 luma = float3(0.299, 0.587, 0.114); | ||
float lumaNW = dot(rgbNW, luma); | ||
float lumaNE = dot(rgbNE, luma); | ||
float lumaSW = dot(rgbSW, luma); | ||
float lumaSE = dot(rgbSE, luma); | ||
float lumaM = dot(rgbM, luma); | ||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); | ||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); | ||
float2 dir; | ||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); | ||
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); | ||
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),FXAA_REDUCE_MIN); | ||
float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); | ||
dir = min(float2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),max(float2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),dir * rcpDirMin)) * inverse_resolution; | ||
|
||
float3 rgbA = 0.5 * (tex2D(decal, VAR.texCoord + dir * (1.0/3.0 - 0.5)).xyz + | ||
tex2D(decal, VAR.texCoord + dir * (2.0/3.0 - 0.5)).xyz); | ||
float3 rgbB = rgbA * 0.5 + 0.25 * (tex2D(decal, VAR.texCoord * inverse_resolution + dir * - 0.5).xyz + tex2D(decal, VAR.texCoord + dir * 0.5).xyz); | ||
float lumaB = dot(rgbB, luma); | ||
if((lumaB < lumaMin) || (lumaB > lumaMax)) { | ||
return float4(rgbA,1.0); | ||
} else { | ||
return float4(rgbB,1.0); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
struct input | ||
{ | ||
float2 video_size; | ||
float2 texture_size; | ||
float2 output_size; | ||
float frame_count; | ||
float frame_direction; | ||
float frame_rotation; | ||
}; | ||
|
||
|
||
struct out_vertex { | ||
float4 position : POSITION; | ||
float2 texCoord : TEXCOORD0; | ||
float4 vpos : TEXCOORD1; | ||
}; | ||
|
||
/* VERTEX_SHADER */ | ||
void main | ||
( | ||
float4 aPosition, | ||
float2 aTexcoord, | ||
uniform input IN, | ||
uniform float4x4 wvp, | ||
out out_vertex OUT | ||
) | ||
{ | ||
OUT.position = mul(aPosition, wvp); | ||
|
||
OUT.texCoord = aTexcoord; | ||
OUT.vpos = OUT.position; | ||
|
||
} |