RenderKit / embree

Embree ray tracing kernels repository.
Apache License 2.0
2.32k stars 383 forks source link

Questions about model normals. #420

Closed GraphicsEnthusiast closed 1 year ago

GraphicsEnthusiast commented 1 year ago

When I use embree to calculate the normal of the model, some models will have problems, such as the teapot model, but some models have no problem, such as the bunny model, and the problematic model can be rendered correctly if I use the normal calculated by myself. wenti spp255

GraphicsEnthusiast commented 1 year ago

spp255

svenwoop commented 1 year ago

Embree returns the normal in object space, while you need a world space normal for shading. Further the normal returned by Embree is the geometry normal, shading typically uses interpolated shading normals.

GraphicsEnthusiast commented 1 year ago

Thank you! But I wonder why the rabbit has no problem but the teapot has a problem. The dragon and Lucy are also fine, but Mitsuba's shader ball has the same problem. image 1234567 123456

GraphicsEnthusiast commented 1 year ago

I want to know why the normals calculated by some models are correct, and some are not correct, and I use the rtcInterpolate0 function to interpolate the normals read from the model, and there will be problems, maybe I am not using it right. Sorry to bother you, but I really want to figure it out.

svenwoop commented 1 year ago

Thus you use rtcInterpolate1 and get different results when doing that same interpolation manually? This should not be the case as rtcInterpolate1 just does a simple interpolation with u/v coordinates. I assume you somehow setup the buffer wrong that holds the normals interpolated by Embree. Anyway, for triangles we do not recommend using rtcInterpolate1 function, best use your own implementation. rtcInterpolate1 supports triangle meshes just for completeness, it will be faster to interpolate yourself.

GraphicsEnthusiast commented 1 year ago

Thank you a lot!