-
-
Save anonymous/e80119b6470b7b4e46afc33f0c075b31 to your computer and use it in GitHub Desktop.
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
#include "ReShade.fxh" | |
uniform float texture_sizeX < | |
ui_type = "drag"; | |
ui_min = 1.0; | |
ui_max = BUFFER_WIDTH; | |
ui_label = "Screen Width [CoolRetroTerm]"; | |
> = 320.0; | |
uniform float texture_sizeY < | |
ui_type = "drag"; | |
ui_min = 1.0; | |
ui_max = BUFFER_HEIGHT; | |
ui_label = "Screen Height [CoolRetroTerm]"; | |
> = 240.0; | |
uniform float staticNoise < | |
ui_type = "drag"; | |
ui_min = 0.0; | |
ui_max = 2.0; | |
ui_step = 0.001; | |
ui_label = "Static Noise [CoolRetroTerm]"; | |
> = 0.1; | |
uniform float screenCurvature < | |
ui_type = "drag"; | |
ui_min = 0.0; | |
ui_max = 1.0; | |
ui_step = 0.001; | |
ui_label = "Screen Curvature [CoolRetroTerm]"; | |
> = 0.1; | |
uniform float jitter < | |
ui_type = "drag"; | |
ui_min = 0.0; | |
ui_max = 1.0; | |
ui_step = 0.001; | |
ui_label = "Jitter [CoolRetroTerm]"; | |
> = 0.18; | |
uniform float horizontalSync < | |
ui_type = "drag"; | |
ui_min = 0.0; | |
ui_max = 1.0; | |
ui_step = 0.01; | |
ui_label = "Horizontal Sync [CoolRetroTerm]"; | |
> = 0.16; | |
texture tNoise <source="allNoise512.png";> { Width=512; Height=512; Format = RGBA16F;}; | |
sampler2D noiseSource | |
{ | |
Texture = tNoise; | |
MinFilter = LINEAR; | |
MagFilter = LINEAR; | |
MipFilter = LINEAR; | |
AddressU = REPEAT; | |
AddressV = REPEAT; | |
}; | |
uniform float time < source = "timer"; >; | |
float4 PS_CoolRetroTerm (float4 pos : SV_Position, float2 uv : TEXCOORD0) : SV_Target | |
{ | |
float2 texcoord = uv; | |
float dispX = ReShade::ScreenSize.x; | |
float dispY = ReShade::ScreenSize.y; | |
float2 scaleNoiseSize = float2((ReShade::ScreenSize.x) / 512, (ReShade::ScreenSize.y) / 512); | |
float2 cc = float2(0.5,0.5) - texcoord; | |
float distance = length(cc); | |
float2 initialCoords = float2(frac(time/(1024.0*2.0)), frac(time/(1024.0*1024.0))); | |
float4 initialNoiseTexel = tex2D(noiseSource, texcoord); | |
initialCoords = float2(frac(time/(1024.0*2.0)), frac(time/(1024.0*1024.0))); | |
initialNoiseTexel = tex2D(ReShade::BackBuffer, initialCoords); | |
float randval = horizontalSync - initialNoiseTexel.r; | |
float distortionScale = max(0.0, randval) * randval * horizontalSync; | |
float distortionFreq = lerp(4.0, 40.0, initialNoiseTexel.g); | |
float noise = staticNoise; | |
float distortion = 0.0; | |
float2 staticCoords = texcoord; | |
float2 hco = float2(ReShade::PixelSize.x, ReShade::PixelSize.y); //hard cuttoff x | |
if (screenCurvature != 0) { | |
distortion = dot(cc, cc) * screenCurvature; | |
staticCoords = (texcoord - cc * (1.0 + distortion) * distortion); | |
} else { | |
staticCoords = texcoord; | |
} | |
float2 coords = staticCoords; | |
float dst = 0; | |
if (horizontalSync !=0){ | |
dst = sin((coords.y + time * 0.001) * distortionFreq); | |
coords.x += dst * distortionScale; | |
if (staticNoise){ | |
noise += distortionScale * 7.0; | |
} | |
} | |
float4 noiseTexel = tex2D(noiseSource, scaleNoiseSize * coords + float2(frac(time / 51.0), frac(time / 237.0))); | |
float2 txt_coords = coords; | |
float2 offset = float2(0.0,0.0); | |
if (jitter != 0) { | |
offset = float2(noiseTexel.b, noiseTexel.a) - float2(0.5,0.5); | |
txt_coords = coords + offset * (jitter*0.007); | |
} else { | |
offset = coords; | |
txt_coords = coords; | |
} | |
float color = 0.0; | |
float noiseVal = noiseTexel.a; | |
float3 txt_color = tex2D(ReShade::BackBuffer, coords).rgb; | |
if (staticNoise != 0){ | |
txt_color += noiseVal * noise * (1.0 - distance * 1.3); | |
} | |
return float4(noiseTexel); | |
} | |
technique CoolRetroTermNoise | |
{ | |
pass CoolRetroTermNoise | |
{ | |
VertexShader = PostProcessVS; | |
PixelShader = PS_CoolRetroTerm; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment