nvpro-samples / vk_raytrace

Ray tracing glTF scene with Vulkan
Apache License 2.0
575 stars 35 forks source link

black edges occur when zoom in #18

Closed f1shel closed 2 years ago

f1shel commented 2 years ago

Hi, thanks for this greate project!

I encountered a problem which seems like a bug.

Take the robot-toon scene for example, when you zoom in to observe the model, some black lines will occur around the contour, as shown in the figure below.

1 2

This will also happen to other contours. Is that a bug?

f1shel commented 2 years ago

another example 3

droettger commented 2 years ago

That is a usual artifact when rendering low-poly models with interpolated per-vertex shading normals.

At high geometry curvatures, which appear along the silhouettes of this object, it can happen that the interpolated shading normal across a triangle primitive actually doesn't lie inside the same hemisphere as the direction to the viewer (negative ray direction) and that's a false condition for the lighting test. For the shading calculation that's like looking at the backface of an opaque object. (This would not happen when using the face-normals instead of the shading normals, but then you get a facetted look.)

Similar effects would arise when the sampled continuation ray in a path tracer would continue below the geometric surface of opaque materials, which also happens regularly with bump- or normal-maps.

This site has some nice images explaining interpolated shading normals: https://www.scratchapixel.com/lessons/3d-basic-rendering/introduction-to-shading/shading-normals

The black areas are running into the dot(V, N) < 0.0 case.

Kuranes commented 2 years ago

@f1shel FYI it's know topic with possible mitigation stragegies as per the publication "Consistent Normal Interpolation", Reshetov et al., 2010 https://blog.yiningkarlli.com/2015/01/consistent-normal-interpolation.html and an implementation here