summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--hlsl/bloom.fx131
-rw-r--r--hlsl/downsample.fx17
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp72
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.h5
4 files changed, 105 insertions, 120 deletions
diff --git a/hlsl/bloom.fx b/hlsl/bloom.fx
index 9fabe14efcd..1ee152adfec 100644
--- a/hlsl/bloom.fx
+++ b/hlsl/bloom.fx
@@ -149,17 +149,17 @@ struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
- float4 TexCoord01 : TEXCOORD0;
- float4 TexCoord23 : TEXCOORD1;
- float4 TexCoord45 : TEXCOORD2;
- float4 TexCoord67 : TEXCOORD3;
- float4 TexCoord89 : TEXCOORD4;
- float2 TexCoordA : TEXCOORD5;
+ float2 TexCoord0 : TEXCOORD0;
+ float4 TexCoord12 : TEXCOORD1;
+ float4 TexCoord34 : TEXCOORD2;
+ float4 TexCoord56 : TEXCOORD3;
+ float4 TexCoord78 : TEXCOORD4;
+ float4 TexCoord9A : TEXCOORD5;
};
struct VS_INPUT
{
- float3 Position : POSITION;
+ float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
};
@@ -167,12 +167,12 @@ struct VS_INPUT
struct PS_INPUT
{
float4 Color : COLOR0;
- float4 TexCoord01 : TEXCOORD0;
- float4 TexCoord23 : TEXCOORD1;
- float4 TexCoord45 : TEXCOORD2;
- float4 TexCoord67 : TEXCOORD3;
- float4 TexCoord89 : TEXCOORD4;
- float2 TexCoordA : TEXCOORD5;
+ float2 TexCoord0 : TEXCOORD0;
+ float4 TexCoord12 : TEXCOORD1;
+ float4 TexCoord34 : TEXCOORD2;
+ float4 TexCoord56 : TEXCOORD3;
+ float4 TexCoord78 : TEXCOORD4;
+ float4 TexCoord9A : TEXCOORD5;
};
//-----------------------------------------------------------------------------
@@ -202,13 +202,14 @@ float random(float2 seed)
uniform float2 ScreenDims;
uniform float2 TargetDims;
+uniform float2 SourceRect;
-uniform float4 Level01Size;
-uniform float4 Level23Size;
-uniform float4 Level45Size;
-uniform float4 Level67Size;
-uniform float4 Level89Size;
-uniform float2 LevelASize;
+uniform float2 Level0Size;
+uniform float4 Level12Size;
+uniform float4 Level34Size;
+uniform float4 Level56Size;
+uniform float4 Level78Size;
+uniform float4 Level9ASize;
VS_OUTPUT vs_main(VS_INPUT Input)
{
@@ -225,13 +226,12 @@ VS_OUTPUT vs_main(VS_INPUT Input)
float2 TexCoord = Input.Position.xy / ScreenDims;
TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
- Output.TexCoord01.xy = TexCoord.xy;
- Output.TexCoord01.zw = TexCoord.xy + 0.5f / Level01Size.zw;
- Output.TexCoord23 = TexCoord.xyxy + 0.5f / Level23Size;
- Output.TexCoord45 = TexCoord.xyxy + 0.5f / Level45Size;
- Output.TexCoord67 = TexCoord.xyxy + 0.5f / Level67Size;
- Output.TexCoord89 = TexCoord.xyxy + 0.5f / Level89Size;
- Output.TexCoordA = TexCoord.xy + 0.5f / LevelASize;
+ Output.TexCoord0 = TexCoord;
+ Output.TexCoord12 = TexCoord.xyxy + (0.5f / Level12Size);
+ Output.TexCoord34 = TexCoord.xyxy + (0.5f / Level34Size);
+ Output.TexCoord56 = TexCoord.xyxy + (0.5f / Level56Size);
+ Output.TexCoord78 = TexCoord.xyxy + (0.5f / Level78Size);
+ Output.TexCoord9A = TexCoord.xyxy + (0.5f / Level9ASize);
return Output;
}
@@ -240,11 +240,14 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Bloom Pixel Shader
//-----------------------------------------------------------------------------
-uniform float4 Level0123Weight;
-uniform float4 Level4567Weight;
-uniform float3 Level89AWeight;
+uniform float Level0Weight;
+uniform float2 Level12Weight;
+uniform float2 Level34Weight;
+uniform float2 Level56Weight;
+uniform float2 Level78Weight;
+uniform float2 Level9AWeight;
-uniform int BloomBlendMode = 1; // 0 addition, 1 darken
+uniform int BloomBlendMode = 0; // 0 addition, 1 darken
uniform float BloomScale;
uniform float3 BloomOverdrive;
@@ -256,34 +259,34 @@ float3 GetNoiseFactor(float3 n, float random)
float4 ps_main(PS_INPUT Input) : COLOR
{
- float3 texel0 = tex2D(DiffuseSampler0, Input.TexCoord01.xy).rgb;
- float3 texel1 = tex2D(DiffuseSampler1, Input.TexCoord01.zw).rgb;
- float3 texel2 = tex2D(DiffuseSampler2, Input.TexCoord23.xy).rgb;
- float3 texel3 = tex2D(DiffuseSampler3, Input.TexCoord23.zw).rgb;
- float3 texel4 = tex2D(DiffuseSampler4, Input.TexCoord45.xy).rgb;
- float3 texel5 = tex2D(DiffuseSampler5, Input.TexCoord45.zw).rgb;
- float3 texel6 = tex2D(DiffuseSampler6, Input.TexCoord67.xy).rgb;
- float3 texel7 = tex2D(DiffuseSampler7, Input.TexCoord67.zw).rgb;
- float3 texel8 = tex2D(DiffuseSampler8, Input.TexCoord89.xy).rgb;
- float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord89.zw).rgb;
- float3 texelA = tex2D(DiffuseSamplerA, Input.TexCoordA).rgb;
+ float3 texel0 = tex2D(DiffuseSampler0, Input.TexCoord0).rgb;
+ float3 texel1 = tex2D(DiffuseSampler1, Input.TexCoord12.xy).rgb;
+ float3 texel2 = tex2D(DiffuseSampler2, Input.TexCoord12.zw).rgb;
+ float3 texel3 = tex2D(DiffuseSampler3, Input.TexCoord34.xy).rgb;
+ float3 texel4 = tex2D(DiffuseSampler4, Input.TexCoord34.zw).rgb;
+ float3 texel5 = tex2D(DiffuseSampler5, Input.TexCoord56.xy).rgb;
+ float3 texel6 = tex2D(DiffuseSampler6, Input.TexCoord56.zw).rgb;
+ float3 texel7 = tex2D(DiffuseSampler7, Input.TexCoord78.xy).rgb;
+ float3 texel8 = tex2D(DiffuseSampler8, Input.TexCoord78.zw).rgb;
+ float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord9A.xy).rgb;
+ float3 texelA = tex2D(DiffuseSamplerA, Input.TexCoord9A.zw).rgb;
float3 blend;
// addition
if (BloomBlendMode == 0)
{
- texel0 *= Level0123Weight.x;
- texel1 *= Level0123Weight.y;
- texel2 *= Level0123Weight.z;
- texel3 *= Level0123Weight.w;
- texel4 *= Level4567Weight.x;
- texel5 *= Level4567Weight.y;
- texel6 *= Level4567Weight.z;
- texel7 *= Level4567Weight.w;
- texel8 *= Level89AWeight.x;
- texel9 *= Level89AWeight.y;
- texelA *= Level89AWeight.z;
+ texel0 *= Level0Weight;
+ texel1 *= Level12Weight.x;
+ texel2 *= Level12Weight.y;
+ texel3 *= Level34Weight.x;
+ texel4 *= Level34Weight.y;
+ texel5 *= Level56Weight.x;
+ texel6 *= Level56Weight.y;
+ texel7 *= Level78Weight.x;
+ texel8 *= Level78Weight.y;
+ texel9 *= Level9AWeight.x;
+ texelA *= Level9AWeight.y;
float3 bloom = float3(
texel1 +
@@ -306,7 +309,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
bloom.b += bloomOverdrive.r * 0.5f;
bloom.b += bloomOverdrive.g * 0.5f;
- float2 NoiseCoord = Input.TexCoord01.xy;
+ float2 NoiseCoord = Input.TexCoord0;
float3 NoiseFactor = GetNoiseFactor(bloom, random(NoiseCoord));
blend = texel0 + bloom * NoiseFactor;
@@ -326,17 +329,17 @@ float4 ps_main(PS_INPUT Input) : COLOR
texel9 = min(texel0, texel9);
texelA = min(texel0, texelA);
- blend = texel0 * Level0123Weight.x;
- blend = lerp(blend, texel1, Level0123Weight.y * BloomScale);
- blend = lerp(blend, texel2, Level0123Weight.z * BloomScale);
- blend = lerp(blend, texel3, Level0123Weight.w * BloomScale);
- blend = lerp(blend, texel4, Level4567Weight.x * BloomScale);
- blend = lerp(blend, texel5, Level4567Weight.y * BloomScale);
- blend = lerp(blend, texel6, Level4567Weight.z * BloomScale);
- blend = lerp(blend, texel7, Level4567Weight.w * BloomScale);
- blend = lerp(blend, texel8, Level89AWeight.x * BloomScale);
- blend = lerp(blend, texel9, Level89AWeight.y * BloomScale);
- blend = lerp(blend, texelA, Level89AWeight.z * BloomScale);
+ blend = texel0 * Level0Weight;
+ blend = lerp(blend, texel1, Level12Weight.x * BloomScale);
+ blend = lerp(blend, texel2, Level12Weight.y * BloomScale);
+ blend = lerp(blend, texel3, Level34Weight.x * BloomScale);
+ blend = lerp(blend, texel4, Level34Weight.y * BloomScale);
+ blend = lerp(blend, texel5, Level56Weight.x * BloomScale);
+ blend = lerp(blend, texel6, Level56Weight.y * BloomScale);
+ blend = lerp(blend, texel7, Level78Weight.x * BloomScale);
+ blend = lerp(blend, texel8, Level78Weight.y * BloomScale);
+ blend = lerp(blend, texel9, Level9AWeight.x * BloomScale);
+ blend = lerp(blend, texelA, Level9AWeight.y * BloomScale);
}
return float4(blend, 1.0f);
diff --git a/hlsl/downsample.fx b/hlsl/downsample.fx
index 9ac584b56f1..122172350f9 100644
--- a/hlsl/downsample.fx
+++ b/hlsl/downsample.fx
@@ -35,7 +35,7 @@ struct VS_OUTPUT
struct VS_INPUT
{
- float3 Position : POSITION;
+ float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
};
@@ -53,6 +53,7 @@ struct PS_INPUT
uniform float2 ScreenDims;
uniform float2 TargetDims;
+uniform float2 SourceRect;
uniform bool PrepareVector;
@@ -72,7 +73,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
float2 TexCoord = Input.Position.xy / ScreenDims;
TexCoord += PrepareVector
- ? 0.5f / TargetDims // half texel offset correction (DX9)
+ ? 0.5f / TargetDims // half texel offset correction (DX9) - only for vector grpahics
: 0.0f;
Output.TexCoord01.xy = TexCoord + float2(-0.5f, -0.5f) * TargetTexelDims;
@@ -89,14 +90,14 @@ VS_OUTPUT vs_main(VS_INPUT Input)
float4 ps_main(PS_INPUT Input) : COLOR
{
- float4 texel0 = tex2D(DiffuseSampler, Input.TexCoord01.xy);
- float4 texel1 = tex2D(DiffuseSampler, Input.TexCoord01.zw);
- float4 texel2 = tex2D(DiffuseSampler, Input.TexCoord23.xy);
- float4 texel3 = tex2D(DiffuseSampler, Input.TexCoord23.zw);
+ float3 texel0 = tex2D(DiffuseSampler, Input.TexCoord01.xy).rgb;
+ float3 texel1 = tex2D(DiffuseSampler, Input.TexCoord01.zw).rgb;
+ float3 texel2 = tex2D(DiffuseSampler, Input.TexCoord23.xy).rgb;
+ float3 texel3 = tex2D(DiffuseSampler, Input.TexCoord23.zw).rgb;
- float4 outTexel = (texel0 + texel1 + texel2 + texel3) / 4.0;
+ float3 outTexel = (texel0 + texel1 + texel2 + texel3) / 4.0;
- return float4(outTexel.rgb, 1.0f);
+ return float4(outTexel, 1.0f);
}
//-----------------------------------------------------------------------------
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index c135019ca23..90f9dd503c1 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -1515,35 +1515,43 @@ int shaders::bloom_pass(render_target *rt, int source_index, poly_info *poly, in
return next_index;
}
- curr_effect = bloom_effect;
- curr_effect->update_uniforms();
-
- float weight0123[4] = {
- options->bloom_level0_weight,
+ float weight12[2] = {
options->bloom_level1_weight,
- options->bloom_level2_weight,
- options->bloom_level3_weight
+ options->bloom_level2_weight
};
- float weight4567[4] = {
- options->bloom_level4_weight,
+ float weight34[2] = {
+ options->bloom_level3_weight,
+ options->bloom_level4_weight
+ };
+ float weight56[2] = {
options->bloom_level5_weight,
options->bloom_level6_weight,
- options->bloom_level7_weight
};
- float weight89A[3] = {
- options->bloom_level8_weight,
+ float weight78[2] = {
+ options->bloom_level7_weight,
+ options->bloom_level8_weight
+ };
+ float weight9A[2] = {
options->bloom_level9_weight,
options->bloom_level10_weight
};
- curr_effect->set_vector("Level0123Weight", 4, weight0123);
- curr_effect->set_vector("Level4567Weight", 4, weight4567);
- curr_effect->set_vector("Level89AWeight", 3, weight89A);
- curr_effect->set_vector("Level01Size", 4, bloom_dims[0]);
- curr_effect->set_vector("Level23Size", 4, bloom_dims[2]);
- curr_effect->set_vector("Level45Size", 4, bloom_dims[4]);
- curr_effect->set_vector("Level67Size", 4, bloom_dims[6]);
- curr_effect->set_vector("Level89Size", 4, bloom_dims[8]);
- curr_effect->set_vector("LevelASize", 2, bloom_dims[10]);
+
+ curr_effect = bloom_effect;
+ curr_effect->update_uniforms();
+
+ curr_effect->set_float ("Level0Weight", options->bloom_level0_weight);
+ curr_effect->set_vector("Level12Weight", 2, weight12);
+ curr_effect->set_vector("Level34Weight", 2, weight34);
+ curr_effect->set_vector("Level56Weight", 2, weight56);
+ curr_effect->set_vector("Level78Weight", 2, weight78);
+ curr_effect->set_vector("Level9AWeight", 2, weight9A);
+
+ curr_effect->set_vector("Level0Size", 2, bloom_dims[0]);
+ curr_effect->set_vector("Level12Size", 4, bloom_dims[1]);
+ curr_effect->set_vector("Level34Size", 4, bloom_dims[3]);
+ curr_effect->set_vector("Level56Size", 4, bloom_dims[5]);
+ curr_effect->set_vector("Level78Size", 4, bloom_dims[7]);
+ curr_effect->set_vector("Level9ASize", 4, bloom_dims[9]);
curr_effect->set_int("BloomBlendMode", options->bloom_blend_mode);
curr_effect->set_float("BloomScale", options->bloom_scale);
@@ -3185,28 +3193,6 @@ void uniform::update()
case CU_POST_FLOOR:
m_shader->set_vector("Floor", 3, options->floor);
break;
-
- case CU_BLOOM_RESCALE:
- m_shader->set_float("BloomRescale", options->bloom_scale);
- break;
- case CU_BLOOM_LVL0123_WEIGHTS:
- {
- float weight0123[4] = { options->bloom_level0_weight, options->bloom_level1_weight, options->bloom_level2_weight, options->bloom_level3_weight };
- m_shader->set_vector("Level0123Weight", 4, weight0123);
- break;
- }
- case CU_BLOOM_LVL4567_WEIGHTS:
- {
- float weight4567[4] = { options->bloom_level4_weight, options->bloom_level5_weight, options->bloom_level6_weight, options->bloom_level7_weight };
- m_shader->set_vector("Level4567Weight", 4, weight4567);
- break;
- }
- case CU_BLOOM_LVL89A_WEIGHTS:
- {
- float weight89A[3] = { options->bloom_level8_weight, options->bloom_level9_weight, options->bloom_level10_weight };
- m_shader->set_vector("Level89AWeight", 3, weight89A);
- break;
- }
}
}
diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h
index 709253c7004..a6d71f27d37 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.h
+++ b/src/osd/modules/render/d3d/d3dhlsl.h
@@ -102,11 +102,6 @@ public:
CU_POST_POWER,
CU_POST_FLOOR,
- CU_BLOOM_RESCALE,
- CU_BLOOM_LVL0123_WEIGHTS,
- CU_BLOOM_LVL4567_WEIGHTS,
- CU_BLOOM_LVL89A_WEIGHTS,
-
CU_COUNT
};