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

Try optimizing imageCleanTransparent #14479

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

appgurueu
Copy link
Contributor

  • Goal of the PR: Same as Different algorithm for imageCleanTransparent #14478
  • How does the PR work? Simply implements a BFS, keeping the "border" of nodes in a vector. Resulting images should look the same (basic testing confirms this), except there is no arbitrary iteration cutoff (because this new algorithm runs in overall linear time, whereas in the previous algo each iteration was linear time, this should not be needed, but it could be added easily).
  • Not benchmarked yet.

To do

This PR is WIP.

  • See FIXMEs: Why is the existing code not gamma correct (should we preserve this for performance)? Why are we weighing by alpha, which "over-weighs" propagated colors?
  • Benchmark
  • Optimize this PR (or kill it if the benchmarks show that it's the same.

How to test

Hack to make all nodes opaque / normal drawtype (this lets you see what happens to apple / rose / etc. without needing RenderDoc and having to look for the textures):

minetest.register_on_mods_loaded(function()
	for name, def in pairs(minetest.registered_nodes) do
		if name ~= "air" then
			minetest.override_item(name, {
				use_texture_alpha = "opaque",
				drawtype = "normal",
			})
		end
	end
end)

Bitmap bitmap(dim.Width, dim.Height);
Bitmap seen(dim.Width, dim.Height);
Bitmap prev_levels(dim.Width, dim.Height);
std::vector<v2u32> level, next_level;
Copy link
Member

@sfan5 sfan5 Mar 20, 2024

Choose a reason for hiding this comment

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

thought: so the Bitmap class is essentially a std::set<v2u32>. and you're using a the vectors like a set.
maybe it's faster to (re)use a bitmap here, because the bitmap is a fixed 32 bytes while the vector goes to 160 bytes if you store even 20 pairs in it?

@sfan5 sfan5 added the WIP The PR is still being worked on by its author and not ready yet. label Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Client rendering Performance Possible close WIP The PR is still being worked on by its author and not ready yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants