Bug in jit.gl.render ? colored alpha channel

abs11's icon

Hello List,

I am trying to send my render output with alpha channel with syphon to another application.
It works well, if i set the erase_mode of my jit.gl.render to clearcolor.

But if i blend my content, it has always the background color of my jit.gl.render object inside.

Here is a patch, which simulates the problem.
I woud expect, that the shape at the copy_context window is not colored.

Perhaps someone had the same problem and solved it.

Max Patch
Copy patch and select New From Clipboard in Max.
Rob Ramirez's icon

use jit.gl.node and set the node's @erase_color to 0 0 0 0:

Max Patch
Copy patch and select New From Clipboard in Max.
abs11's icon

Hello Rob,

Thanks for the nice trick, but my patch is a bit more complex.
I have many (hundreds) gl elements capsulated inside different poly~ objects.

I found no way connecting them to jit.gl.node ...
Perhaps there is also a little trick to connect them without wires ;-)

Greetings,
abs11

abs11's icon

Ahhhh ...
Got it now.
@name attribute of jit.gl.node is my friend :-)
Sorry for the noise ...

abs11's icon

Hey Rob,

Get strange results, using jit.gl.node @capture 1, if I bang my gl objects manually. (@automatic 0)
Everythin is fine @automatic 1 ...

Here is an example based on the jit.gl.node helpfile.
- no texture output
- the videoplane still 3 dimensional @capture 1

Max Patch
Copy patch and select New From Clipboard in Max.

Btw is there no chance to get it working without jit.gl.node ?

abs11's icon

Hello All,

I am a bit lost. I did not found a solution to grab a texture of my render context with the correct alpha channel, if i trigger my open gl objects manualy. (@automatic 0)

1) The to_texture method of gl.render outputs a wrong alpha
2) There is no texture output, if i use jit.gl.node. gl object @automatic is set to 0

I dont think, that it a very advanced setup ;-)
Perhaps someone has found a solution or workaround.

Or will these bugs fixed ???
Greetings,
abs11

Rob Ramirez's icon

capturing with jit.gl.node only supports automatic mode drawing.

maybe try setting your gl.render @erase_color to 0 0 0 0

abs11's icon

Hello Rob,

gl.render @erase_color to 0 0 0 0 always copies black into the alpha channel.

Is there any hope, that we get a fix or workaround to get a proper alpha out of a render context ?

Greetings,
abs11

Max Patch
Copy patch and select New From Clipboard in Max.

Here is a patch:

Rob Ramirez's icon

the texture you capture to must be float32 instead of the default of char.
send the message "type float32" to the texture, after your init rendering.

for some reason, setting the type only works after the render context is initialized, so setting it in the max box with @type float32 doesn't work.

abs11's icon

Hello Rob,

Thanks for the tip, but sadly the "type float32" message changes nothing here.
The alpha channel still has black inside. Check the difference between the "original_context" and the "copy_context" while blending the gridshape.

Btw. i am working on max 6.1.6 and 10.8.5 in 32bit mode

Here is my patch, after 4 sec. the texture should be float32.

Max Patch
Copy patch and select New From Clipboard in Max.

Greetings,
abs11

Rob Ramirez's icon
Max Patch
Copy patch and select New From Clipboard in Max.

the difference is because you have blend_enable 1 on you jit.gl.videoplane:

abs11's icon

Hey Rob,

First i want to thank you for your patience !

But "blend_enable 0" is not an option, because then the alpha channel is gone.
(I need it in the receiving application)
It is difficult to describe with a single gridshape, so i made a new patcher.

It has a white plane with a gradient as an alpha channel.
There are only white pixels in the original_context.
I see a lot af grey pixel here.

Perhaps i am wrong, but for my understanding the copy_context should be white.
If you change to blue (erase_color 0. 0. 1. 0.), the pixel gets blue.

Max Patch
Copy patch and select New From Clipboard in Max.

Greetings abs11

Rob Ramirez's icon

sorry, i'm not seeing any unexpected results over here.
below is what i'm seeing when i open your patch, change the orginal-context erase color to blue, and the copy context erase color to pink.

it looks exactly like i would expect.

Screen-Shot-2014-03-20-at-12.41.44-PM.png
png
abs11's icon

Hello Rob,

Perhaps this behaviour depends on the gpu.
Mine is an "AMD Radeon HD 6750M"

I have also added a single white line.
At the copy_context there you always see the erase_color of the original_context.

Max Patch
Copy patch and select New From Clipboard in Max.

The output looks like this.
scrennshot_blue.png
screenshot_black.png

screenshot_black.png
png
scrennshot_blue.png
png
abs11's icon

BTW
The output is exactly the same on a mac mini (gpu: NVIDIA GeForce 9400)
The expectation is that the copy_contex is white ;-)