Data: add a blurred DOF feature

This commit is contained in:
iwubcode
2025-11-18 00:21:38 -06:00
parent db72877520
commit d8c8a04ab8
7 changed files with 151 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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":[]
}

View File

@@ -0,0 +1,4 @@
void process_vertex(in DolphinVertexInput vertex_input, out DolphinVertexOutput vertex_output)
{
dolphin_process_emulated_vertex(vertex_input, vertex_output);
}

View File

@@ -0,0 +1,19 @@
{
"next_material_asset":"dolphin_dof_blur_vertical",
"properties":[
{
"type": "bool",
"value": true
},
{
"type": "float",
"value": 1.0
},
{
"type": "float",
"value": 1.0
}
],
"textures":[],
"shader_asset": "dolphin_dof_blur"
}

View File

@@ -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_dof_blur"
}

View File

@@ -0,0 +1,41 @@
{
"meta":
{
"title": "DOF Blurred",
"author": "Dolphin Team",
"description": "Modifies depth of field effects to blur them to their native resolution. Results in depth of field looking much more natural at higher resolutions but the blur may be too intense in some games."
},
"features":
[
{
"group": "DOF",
"action": "custom_pipeline",
"action_data":
{
"material_asset": "dolphin_dof_blur_horizontal"
}
}
],
"assets": [
{
"data": {
"metadata": "blur.rastershader",
"pixel_shader": "blur.ps.glsl",
"vertex_shader": "blur.vs.glsl"
},
"name": "dolphin_dof_blur"
},
{
"data": {
"metadata": "blur_horizontal.rastermaterial"
},
"name": "dolphin_dof_blur_horizontal"
},
{
"data": {
"metadata": "blur_vertical.rastermaterial"
},
"name": "dolphin_dof_blur_vertical"
}
]
}