Confused when transfer object normal to world normal

Hi,when I’m getting different result when using optixTransformNormalFromObjectToWorldSpace, the normal variable all turn to be (0, 0, 0).
To find out the different,I’m make the normal to output color. When I use the optixHair sample to raytrace,the fun works totally fine,the effect as belows:


But when I use the same calculation on my code,fun results is very strange,effect:
objectNormal-2
output normal is balck…Is there any configure I’m missing?

Hi @blubumbee, can you add some detail about how you compute your normals? Are you using the surfaceNormal() function from the optixHair sample?

A couple of easy things to check come to my mind:

If you’re calling any of the optixGet*VertexData() functions, make sure you build your GAS using OPTIX_BUILD_FLAG_ALLOW_RANDOM_VERTEX_ACCESS.

If you’re passing normals between shader programs in a payload or attribute register, or converting your normals to ints temporarily anywhere else, then don’t forget to use float_as_int() and int_as_float() if needed. I forget these sometimes, and the symptom is the same as yours – [0,1] float values will get clamped to 0.

Other than those, my next suggestions would be to check the transform to make sure it’s not degenerate, and also check the normals before you transform them. In your pictures, the colors don’t hit full saturation which indicates to me that the normals aren’t normalized. (I’m assuming that you aren’t modifying the colors, and that they should look as bright as the optixHair colors.) If the normals aren’t normalized, and the transform has scaling in it, then I could imagine the normals accidentally becoming small enough to appear flat like in your picture, even though maybe they’re technically non-zero?


David.

Thank you so much for reply.
I use surfaceNormal() to get the object normal.The the same way as optixHair sample.
I find the problem by comment function one by one in optixHiar sample,after like fourty times debug,finally I find I was missing the yUpTransform…
Thanks again for the third advices.