syoyo / tinyusdz

Tiny, dependency-free USDZ/USDA/USDC library written in C++14
Other
453 stars 32 forks source link

[Branch "rendermesh-refactor"] normals not working correctly #149

Closed tellypresence closed 2 months ago

tellypresence commented 2 months ago

On branch rendermesh-refactor

I'm having a problem accessing mesh normals, using RenderMesh::normals.data isn't working for me, is there an example available of the new technique in rendermesh-refactor branch? Here's the approach I'm using:

const size_t stride_bytes{render_scene.meshes[meshIdx].normals.stride_bytes()};
x = render_scene.meshes[meshIdx].normals.get_data()[faceVertIdxOffset + j];
y = render_scene.meshes[meshIdx].normals.get_data()[faceVertIdxOffset + j + stride_bytes];
z = render_scene.meshes[meshIdx].normals.get_data()[faceVertIdxOffset + j + 2 * stride_bytes];

P.S. On dev branch I was accessing individual normal vec3 elements using

x = render_scene.meshes[meshIdx].facevaryingNormals[faceVertIdxOffset + j][0];
y = render_scene.meshes[meshIdx].facevaryingNormals[faceVertIdxOffset + j][1];
z = render_scene.meshes[meshIdx].facevaryingNormals[faceVertIdxOffset + j][2];

which was working very well

syoyo commented 2 months ago

There was an issue on converting facevarying attributes(normals, texcoords) in rendermesh-refactor, which is now fixed in this commit: https://github.com/syoyo/tinyusdz/commit/8d3a5dc50aca1c732efa5bae4701ea2b7981cf6d

Please report an issue related to rendermesh-refactor branch to here https://github.com/syoyo/tinyusdz/issues/148