No transparency when using the R8 pixel format
CaptainKraft opened this issue · 1 comments
I'm on Windows using the latest sokol libs.
When rendering an image with the pixel format SG_PIXELFORMAT_R8
, and while using a custom shader (shown below), I am unable to render with any transparency.
@vs vs
in vec4 coord;
out vec2 texUV;
void main() {
gl_Position = vec4(coord.xy, 0.0, 1.0);
texUV = coord.zw;
}
@end
@fs fs
uniform texture2D iTexChannel0;
uniform sampler iSmpChannel0;
uniform fs_params {
vec4 iColor;
};
in vec2 texUV;
out vec4 fragColor;
void main() {
vec4 tex_color = texture(sampler2D(iTexChannel0, iSmpChannel0), texUV) * iColor;
fragColor = vec4(1, 1, 1, tex_color.r);
}
@end
@program text vs fs
I have the blend mode set correctly, and I'm correctly rendering other images with transparency. When using the above shader, I can even set the fragColor's alpha value to 0, and it will still render fully opaque.
Here is the image description:
res.img = sg_make_image(&(sg_image_desc){
.width = res.w,
.height = res.h,
.data.subimage[0][0].ptr = temp_bitmap,
.data.subimage[0][0].size = (size_t)(res.w * res.h),
.pixel_format = SG_PIXELFORMAT_R8,
});
When rendering with the default shader, this is what is produced:
And when rendering with the custom shader, this is what is produced:
Am I doing something wrong, or is there a bug in the way that R8 images are being rendered?
My mistake. I missed the part where I'm supposed to set a blend mode for the pipeline.