mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-08-27 05:06:39 -05:00
Data: provide a blur mod for games with bloom
Add a mod for all games with bloom targets that blurs the bloom based on resolution using a custom material. The shader exposes bloom brightness and the amount of spread through uniforms (not exposed in the UI yet). The original shader logic was done by TryTwo. This shader was reworked for graphics mods and cleaned up slightly. Co-authored-by: TryTwo <taolas@gmail.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
void process_fragment(in DolphinFragmentInput frag_input, out DolphinFragmentOutput frag_output)
|
||||
{
|
||||
int layer = int(frag_input.tex0.z);
|
||||
int r = int(efb_scale) * int(SPREAD_MULTIPLIER);
|
||||
int coord;
|
||||
int length;
|
||||
int2 initial_coords = int2(frag_input.tex0.xy * source_resolution.xy);
|
||||
vec4 brightness = float4(1.0, 1.0, 1.0, 1.0);
|
||||
if (HORIZONTAL)
|
||||
{
|
||||
length = int(source_resolution.x);
|
||||
coord = initial_coords.x;
|
||||
brightness = BRIGHTNESS_MULTIPLIER * brightness;
|
||||
}
|
||||
else
|
||||
{
|
||||
length = int(source_resolution.y);
|
||||
coord = initial_coords.y;
|
||||
}
|
||||
|
||||
int offset;
|
||||
vec4 count = vec4(0.0,0.0,0.0,0.0);
|
||||
vec4 col = vec4(0.0,0.0,0.0,0.0);
|
||||
for (offset = -r; offset <= r; offset++)
|
||||
{
|
||||
int pos = coord + offset;
|
||||
if (pos <= length && pos >= 0)
|
||||
{
|
||||
int3 sample_coords;
|
||||
if (HORIZONTAL)
|
||||
{
|
||||
sample_coords = int3(int2(pos, initial_coords.y), layer);
|
||||
}
|
||||
else
|
||||
{
|
||||
sample_coords = int3(int2(initial_coords.x, pos), layer);
|
||||
}
|
||||
|
||||
col += texelFetch(samp0, sample_coords, 0);
|
||||
count += vec4(1.0,1.0,1.0,1.0);
|
||||
}
|
||||
}
|
||||
frag_output.main = col / count * brightness;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"properties":[
|
||||
{
|
||||
"code_name": "HORIZONTAL",
|
||||
"default": true,
|
||||
"description": "Whether to apply the blur horizontally or vertically",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"code_name": "SPREAD_MULTIPLIER",
|
||||
"default": 1.0,
|
||||
"description": "How much to spread the blur",
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"code_name": "BRIGHTNESS_MULTIPLIER",
|
||||
"default": 1.0,
|
||||
"description": "How bright the blur is",
|
||||
"type": "float"
|
||||
}
|
||||
],
|
||||
"samplers":[]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
void process_vertex(in DolphinVertexInput vertex_input, out DolphinVertexOutput vertex_output)
|
||||
{
|
||||
dolphin_process_emulated_vertex(vertex_input, vertex_output);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"next_material_asset":"dolphin_bloom_blur_vertical",
|
||||
"properties":[
|
||||
{
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "float",
|
||||
"value": 1.0
|
||||
},
|
||||
{
|
||||
"type": "float",
|
||||
"value": 1.0
|
||||
}
|
||||
],
|
||||
"textures":[],
|
||||
"shader_asset": "dolphin_bloom_blur"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"next_material_asset":"",
|
||||
"properties":[
|
||||
{
|
||||
"type": "bool",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"type": "float",
|
||||
"value": 1.0
|
||||
},
|
||||
{
|
||||
"type": "float",
|
||||
"value": 1.0
|
||||
}
|
||||
],
|
||||
"textures":[],
|
||||
"shader_asset": "dolphin_bloom_blur"
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"meta":
|
||||
{
|
||||
"title": "Bloom Blurred",
|
||||
"author": "Dolphin Team",
|
||||
"description": "Modifies bloom effects to blur them to their native resolution. Results in bloom looking much more natural at higher resolutions but the blur may be too intense in some games."
|
||||
},
|
||||
"features":
|
||||
[
|
||||
{
|
||||
"group": "Bloom",
|
||||
"action": "custom_pipeline",
|
||||
"action_data":
|
||||
{
|
||||
"material_asset": "dolphin_bloom_blur_horizontal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"assets": [
|
||||
{
|
||||
"data": {
|
||||
"metadata": "blur.rastershader",
|
||||
"pixel_shader": "blur.ps.glsl",
|
||||
"vertex_shader": "blur.vs.glsl"
|
||||
},
|
||||
"name": "dolphin_bloom_blur"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"metadata": "blur_horizontal.rastermaterial"
|
||||
},
|
||||
"name": "dolphin_bloom_blur_horizontal"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"metadata": "blur_vertical.rastermaterial"
|
||||
},
|
||||
"name": "dolphin_bloom_blur_vertical"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user