praeclarum / ShaderGraphCoder

Write RealityKit shaders using Swift
137 stars 2 forks source link

Texture coordinate V is upside down. #5

Closed ynagatomo closed 3 months ago

ynagatomo commented 3 months ago

Thank you for fixing the texture issue. But I think the texture coordinate V may be upside down like showing below.

praeclarum commented 3 months ago

Yeah this is an annoyance in USD shaders vs Metal (and the rest of the graphics world). For whatever reason, they decided to put 0,0 at the bottom left of a texture. You can verify this in Reality Composer Pro. Apple documents it (poorly) but I can't find the reference at the moment...

In https://developer.apple.com/metal/Metal-RealityKit-APIs.pdf you'll notice they mention that USD texcoord v's are flipped. Since the ShaderGraph is USD based, we're stuck with this convention. Screenshot 2024-06-08 at 11 15 19 AM

Sorry this is just a weird shader graph thing and not a bug in this library :-( Please make friends with the oneMinus operation.

ynagatomo commented 3 months ago

Understood. Thanks.