I want to draw a greyscale image taken from an ImageData object that has 1 byte per pixel (pixel format "r8").
I want to show it as greyscale on screen, but when I use lg.newImage(imgdata) and then draw the resulting Image object, it appears red.
I can obviously use a shader that copies the red channel to the green and blue channels to get the result I want, but is there an easier way? E.g. some way to create the Image object from three copies of the r channel, or some way to force the red to appear as white somehow?
Greyscale image with 1 byte per pixel
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- slime
- Solid Snayke
- Posts: 3136
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Greyscale image with 1 byte per pixel
A shader is the only way. Modern GPUs support color component swizzles when creating a texture which would let you do that, but not all GPUs support it and love doesn't provide a way to use that capability at the moment.
Here's an example of a basic shader:
Here's an example of a basic shader:
Code: Select all
vec4 effect(vec4 vcolor, Image tex, vec2 tc, vec2 pc)
{
return vcolor * vec4(Texel(tex, tc).rrr, 1.0));
}
Re: Greyscale image with 1 byte per pixel
OK, thanks slime!
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 9 guests