Page MenuHome

bge.texture.ImageRender alpha channel returns 255 for every pixel
Closed, ArchivedPublic

Description

Category: Rendering

When using image = bge.texture.ImageRender() the alpha channel always returns 255 for every pixel. The red green and blue channels all work.

image = bge.texture.ImageRender(scene, cam)
image.alpha = True
image.background = (0, 0, 0, 0)
buffer = bge.texture.imageToArray(image, "AAA1")

Event Timeline

Blender (and more specifically ghost) does not request and alpha channel for it's render context. On Nvidia cards, you only get a GL_RGB context, but on ATI/AMD, you get GL_RGBA. Since ImageRender is making use of the back buffer (as opposed to an FBO, which it should be using instead), you are stuck with whatever Ghost managed to get. I'm guessing you're using an Nvidia card which is why you always get 255 for the alpha value. Could someone test this on an ATI/AMD card to confirm?

ghost right now is not trying to get RGBA at all.
There is a patch for that (though I didn't test it with video texture) that may be worth committing.

It's old, but if you want to try, it would be nice to see if it fixes this bug:
http://projects.blender.org/tracker/?func=detail&aid=18967&group_id=9&atid=306

I'm not much of a Windows programmer and haven't been able to get Blender to compiler on Windows. My only Windows box is running Windows 8 so that might be the problem. Does the patch work on OS X? If not, any chance I could get a binary with the patch?

Hi Kevin. The patch I mention was finally commitied to trunk. Can you get a build on builder.blender.org newer than rev.54745 and see if it solved your problem?
I couldn't get your file to work even using the RRR1 line (console error saying that buffer is not empty). I'm not sure how to test it then

hi, actually if you could make a demo file using ImageRender and using the image in a plane in the scene it will be easier to debug/test this. Specially because the error I'm getting in your script is related to the ImageToArray part of it

It looks like the alpha framebuffer is disabled by default (r58799). However, after enabling it, I was still getting 255 for the alpha value. I checked my context in gDEBugger, and according to it I had 8 bits of alpha for my framebuffer. May be some other issue.

It looks like a combination of re-enabling the alpha and changing the setBackground in ImageRender's constructor to set an alpha value of 0 fixes the problem. It looks like the alpha framebuffer support was disabled in r56912 to fix a bug. Will need to ask around to figure out the best way to handle this.

A duplicate (with more test files) was posted here: https://projects.blender.org/tracker/?func=detail&atid=306&aid=37396&group_id=9.

Just some update on that: at some point we fixed that and committed the fix to master but this introduced another issue. So the fix is there, but it may be need to be done optional.

@Dalai Felinto (dfelinto) so the fix is in master or not? and what is the new issue?

@Dalai Felinto (dfelinto): Is this fixed ?

I think it is fixed in @Benoit Bolsee (ben2610) decklink branch but it is not merged in master yet

Aaron Carlisle (Blendify) closed this task as Archived.Jun 29 2019, 2:12 AM
Aaron Carlisle (Blendify) claimed this task.