Closed mixtur closed 3 months ago
"If a tree falls in the forest..." No, wait. "If a green checkmark has an alpha value of 0, is it really there?"
The texture area that is used here is indicated by that square (in the left part of the Window, the Blender UV editor). This square appears to be below the green check mark. And it appears to be in an "empty" area, which seems to explain that the square is rendered in black.
But ... there is a green checkmark! The problem (which is not really a problem, but the intention) is that the pixels there have an alpha value of 0. They should still be rendered opaque. (Or 'opaquely'? However...)
Here is the texture image where I blatantly set all the alpha values to 255 (leaving the other color components untouched):
There indeed is a green checkmark.
I'm not sure why Blender doesn't get this right, but ... some Blender expert might give a hint here - probably, just some setting somewhere that has to be changed.
Edit, for completeness: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#alpha-coverage says
alphaMode
can be one of the following values:
OPAQUE
- The rendered output is fully opaque and any alpha value is ignored.
Oh. I see. So my problem is that my method of aquiring pixel values also premultiplies them by alpha. Thank you. It helps a lot.
If anyone will ever have the same problem, get pixel values not through canvas 2d context, but rather with webgl, or use some WebAssembly image parser (stb_image or similar).
I've been doing Raytracing in one weekend series, then got carried away a little and decided to implement gltf support there.
I am a little confused by this model https://github.com/KhronosGroup/glTF-Sample-Assets/tree/main/Models/AlphaBlendModeTest
Here is what happens in my ray tracer: https://mixtur.github.io/raytracing-weekend/renderer.html?scene=10
The left-most checkmark is a black square, instead of a check mark. And Blender seems to agree with me.
However all 3d engines, and a reference glTF viewer, seem to render the check mark.
How is that possible?