Skip to content

Commit

Permalink
Revert "New phosphor persistence shaders for HLSL"
Browse files Browse the repository at this point in the history
  • Loading branch information
rb6502 committed Jan 5, 2017
1 parent ff28f11 commit 311a56b
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 375 deletions.
159 changes: 0 additions & 159 deletions hlsl/ghosting.fx

This file was deleted.

52 changes: 11 additions & 41 deletions hlsl/phosphor.fx
@@ -1,5 +1,5 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Ryan Holtz, Westley M. Martinez // copyright-holders:Ryan Holtz
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Phosphor Effect // Phosphor Effect
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Expand All @@ -13,7 +13,6 @@ texture Diffuse;
sampler DiffuseSampler = sampler_state sampler DiffuseSampler = sampler_state
{ {
Texture = <Diffuse>; Texture = <Diffuse>;
SRGBTexture = TRUE;
MipFilter = LINEAR; MipFilter = LINEAR;
MinFilter = LINEAR; MinFilter = LINEAR;
MagFilter = LINEAR; MagFilter = LINEAR;
Expand All @@ -27,7 +26,6 @@ texture LastPass;
sampler PreviousSampler = sampler_state sampler PreviousSampler = sampler_state
{ {
Texture = <LastPass>; Texture = <LastPass>;
SRGBTexture = TRUE;
MipFilter = LINEAR; MipFilter = LINEAR;
MinFilter = LINEAR; MinFilter = LINEAR;
MagFilter = LINEAR; MagFilter = LINEAR;
Expand Down Expand Up @@ -95,51 +93,24 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Phosphor Pixel Shader // Phosphor Pixel Shader
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------


uniform int Mode = 0; uniform float3 Phosphor = float3(0.0f, 0.0f, 0.0f);
uniform float DeltaTime = 0.0f; uniform float DeltaTime = 0.0f;
uniform float3 TimeConstant = { 0.0f, 0.0f, 0.0f }; static const float F = 30.0f;
uniform float3 Beta = { 0.0f, 0.0f, 0.0f };
static const float TAU_FACTOR = 0.4342944819;
static const float GAMMA_INV_FACTOR = TAU_FACTOR / 100;


float4 ps_main(PS_INPUT Input) : COLOR float4 ps_main(PS_INPUT Input) : COLOR
{ {
float4 CurrPix = tex2D(DiffuseSampler, Input.TexCoord); float4 CurrPix = tex2D(DiffuseSampler, Input.TexCoord);
float3 PrevPix = tex2D(PreviousSampler, Input.PrevCoord).rgb; float3 PrevPix = tex2D(PreviousSampler, Input.PrevCoord).rgb;
float r = PrevPix.r;
float g = PrevPix.g;
float b = PrevPix.b;

if (Mode == 0) {
r = 0;
g = 0;
b = 0;
}
else if (Mode == 1) {
float3 tau = TimeConstant * TAU_FACTOR;


r *= tau.r == 0 ? 0 : exp(-DeltaTime / tau.r); PrevPix.r *= Phosphor.r == 0 ? 0 : pow(Phosphor.r, F * DeltaTime);
g *= tau.g == 0 ? 0 : exp(-DeltaTime / tau.g); PrevPix.g *= Phosphor.g == 0 ? 0 : pow(Phosphor.g, F * DeltaTime);
b *= tau.b == 0 ? 0 : exp(-DeltaTime / tau.b); PrevPix.b *= Phosphor.b == 0 ? 0 : pow(Phosphor.b, F * DeltaTime);
} float RedMax = max(CurrPix.r, PrevPix.r);
else { float GreenMax = max(CurrPix.g, PrevPix.g);
float3 gamma = 1 / (TimeConstant * GAMMA_INV_FACTOR); float BlueMax = max(CurrPix.b, PrevPix.b);

if (r != 0.0f)
r = pow(gamma.r * DeltaTime + pow(1 / r, 1 / Beta.r),
-Beta.r);
if (g != 0.0f)
g = pow(gamma.g * DeltaTime + pow(1 / g, 1 / Beta.g),
-Beta.g);
if (b != 0.0f)
b = pow(gamma.b * DeltaTime + pow(1 / b, 1 / Beta.b),
-Beta.b);
}


r = max(CurrPix.r, r); return Passthrough ?
g = max(CurrPix.g, g); CurrPix : float4(RedMax, GreenMax, BlueMax, CurrPix.a);
b = max(CurrPix.b, b);
return Passthrough ? CurrPix : float4(r, g, b, CurrPix.a);
} }


//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Expand All @@ -150,7 +121,6 @@ technique DefaultTechnique
{ {
pass Pass0 pass Pass0
{ {
SRGBWriteEnable = TRUE;
Lighting = FALSE; Lighting = FALSE;


VertexShader = compile vs_2_0 vs_main(); VertexShader = compile vs_2_0 vs_main();
Expand Down
3 changes: 1 addition & 2 deletions ini/presets/gameboy.ini
Expand Up @@ -31,8 +31,7 @@ offset 0.0,0.10,0.05
scale 0.9,0.8,1.0 scale 0.9,0.8,1.0
power 1.4,1.2,1.8 power 1.4,1.2,1.8
floor 0.0,0.0,0.0 floor 0.0,0.0,0.0
lcd_rise_time 0.25,0.25,0.25 phosphor_life 0.65,0.65,0.65
lcd_fall_time 0.1,0.1,0.1


# #
# NTSC POST-PROCESSING OPTIONS # NTSC POST-PROCESSING OPTIONS
Expand Down
3 changes: 1 addition & 2 deletions ini/presets/gba.ini
Expand Up @@ -31,8 +31,7 @@ offset 0.0,0.0,0.0
scale 1.0,1.0,1.0 scale 1.0,1.0,1.0
power 1.0,1.0,1.0 power 1.0,1.0,1.0
floor 0.0,0.0,0.0 floor 0.0,0.0,0.0
lcd_rise_time 0.05,0.05,0.05 phosphor_life 0.5,0.5,0.5
lcd_fall_time 0.1,0.1,0.1


# #
# NTSC POST-PROCESSING OPTIONS # NTSC POST-PROCESSING OPTIONS
Expand Down
3 changes: 1 addition & 2 deletions ini/presets/lcd-matrix.ini
Expand Up @@ -31,8 +31,7 @@ offset 0.0,0.0,0.0
scale 1.0,1.0,1.0 scale 1.0,1.0,1.0
power 1.0,1.0,1.0 power 1.0,1.0,1.0
floor 0.0,0.0,0.0 floor 0.0,0.0,0.0
lcd_rise_time 0.25,0.25,0.25 phosphor_life 0.5,0.5,0.5
lcd_fall_time 0.1,0.1,0.1


# #
# NTSC POST-PROCESSING OPTIONS # NTSC POST-PROCESSING OPTIONS
Expand Down
3 changes: 1 addition & 2 deletions ini/presets/lcd.ini
Expand Up @@ -31,8 +31,7 @@ offset 0.0,0.0,0.0
scale 1.0,1.0,1.0 scale 1.0,1.0,1.0
power 1.0,1.0,1.0 power 1.0,1.0,1.0
floor 0.0,0.0,0.0 floor 0.0,0.0,0.0
lcd_rise_time 0.05,0.05,0.05 phosphor_life 0.5,0.5,0.5
lcd_fall_time 0.1,0.1,0.1


# #
# NTSC POST-PROCESSING OPTIONS # NTSC POST-PROCESSING OPTIONS
Expand Down
4 changes: 1 addition & 3 deletions ini/presets/raster.ini
Expand Up @@ -37,9 +37,7 @@ offset -0.30,-0.20,-0.05
scale 1.15,1.05,0.90 scale 1.15,1.05,0.90
power 0.90,0.90,1.15 power 0.90,0.90,1.15
floor 0.025,0.025,0.025 floor 0.025,0.025,0.025
phosphor_mode 2 phosphor_life 0.25,0.25,0.25
phosphor_time 0.005,0.050,0.050
phosphor_beta 1.0,1.0,1.0


# #
# NTSC POST-PROCESSING OPTIONS # NTSC POST-PROCESSING OPTIONS
Expand Down
4 changes: 1 addition & 3 deletions ini/presets/vector-mono.ini
Expand Up @@ -37,9 +37,7 @@ offset 0.0,0.0,0.0
scale 1.0,1.0,1.0 scale 1.0,1.0,1.0
power 1.0,1.0,1.0 power 1.0,1.0,1.0
floor 0.0,0.0,0.0 floor 0.0,0.0,0.0
phosphor_mode 2 phosphor_life 0.5,0.5,0.5
phosphor_time 0.01,0.01,0.01
phosphor_beta 1.0,1.0,1.0


# #
# NTSC POST-PROCESSING OPTIONS # NTSC POST-PROCESSING OPTIONS
Expand Down
4 changes: 1 addition & 3 deletions ini/presets/vector.ini
Expand Up @@ -40,9 +40,7 @@ offset 0.0,0.0,0.0
scale 1.0,1.0,1.0 scale 1.0,1.0,1.0
power 1.0,1.0,1.0 power 1.0,1.0,1.0
floor 0.0,0.0,0.0 floor 0.0,0.0,0.0
phosphor_mode 2 phosphor_life 0.5,0.5,0.5
phosphor_time 0.005,0.050,0.050
phosphor_beta 1.0,1.0,1.0


# #
# NTSC POST-PROCESSING OPTIONS # NTSC POST-PROCESSING OPTIONS
Expand Down
14 changes: 6 additions & 8 deletions src/osd/modules/render/d3d/d3dcomm.h
Expand Up @@ -220,7 +220,7 @@ class d3d_render_target
{ {
public: public:
// construction/destruction // construction/destruction
d3d_render_target(): target_width(0), target_height(0), width(0), height(0), screen_index(0), bloom_count(0), cache_index(0) d3d_render_target(): target_width(0), target_height(0), width(0), height(0), screen_index(0), bloom_count(0)
{ {
for (int index = 0; index < MAX_BLOOM_COUNT; index++) for (int index = 0; index < MAX_BLOOM_COUNT; index++)
{ {
Expand All @@ -234,16 +234,16 @@ class d3d_render_target
source_surface[index] = nullptr; source_surface[index] = nullptr;
target_texture[index] = nullptr; target_texture[index] = nullptr;
target_surface[index] = nullptr; target_surface[index] = nullptr;
cache_texture[index] = nullptr;
cache_surface[index] = nullptr;
} }

cache_texture = nullptr;
cache_surface = nullptr;
} }


~d3d_render_target(); ~d3d_render_target();


bool init(renderer_d3d9 *d3d, int source_width, int source_height, int target_width, int target_height, int screen_index); bool init(renderer_d3d9 *d3d, int source_width, int source_height, int target_width, int target_height, int screen_index);
int next_index(int index) { return ++index > 1 ? 0 : index; } int next_index(int index) { return ++index > 1 ? 0 : index; }
int next_cache_index() { cache_index = ++cache_index > 1 ? 0 : cache_index; return cache_index; }


// real target dimension // real target dimension
int target_width; int target_width;
Expand All @@ -260,17 +260,15 @@ class d3d_render_target
IDirect3DSurface9 *source_surface[2]; IDirect3DSurface9 *source_surface[2];
IDirect3DTexture9 *source_texture[2]; IDirect3DTexture9 *source_texture[2];


IDirect3DSurface9 *cache_surface[2]; IDirect3DSurface9 *cache_surface;
IDirect3DTexture9 *cache_texture[2]; IDirect3DTexture9 *cache_texture;


IDirect3DSurface9 *bloom_surface[MAX_BLOOM_COUNT]; IDirect3DSurface9 *bloom_surface[MAX_BLOOM_COUNT];
IDirect3DTexture9 *bloom_texture[MAX_BLOOM_COUNT]; IDirect3DTexture9 *bloom_texture[MAX_BLOOM_COUNT];


float bloom_dims[MAX_BLOOM_COUNT][2]; float bloom_dims[MAX_BLOOM_COUNT][2];


int bloom_count; int bloom_count;

int cache_index;
}; };


#endif #endif

0 comments on commit 311a56b

Please sign in to comment.