2015-05-24 05:53:26 -07:00
|
|
|
// license:BSD-3-Clause
|
2015-05-12 00:18:09 -07:00
|
|
|
// copyright-holders:Ryan Holtz,ImJezze
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
2011-05-17 17:35:16 -07:00
|
|
|
// Scanline & Shadowmask Effect
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-12-31 07:32:35 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Sampler Definitions
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2013-08-29 18:05:13 -07:00
|
|
|
texture DiffuseTexture;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
|
|
|
|
sampler DiffuseSampler = sampler_state
|
|
|
|
{
|
2015-05-03 05:41:05 -07:00
|
|
|
Texture = <DiffuseTexture>;
|
2014-01-23 16:30:29 -08:00
|
|
|
MipFilter = LINEAR;
|
|
|
|
MinFilter = LINEAR;
|
|
|
|
MagFilter = LINEAR;
|
|
|
|
AddressU = CLAMP;
|
|
|
|
AddressV = CLAMP;
|
|
|
|
AddressW = CLAMP;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
};
|
|
|
|
|
2013-08-29 18:05:13 -07:00
|
|
|
texture ShadowTexture;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
|
|
|
|
sampler ShadowSampler = sampler_state
|
|
|
|
{
|
2015-05-03 05:41:05 -07:00
|
|
|
Texture = <ShadowTexture>;
|
2014-01-23 16:30:29 -08:00
|
|
|
MipFilter = LINEAR;
|
|
|
|
MinFilter = LINEAR;
|
|
|
|
MagFilter = LINEAR;
|
|
|
|
AddressU = WRAP;
|
|
|
|
AddressV = WRAP;
|
|
|
|
AddressW = WRAP;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Vertex Definitions
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-05-03 05:41:05 -07:00
|
|
|
struct VS_INPUT
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
{
|
2014-01-23 16:30:29 -08:00
|
|
|
float4 Position : POSITION;
|
|
|
|
float4 Color : COLOR0;
|
|
|
|
float2 TexCoord : TEXCOORD0;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
};
|
|
|
|
|
2015-05-03 05:41:05 -07:00
|
|
|
struct VS_OUTPUT
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
{
|
2014-01-23 16:30:29 -08:00
|
|
|
float4 Position : POSITION;
|
|
|
|
float4 Color : COLOR0;
|
2016-10-22 13:39:14 -07:00
|
|
|
float2 TexCoord : TEXCOORD0;
|
|
|
|
float2 ScreenCoord : TEXCOORD1;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PS_INPUT
|
|
|
|
{
|
2014-01-23 16:30:29 -08:00
|
|
|
float4 Color : COLOR0;
|
2016-10-22 13:39:14 -07:00
|
|
|
float2 TexCoord : TEXCOORD0;
|
|
|
|
float2 ScreenCoord : TEXCOORD1;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
};
|
|
|
|
|
2015-10-18 10:16:46 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Constants
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static const float PI = 3.1415927f;
|
2016-06-19 13:23:02 -07:00
|
|
|
static const float HalfPI = PI * 0.5f;
|
2015-10-18 10:16:46 -07:00
|
|
|
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
2011-05-17 17:35:16 -07:00
|
|
|
// Scanline & Shadowmask Vertex Shader
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-03-12 07:03:28 -08:00
|
|
|
uniform float2 ScreenDims;
|
|
|
|
uniform float2 SourceDims;
|
|
|
|
uniform float2 TargetDims;
|
2016-09-28 06:22:38 -07:00
|
|
|
uniform float2 TargetScale;
|
2016-03-12 07:03:28 -08:00
|
|
|
uniform float2 QuadDims;
|
2015-07-19 03:28:51 -07:00
|
|
|
|
2015-05-03 05:41:05 -07:00
|
|
|
uniform float2 ShadowDims = float2(32.0f, 32.0f); // size of the shadow texture (extended to power-of-two size)
|
|
|
|
uniform float2 ShadowUVOffset = float2(0.0f, 0.0f);
|
|
|
|
|
2015-12-31 07:59:23 -08:00
|
|
|
uniform bool SwapXY = false;
|
2015-07-12 14:28:38 -07:00
|
|
|
|
2015-09-26 09:22:51 -07:00
|
|
|
uniform bool PrepareBloom = false; // disables some effects for rendering bloom textures
|
2016-02-20 12:58:56 -08:00
|
|
|
uniform bool VectorScreen = false;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
|
|
|
|
VS_OUTPUT vs_main(VS_INPUT Input)
|
|
|
|
{
|
2014-01-23 16:30:29 -08:00
|
|
|
VS_OUTPUT Output = (VS_OUTPUT)0;
|
2015-05-03 05:41:05 -07:00
|
|
|
|
2015-08-02 08:31:54 -07:00
|
|
|
Output.Position = float4(Input.Position.xyz, 1.0f);
|
2014-01-23 16:30:29 -08:00
|
|
|
Output.Position.xy /= ScreenDims;
|
2015-05-03 05:41:05 -07:00
|
|
|
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
|
|
|
Output.Position.xy -= 0.5f; // center
|
|
|
|
Output.Position.xy *= 2.0f; // zoom
|
|
|
|
|
2016-03-12 07:03:28 -08:00
|
|
|
Output.TexCoord = Input.TexCoord;
|
2016-02-25 11:58:49 -08:00
|
|
|
Output.TexCoord += PrepareBloom
|
2016-06-06 10:40:10 -07:00
|
|
|
? 0.0f // use half texel offset (DX9) to do the blur for first bloom layer
|
2016-04-22 04:16:37 -07:00
|
|
|
: 0.5f / TargetDims; // fix half texel offset (DX9)
|
2016-02-20 12:58:56 -08:00
|
|
|
|
|
|
|
Output.ScreenCoord = Input.Position.xy / ScreenDims;
|
|
|
|
|
2014-01-23 16:30:29 -08:00
|
|
|
Output.Color = Input.Color;
|
|
|
|
|
|
|
|
return Output;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2015-12-31 07:32:35 -08:00
|
|
|
// Scanline & Shadowmask Pixel Shader
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-02-07 04:32:34 -08:00
|
|
|
uniform float HumBarDesync = 60.0f / 59.94f - 1.0f; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
|
2016-01-25 13:02:24 -08:00
|
|
|
uniform float HumBarAlpha = 0.0f;
|
|
|
|
|
|
|
|
uniform float TimeMilliseconds = 0.0f;
|
|
|
|
|
2015-11-17 10:37:56 -08:00
|
|
|
uniform float2 ScreenScale = float2(1.0f, 1.0f);
|
|
|
|
uniform float2 ScreenOffset = float2(0.0f, 0.0f);
|
|
|
|
|
2015-12-25 11:02:47 -08:00
|
|
|
uniform float ScanlineAlpha = 0.0f;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
uniform float ScanlineScale = 1.0f;
|
2016-03-15 14:15:25 -07:00
|
|
|
uniform float ScanlineHeight = 1.0f;
|
|
|
|
uniform float ScanlineVariation = 1.0f;
|
|
|
|
uniform float ScanlineOffset = 1.0f;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
uniform float ScanlineBrightScale = 1.0f;
|
|
|
|
uniform float ScanlineBrightOffset = 1.0f;
|
2015-05-03 05:41:05 -07:00
|
|
|
|
2015-12-25 11:02:47 -08:00
|
|
|
uniform float3 BackColor = float3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
2016-03-12 10:17:57 -08:00
|
|
|
uniform int ShadowTileMode = 0; // 0 based on screen (quad) dimension, 1 based on source dimension
|
2013-08-29 18:05:13 -07:00
|
|
|
uniform float ShadowAlpha = 0.0f;
|
2015-05-03 05:41:05 -07:00
|
|
|
uniform float2 ShadowCount = float2(6.0f, 6.0f);
|
|
|
|
uniform float2 ShadowUV = float2(0.25f, 0.25f);
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
|
2011-06-11 16:46:24 -07:00
|
|
|
uniform float3 Power = float3(1.0f, 1.0f, 1.0f);
|
|
|
|
uniform float3 Floor = float3(0.0f, 0.0f, 0.0f);
|
2011-06-06 14:25:38 -07:00
|
|
|
|
2016-04-22 04:16:37 -07:00
|
|
|
float2 GetAdjustedCoords(float2 coord)
|
2015-11-17 10:37:56 -08:00
|
|
|
{
|
|
|
|
// center coordinates
|
2016-04-22 04:16:37 -07:00
|
|
|
coord -= 0.5f;
|
2015-11-17 10:37:56 -08:00
|
|
|
|
|
|
|
// apply screen scale
|
2016-04-20 22:52:29 -07:00
|
|
|
coord *= ScreenScale;
|
2015-11-17 10:37:56 -08:00
|
|
|
|
|
|
|
// un-center coordinates
|
2016-04-22 04:16:37 -07:00
|
|
|
coord += 0.5f;
|
2015-11-17 10:37:56 -08:00
|
|
|
|
|
|
|
// apply screen offset
|
2016-04-22 04:16:37 -07:00
|
|
|
coord += ScreenOffset;
|
2015-11-17 10:37:56 -08:00
|
|
|
|
|
|
|
return coord;
|
|
|
|
}
|
|
|
|
|
2016-09-28 06:22:38 -07:00
|
|
|
float2 GetShadowCoord(float2 TargetCoord, float2 SourceCoord)
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
{
|
2016-09-28 06:22:38 -07:00
|
|
|
// base-target dimensions (without oversampling)
|
|
|
|
float2 BaseTargetDims = TargetDims / TargetScale;
|
|
|
|
BaseTargetDims = SwapXY
|
|
|
|
? BaseTargetDims.yx
|
|
|
|
: BaseTargetDims.xy;
|
2016-03-12 07:03:28 -08:00
|
|
|
|
|
|
|
float2 canvasCoord = ShadowTileMode == 0
|
2016-09-28 06:22:38 -07:00
|
|
|
? TargetCoord + ShadowUVOffset / BaseTargetDims
|
2016-03-12 07:03:28 -08:00
|
|
|
: SourceCoord + ShadowUVOffset / SourceDims;
|
|
|
|
float2 canvasTexelDims = ShadowTileMode == 0
|
2016-09-28 06:22:38 -07:00
|
|
|
? 1.0f / BaseTargetDims
|
|
|
|
: 1.0f / SourceDims;
|
2016-03-12 07:03:28 -08:00
|
|
|
|
|
|
|
float2 shadowDims = ShadowDims;
|
|
|
|
float2 shadowUV = ShadowUV;
|
|
|
|
float2 shadowCount = ShadowCount;
|
|
|
|
|
2016-04-13 10:21:57 -07:00
|
|
|
// swap x/y in screen mode (not source mode)
|
2016-03-12 10:17:57 -08:00
|
|
|
canvasCoord = ShadowTileMode == 0 && SwapXY
|
2016-03-12 07:03:28 -08:00
|
|
|
? canvasCoord.yx
|
|
|
|
: canvasCoord.xy;
|
2015-11-17 10:37:56 -08:00
|
|
|
|
2016-04-13 10:21:57 -07:00
|
|
|
// swap x/y in screen mode (not source mode)
|
2016-03-12 10:17:57 -08:00
|
|
|
shadowCount = ShadowTileMode == 0 && SwapXY
|
2016-03-12 07:03:28 -08:00
|
|
|
? shadowCount.yx
|
|
|
|
: shadowCount.xy;
|
|
|
|
|
|
|
|
float2 shadowTile = canvasTexelDims * shadowCount;
|
|
|
|
|
|
|
|
float2 shadowFrac = frac(canvasCoord / shadowTile);
|
2016-03-12 10:17:57 -08:00
|
|
|
|
2016-04-13 10:21:57 -07:00
|
|
|
// swap x/y in screen mode (not source mode)
|
|
|
|
shadowFrac = ShadowTileMode == 0 && SwapXY
|
2016-03-12 07:03:28 -08:00
|
|
|
? shadowFrac.yx
|
|
|
|
: shadowFrac.xy;
|
|
|
|
|
|
|
|
float2 shadowCoord = (shadowFrac * shadowUV);
|
2016-05-05 13:46:56 -07:00
|
|
|
shadowCoord += ShadowTileMode == 0
|
|
|
|
? 0.5f / shadowDims // fix half texel offset (DX9)
|
|
|
|
: 0.0f;
|
2016-03-12 07:03:28 -08:00
|
|
|
|
|
|
|
return shadowCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 ps_main(PS_INPUT Input) : COLOR
|
|
|
|
{
|
2016-02-20 12:58:56 -08:00
|
|
|
float2 ScreenCoord = Input.ScreenCoord;
|
2016-09-28 06:22:38 -07:00
|
|
|
float2 BaseCoord = GetAdjustedCoords(Input.TexCoord);
|
2015-05-03 05:41:05 -07:00
|
|
|
|
2015-09-26 09:22:51 -07:00
|
|
|
// Color
|
2016-09-28 06:22:38 -07:00
|
|
|
float4 BaseColor = tex2D(DiffuseSampler, BaseCoord);
|
2015-05-03 05:41:05 -07:00
|
|
|
BaseColor.a = 1.0f;
|
|
|
|
|
2016-04-13 10:21:57 -07:00
|
|
|
// clip border
|
2016-10-22 13:39:14 -07:00
|
|
|
if (BaseCoord.x < 0.0f || BaseCoord.y < 0.0f ||
|
|
|
|
BaseCoord.x > 1.0f || BaseCoord.y > 1.0f)
|
|
|
|
{
|
|
|
|
// we don't use the clip function, because we don't clear the render target before
|
|
|
|
return float4(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
}
|
2015-11-17 10:37:56 -08:00
|
|
|
|
2015-05-03 05:41:05 -07:00
|
|
|
// Mask Simulation (may not affect bloom)
|
2016-01-25 13:02:24 -08:00
|
|
|
if (!PrepareBloom && ShadowAlpha > 0.0f)
|
2015-05-03 05:41:05 -07:00
|
|
|
{
|
2016-10-22 13:39:14 -07:00
|
|
|
float2 ShadowCoord = GetShadowCoord(ScreenCoord, BaseCoord);
|
2015-05-09 02:40:23 -07:00
|
|
|
|
2015-12-25 11:02:47 -08:00
|
|
|
float4 ShadowColor = tex2D(ShadowSampler, ShadowCoord);
|
|
|
|
float3 ShadowMaskColor = lerp(1.0f, ShadowColor.rgb, ShadowAlpha);
|
|
|
|
float ShadowMaskClear = (1.0f - ShadowColor.a) * ShadowAlpha;
|
2015-05-03 05:41:05 -07:00
|
|
|
|
2015-12-25 11:02:47 -08:00
|
|
|
// apply shadow mask color
|
|
|
|
BaseColor.rgb *= ShadowMaskColor;
|
|
|
|
// clear shadow mask by background color
|
|
|
|
BaseColor.rgb = lerp(BaseColor.rgb, BackColor, ShadowMaskClear);
|
2015-05-03 05:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Color Compression (may not affect bloom)
|
|
|
|
if (!PrepareBloom)
|
|
|
|
{
|
|
|
|
// increasing the floor of the signal without affecting the ceiling
|
|
|
|
BaseColor.rgb = Floor + (1.0f - Floor) * BaseColor.rgb;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Color Power (may affect bloom)
|
|
|
|
BaseColor.r = pow(BaseColor.r, Power.r);
|
|
|
|
BaseColor.g = pow(BaseColor.g, Power.g);
|
|
|
|
BaseColor.b = pow(BaseColor.b, Power.b);
|
|
|
|
|
|
|
|
// Scanline Simulation (may not affect bloom)
|
|
|
|
if (!PrepareBloom)
|
|
|
|
{
|
2015-12-24 05:06:01 -08:00
|
|
|
// Scanline Simulation (may not affect vector screen)
|
2016-02-20 12:58:56 -08:00
|
|
|
if (!VectorScreen && ScanlineAlpha > 0.0f)
|
2015-09-26 09:22:51 -07:00
|
|
|
{
|
2016-02-07 04:32:34 -08:00
|
|
|
float BrightnessOffset = (ScanlineBrightOffset * ScanlineAlpha);
|
|
|
|
float BrightnessScale = (ScanlineBrightScale * ScanlineAlpha) + (1.0f - ScanlineAlpha);
|
2015-09-26 09:22:51 -07:00
|
|
|
|
2016-02-07 04:32:34 -08:00
|
|
|
float ColorBrightness = 0.299f * BaseColor.r + 0.587f * BaseColor.g + 0.114 * BaseColor.b;
|
|
|
|
|
2016-10-22 13:39:14 -07:00
|
|
|
float ScanlineCoord = BaseCoord.y;
|
2016-08-13 11:30:40 -07:00
|
|
|
ScanlineCoord += SwapXY
|
|
|
|
? QuadDims.x <= SourceDims.x * 2.0f
|
|
|
|
? 0.5f / QuadDims.x // uncenter scanlines if the quad is less than twice the size of the source
|
|
|
|
: 0.0f
|
|
|
|
: QuadDims.y <= SourceDims.y * 2.0f
|
|
|
|
? 0.5f / QuadDims.y // uncenter scanlines if the quad is less than twice the size of the source
|
|
|
|
: 0.0f;
|
2016-06-06 10:40:10 -07:00
|
|
|
|
|
|
|
ScanlineCoord *= SourceDims.y * ScanlineScale * PI;
|
|
|
|
|
2016-06-19 13:23:02 -07:00
|
|
|
float ScanlineCoordJitter = ScanlineOffset * HalfPI;
|
2016-02-07 04:32:34 -08:00
|
|
|
float ScanlineSine = sin(ScanlineCoord + ScanlineCoordJitter);
|
2016-03-15 14:15:25 -07:00
|
|
|
float ScanlineWide = ScanlineHeight + ScanlineVariation * max(1.0f, ScanlineHeight) * (1.0f - ColorBrightness);
|
2016-02-07 04:32:34 -08:00
|
|
|
float ScanlineAmount = pow(ScanlineSine * ScanlineSine, ScanlineWide);
|
|
|
|
float ScanlineBrightness = ScanlineAmount * BrightnessScale + BrightnessOffset * BrightnessScale;
|
|
|
|
|
|
|
|
BaseColor.rgb *= lerp(1.0f, ScanlineBrightness, ScanlineAlpha);
|
2016-01-25 13:02:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hum Bar Simulation (may not affect vector screen)
|
2016-02-20 12:58:56 -08:00
|
|
|
if (!VectorScreen && HumBarAlpha > 0.0f)
|
2016-01-25 13:02:24 -08:00
|
|
|
{
|
2016-02-07 04:32:34 -08:00
|
|
|
float HumBarStep = frac(TimeMilliseconds * HumBarDesync);
|
2016-10-22 13:39:14 -07:00
|
|
|
float HumBarBrightness = 1.0 - frac(BaseCoord.y + HumBarStep) * HumBarAlpha;
|
2016-02-07 04:32:34 -08:00
|
|
|
BaseColor.rgb *= HumBarBrightness;
|
2015-09-26 09:22:51 -07:00
|
|
|
}
|
2015-05-03 05:41:05 -07:00
|
|
|
}
|
|
|
|
|
2016-02-20 12:58:56 -08:00
|
|
|
return BaseColor;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2015-12-31 07:32:35 -08:00
|
|
|
// Scanline & Shadowmask Technique
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-12-31 07:32:35 -08:00
|
|
|
technique DefaultTechnique
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
{
|
2014-01-23 16:30:29 -08:00
|
|
|
pass Pass0
|
|
|
|
{
|
|
|
|
Lighting = FALSE;
|
Initial shader import (nw)
Focus: 8-sample blur that averages 7 samples around a center sample.
Phosphor: Not currently used, treated as a pass-through by drawd3d.c, but could be used to implement additional convolutions in a second pass.
Pincushion: Used (when commented in in drawd3d.c) to pincushion an entire full-screen texture but not otherwise apply any convolutions.
Post: The meat and potatoes. It does scanlines, it does aperture masking, it does dot crawl, it does chroma subsampling, it does YIQ colorspace convolution, it does RGB colorspace convolution, it does pincushioning, it walks, it talks, it does the dishes, it'll screw your wife for you, and if you don't have a wife it will find one for you, get you married to her, and screw her for you, IT IS THAT GOOD, LADIES AND GENTLEMEN.
Primary: Simple passthrough for UI and artwork.
2011-05-16 09:55:34 -07:00
|
|
|
|
2014-01-23 16:30:29 -08:00
|
|
|
VertexShader = compile vs_3_0 vs_main();
|
2015-05-03 05:41:05 -07:00
|
|
|
PixelShader = compile ps_3_0 ps_main();
|
2014-01-23 16:30:29 -08:00
|
|
|
}
|
2016-10-22 13:39:14 -07:00
|
|
|
}
|