Skip to content

[BUG] - wide seams along intersections and edges with dual depth peeling #219

@mqnc

Description

@mqnc

Describe the bug.
There are large seams and gaps where surfaces intersect or meet when using dual depth peeling. These only start to appear at a certain zoom level, you have to zoom in a little bit. I think they are too large and too regular-looking to be explained by some z fighting or depth resolution issues.
Image

Tell us how to reproduce the bug.

#include <easy3d/util/initializer.h>
#include <easy3d/viewer/viewer.h>
#include <easy3d/renderer/drawable_triangles.h>
#include <easy3d/renderer/dual_depth_peeling.h>

using namespace easy3d;

class TransparencyViewer: public easy3d::Viewer {
public:
	explicit TransparencyViewer(const std::string& title = ""): Viewer(title) {
		transparency_ = new DualDepthPeeling(camera());
	}
	~TransparencyViewer() override {
		delete transparency_;
	}

protected:
	void draw() const override {
		std::vector<TrianglesDrawable*> surfaces;
		for (auto d: drawables_) {
			surfaces.push_back(dynamic_cast<TrianglesDrawable*>(d.get()));
		}
		transparency_->draw(surfaces);
	}

private:
	easy3d::DualDepthPeeling* transparency_;
};


std::shared_ptr<TrianglesDrawable> make_cube(const vec3& offset) {
	std::vector<vec3> vertices = {
		{-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1},
		{-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1}
	};
	for (auto& v: vertices) v += offset;

	std::vector<unsigned int> indices = {
		0, 1, 2, 0, 2, 3,
		1, 5, 6, 1, 6, 2,
		5, 4, 7, 5, 7, 6,
		4, 0, 3, 4, 3, 7,
		3, 2, 6, 3, 6, 7,
		4, 5, 1, 4, 1, 0
	};

	auto d = std::make_shared<TrianglesDrawable>("cube");
	d->update_vertex_buffer(vertices);
	d->update_element_buffer(indices);

	return d;
}

int main(int argc, char** argv) {
	initialize();

	TransparencyViewer viewer("Two Transparent Cubes");

	viewer.add_drawable(make_cube(vec3(0, 0, 0)));
	viewer.add_drawable(make_cube(vec3(0.5f, 0.5f, 0.5f)));

	viewer.run();
}

Development/Running environment:

  • OS: kubuntu 24.04
  • Compiler G++ 13.3.0
  • Release

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions