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

Can we handle z-fight issue in ospray #546

Open
bharatshiyani opened this issue Nov 23, 2022 · 4 comments
Open

Can we handle z-fight issue in ospray #546

bharatshiyani opened this issue Nov 23, 2022 · 4 comments

Comments

@bharatshiyani
Copy link

Hello,

We face z-fight issue when two co-planner surfaces are there. In opengl we can handle that issue by giving priority to specific surface and at rendering time, based on camera angle we apply offset to the vertice in shader according to priority.

Is something like this possible in ospray, can we modify vertices value based on camera angle ?

image

@johguenther
Copy link
Contributor

Related to #545.

Let us explore the use case a bit more:

  • Co-planar surfaces cannot be avoided (e.g., during modelling or scene preparation)?
  • Co-planar surfaces need to have different materials? Because with identical materials/color there should not be visible artifacts.
  • Do you need to have control over which surface should "win"? Or is either fine, as long as there are no z-fighting issues?

@bharatshiyani
Copy link
Author

Hi @johguenther,

Thank you for the reply.

Indeed the z-fight is the issue face quite frequently by many users in graphics engine.

  1. Co-planar can not be avoided because there are cases where we just use 3D data coming to our rendering application and that data often comes as co-planer.
  2. Yes very frequent usecase.
  3. Yes control required to see which surface has priority and so at the rendering we see that control in from from camera view. And if surfaces are not z-fighting then the normal behavior is fine.

Just to give you perspective, if something like this is doable, lets say we set priority to surface from 1 to 5. And 3 is the default. And at shader, we check as below...

if priority is 3 : do nothing
if priority is 2: offset a vertice little bit away from the camera
if priority is 4: offset a vertice little bit near to the camera.
This way if we have two surfaces overlapping then we can set priority of one surface to 4 and that will be drawn on top from camera's viewing angle.


Currently if we add manual offset to each vertices before creating ospray geometry, then static images is ok. But when we change the camera angle it is not correct. Because on each frame the vertice will not offset based on camera angle.

Thanks.

@johguenther
Copy link
Contributor

I do not want to offset vertices (problematic for a ray tracer), but instead was thinking to consistently handle the intersections by taking the instance and object IDs into account as well. The co-planar surfaces are not within the same geometry, are they? Then they would usually have the same material and also cannot be distinguished which one to offset / select.

@bharatshiyani
Copy link
Author

Hi @johguenther ,

Right the co-planer surfaces are not within the same geometry.

"Consistently handle the interaction" solution seems promising. I think this should solve the z-fight problem.

Any plane for implementation ?

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

No branches or pull requests

2 participants