Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented dither noise #492

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Implemented dither noise #492

wants to merge 10 commits into from

Conversation

KiritoDv
Copy link
Contributor

(cherry picked from commit 7321c1a)

(cherry picked from commit 7321c1a)
(cherry picked from commit e344ac3)
src/graphic/Fast3D/gfx_pc.cpp Outdated Show resolved Hide resolved
@@ -3886,7 +3898,7 @@ void gfx_run(Gfx* commands, const std::unordered_map<Mtx*, MtxF>& mtx_replacemen
!game_renders_to_framebuffer);
gfx_rapi->start_frame();
gfx_rapi->start_draw_to_framebuffer(game_renders_to_framebuffer ? game_framebuffer : 0,
(float)gfx_current_dimensions.height / gfx_native_dimensions.height);
gfx_calculate_noise_scale(), g_rdp.alpha_test_value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing in alpha_test_value through start_draw_to_framebuffer means that the value is only read and set once at the very beginning of the frame.

But you implemented gfx_dp_set_blend_color which influences this value, but it'll never be updated to the shader this way.

Comment on lines 583 to 591
if (cc_features.opt_alpha && cc_features.opt_noise) {
append_line(
fs_buf, &fs_len,
"texel.a = alphaDither(random(vec3(floor(gl_FragCoord.xy * noise_scale), float(frame_count))), texel.a);");
} else if (cc_features.opt_noise) {
append_line(fs_buf, &fs_len,
"texel.a *= floor(clamp(random(vec3(floor(gl_FragCoord.xy * noise_scale), float(frame_count))) + "
"texel.a, 0.0, 1.0));");
"texel.rgb = colorDither(random(vec3(floor(gl_FragCoord.xy * noise_scale), float(frame_count))), "
"texel.rgb);");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least from what I can see in MM, it is possible for aplha dithering and color dithering to be applied at the same time. This if / if else does not allow that currently.

We may even need to split opt_noise into two values, or something so that we can control which is used.

@Kenix3 Kenix3 requested a review from Archez April 30, 2024 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants