Hi,
Now, I don't know if this is possible at all.
Suppose I have a [rectangle] (or whatever primitive indeed) with a texture, and something behind the rectangle. Is it possible to have the rectangle "blend" with the background with some blending mode (such as add, multiply, etc)? (without having to render all the rest of the scene except the rectangle into a texture via gemframebuffer, and then blending the two textures with pix_add and friends)???
Isn't it a matter of shaders? I guess it could be achieved using openGL functions... but is there a "simple" way?
Thanks m.
Is it what you are looking for ? ++
Jack
Le samedi 28 novembre 2009 à 17:53 +0100, Matteo Sisti Sette a écrit :
Hi,
Now, I don't know if this is possible at all.
Suppose I have a [rectangle] (or whatever primitive indeed) with a texture, and something behind the rectangle. Is it possible to have the rectangle "blend" with the background with some blending mode (such as add, multiply, etc)? (without having to render all the rest of the scene except the rectangle into a texture via gemframebuffer, and then blending the two textures with pix_add and friends)???
Isn't it a matter of shaders? I guess it could be achieved using openGL functions... but is there a "simple" way?
Thanks m.
Jack escribió:
Is it what you are looking for ?
Well, since I use Windows pix_share_write and read don't work, but I guess I could do the same without those objects.
Yes, this is one approach. I was looking for another approach that wouldn't involve taking snapshots of the scene and adding them as textures, but I guess this is the only reasonable way of doing it (in gem)
thanks.
By the way, another question...
Suppose I have an image stream from the camera of WxH pixels, and I have to create a (N*W)x(N*H) image composed by an NxN "grid" where each element of the grid is either a copy of the camera image (possibly manipulated) or an empty all-transparent image (i.e. WxH pixels with alpha=0). So the resulting image has some transparent regions (rectangles).
Now, given that this image has to be blended with another one (which is indeed a previous snapshot of the same input), what approach would you recommend: A) Use several [rectangle]s on a plane, get a snapshot of the framebuffer and put it into a texture B) manipulate the camera input as pix, or as texture, and compose a bigger pix, so only at the very end, for displaying, you would use a rectangle ?
Thanks m.
Matteo Sisti Sette escribió:
A) Use several [rectangle]s on a plane, get a snapshot of the framebuffer and put it into a texture B) manipulate the camera input as pix, or as texture, and compose a bigger pix, so only at the very end, for displaying, you would use a rectangle ?
Hmmmm I can't seem to find any pix_ object that would help building the (B) approach. Isn't any of the following possible??? - create an "empty" image of a given size (so that yoy can then draw on top of it.... for example [pix_rectangle] draws a filled rectangle on an existing pix, so it seems to me quite strange that you can't create an empty pix: do you have to load an empty image into a [pix_image]?) - "join" two pixes of the same size (or at least with one dimension in common) by "concatenating" them either horizontally or vertically - "print" a (presumably smaller) image on top of a (presumably bigger) one, i.e. fill a region of a pix with the pixels taken from another pix, starting at a given offset point
Obviously the second function could be implemented in terms of the first and third.
Hi,
I realized that a recent thread was about something very similar to what I need to do right now (the thread was "way to get gemframebuffer back onto main memory for pix_operations")...
The ultimate question for me is: how do I take a [pix_texture] and get the "image" again into a pix so I can pass it to any pix_ object??
Jack proposed [pix_share_write] and [pix_share_read] but that does not work on windows. Is that the only way to get a texture content back to memory? There must be a way other than shared memory, indeed I don't need to "share" that memory with anyone at all....
Isn't there any "inverse [pix_texture]" object??
Oh sh@#*, [pix_snap] seems to be the answer, isn't it!!!
Matteo Sisti Sette escribió:
Hi,
I realized that a recent thread was about something very similar to what I need to do right now (the thread was "way to get gemframebuffer back onto main memory for pix_operations")...
The ultimate question for me is: how do I take a [pix_texture] and get the "image" again into a pix so I can pass it to any pix_ object??
Jack proposed [pix_share_write] and [pix_share_read] but that does not work on windows. Is that the only way to get a texture content back to memory? There must be a way other than shared memory, indeed I don't need to "share" that memory with anyone at all....
Isn't there any "inverse [pix_texture]" object??
Hi,
I realized that a recent thread was about something very similar to what I need to do right now (the thread was "way to get gemframebuffer back onto main memory for pix_operations")...
The ultimate question for me is: how do I take a [pix_texture] and get the "image" again into a pix so I can pass it to any pix_ object??
Jack proposed [pix_share_write] and [pix_share_read] but that does not work on windows. Is that the only way to get a texture content back to memory? There must be a way other than shared memory, indeed I don't need to "share" that memory with anyone at all....
Isn't there any "inverse [pix_texture]" object??
Yes, its name is [pix_snap] ;) ++
Jack
-- Matteo Sisti Sette matteosistisette@gmail.com http://www.matteosistisette.com
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Matteo Sisti Sette wrote:
Hi,
Now, I don't know if this is possible at all.
Suppose I have a [rectangle] (or whatever primitive indeed) with a texture, and something behind the rectangle. Is it possible to have the rectangle "blend" with the background with some blending mode (such as add, multiply, etc)? (without having to render all the rest of the scene except the rectangle into a texture via gemframebuffer, and then blending the two textures with pix_add and friends)???
there's [env $1( (with $1=0..5 or so) to [pix_texture] which will give you a number of different blending modes.
there's a bug in the released versions of Gem, that will set the blending mode for all texture blendings. so you might want to reset it after you changed it. should be fixed in svn/trunk.
then you can (in a very limited way) change the general blending function (no tex involved) by sending a number to the 2nd inlet to [alpha]. if you want more control, use [GEMglBlendFunc] (and get a copy of the openGL red book to see what it does and what you can do)
Isn't it a matter of shaders? I guess it could be achieved using openGL functions... but is there a "simple" way?
that will give you all the flexibility in the world.
fgamsdr IOhannes
IOhannes m zmölnig escribió:
there's [env $1( (with $1=0..5 or so) to [pix_texture] which will give you a number of different blending modes.
I have tried, but I see no difference between values 0,1,2,4,5, a part a one-pixel white border in some case; and with 3 I get an all-white image (or no texture) (and the background is not white)....
am I missing something?
I wasn't completely compensating for the bug, but even now that I am, I can obtain - normal blending (i.e. no blending) - all white (dunnwo what this is supposed to be) - inverted opaque texture (still no blending)
No additive nor subtractive nor any kind of blending at all....
Matteo Sisti Sette escribió:
IOhannes m zmölnig escribió:
there's [env $1( (with $1=0..5 or so) to [pix_texture] which will give you a number of different blending modes.
I have tried, but I see no difference between values 0,1,2,4,5, a part a one-pixel white border in some case; and with 3 I get an all-white image (or no texture) (and the background is not white)....
am I missing something?
Btw now I see in the documentation it says "env" is for "texture environment mode" and I don't know what it means but the options don't sound like blending modes the way I understand them (i.e. ways of blending with the background).......
Matteo Sisti Sette escribió:
I wasn't completely compensating for the bug, but even now that I am, I can obtain
- normal blending (i.e. no blending)
- all white (dunnwo what this is supposed to be)
- inverted opaque texture (still no blending)
No additive nor subtractive nor any kind of blending at all....
Matteo Sisti Sette escribió:
IOhannes m zmölnig escribió:
there's [env $1( (with $1=0..5 or so) to [pix_texture] which will give you a number of different blending modes.
I have tried, but I see no difference between values 0,1,2,4,5, a part a one-pixel white border in some case; and with 3 I get an all-white image (or no texture) (and the background is not white)....
am I missing something?
Ohhhhhhh, ok!!!
[env ( is the way the texture blends with the color of the survace (i.e. the one set by [color])!!! That's useless to my purpose: by blending mode I meant the way the object (with its resulting color however it results from its color and rexture) blends with its background
At the end I think I'll use glsl: with a very small and trivial modification to the "multitexture" example I've been able to add/multiply/subtract two textures, so I'll use that to blend a [framebuffer]ed image with another one as textures.
Send us the patch ! ;) ++
Jack
Le dimanche 29 novembre 2009 à 02:01 +0100, Matteo Sisti Sette a écrit :
Ohhhhhhh, ok!!!
[env ( is the way the texture blends with the color of the survace (i.e. the one set by [color])!!! That's useless to my purpose: by blending mode I meant the way the object (with its resulting color however it results from its color and rexture) blends with its background
At the end I think I'll use glsl: with a very small and trivial modification to the "multitexture" example I've been able to add/multiply/subtract two textures, so I'll use that to blend a [framebuffer]ed image with another one as textures.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Matteo Sisti Sette wrote:
Ohhhhhhh, ok!!!
[env ( is the way the texture blends with the color of the survace (i.e. the one set by [color])!!!
ah right. that answer was late at night...
That's useless to my purpose: by blending mode I meant the way the object (with its resulting color however it results from its color and rexture) blends with its background
yep. you should be able to control this on low level with [GEMglBlendFunc] and [GEMglAlphaFunc]
At the end I think I'll use glsl: with a very small and trivial modification to the "multitexture" example I've been able to add/multiply/subtract two textures, so I'll use that to blend a [framebuffer]ed image with another one as textures.
well, if you only want to change the blending between a surface and the background, then you should be able to do this without [gemframebuffer],
but then you would have to re-implement the default fragment shader which is probably not worth it.
i wonder why i miss something like ftransform() for fragment shaders.
fgamr IOhannes
mfasr IOhannes
IOhannes m zmölnig escribió:
by blending mode I meant the way the object (with its resulting color however it results from its color and rexture) blends with its background
yep. you should be able to control this on low level with [GEMglBlendFunc] and [GEMglAlphaFunc]
Great, I'll try to investigate these ones, thanks!
Le dimanche 29 novembre 2009 à 12:07 +0100, IOhannes m zmölnig a écrit :
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Matteo Sisti Sette wrote:
Ohhhhhhh, ok!!!
[env ( is the way the texture blends with the color of the survace (i.e. the one set by [color])!!!
ah right. that answer was late at night...
That's useless to my purpose: by blending mode I meant the way the object (with its resulting color however it results from its color and rexture) blends with its background
yep. you should be able to control this on low level with [GEMglBlendFunc] and [GEMglAlphaFunc]
Sometimes the solutions are very simple, we just need a simple OpenGL function :) I have started to read the Red Book there is few month ago, i have to finish it ! I have done this patch, is it correct to use different blend modes ? ++
Jack
At the end I think I'll use glsl: with a very small and trivial modification to the "multitexture" example I've been able to add/multiply/subtract two textures, so I'll use that to blend a [framebuffer]ed image with another one as textures.
well, if you only want to change the blending between a surface and the background, then you should be able to do this without [gemframebuffer],
but then you would have to re-implement the default fragment shader which is probably not worth it.
i wonder why i miss something like ftransform() for fragment shaders.
fgamr IOhannes
mfasr IOhannes
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAksSVfoACgkQkX2Xpv6ydvQL4gCeKrTEJ4xH5k3mqZeTpxwyB43P 2B8AoO7iI3pCXLV51RbeKwo+3RXtPo3o =7lWh -----END PGP SIGNATURE-----
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
i forgot the patch. ++
Jack
Le dimanche 29 novembre 2009 à 15:41 +0100, Jack a écrit :
Le dimanche 29 novembre 2009 à 12:07 +0100, IOhannes m zmölnig a écrit :
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Matteo Sisti Sette wrote:
Ohhhhhhh, ok!!!
[env ( is the way the texture blends with the color of the survace (i.e. the one set by [color])!!!
ah right. that answer was late at night...
That's useless to my purpose: by blending mode I meant the way the object (with its resulting color however it results from its color and rexture) blends with its background
yep. you should be able to control this on low level with [GEMglBlendFunc] and [GEMglAlphaFunc]
Sometimes the solutions are very simple, we just need a simple OpenGL function :) I have started to read the Red Book there is few month ago, i have to finish it ! I have done this patch, is it correct to use different blend modes ? ++
Jack
At the end I think I'll use glsl: with a very small and trivial modification to the "multitexture" example I've been able to add/multiply/subtract two textures, so I'll use that to blend a [framebuffer]ed image with another one as textures.
well, if you only want to change the blending between a surface and the background, then you should be able to do this without [gemframebuffer],
but then you would have to re-implement the default fragment shader which is probably not worth it.
i wonder why i miss something like ftransform() for fragment shaders.
fgamr IOhannes
mfasr IOhannes
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAksSVfoACgkQkX2Xpv6ydvQL4gCeKrTEJ4xH5k3mqZeTpxwyB43P 2B8AoO7iI3pCXLV51RbeKwo+3RXtPo3o =7lWh -----END PGP SIGNATURE-----
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
Jack escribió:
i forgot the patch.
Excellent (as Miller would say... or Mr Burns) That's exactly what I was trying to do.
I thought I could simply send [symbol GL_BLEND( (and other constant names) to the GL objects. Also, I was missing the necessary [alpha] object.
By the way, in your patch, I thing in the left "column" of [GLdefine]s, those which go to the _source_ factor inlet, you should replace GL_SRC_* with GL_DST_*, ¿no?
Thanks a lot for the patch
By the way, it seems to me that with this approach I can achieve: - additive blending (by setting both sfactor and dfactor to GL_ONE) - multiplicative blending (by setting for example sfactor=GL_ONE and dfactor=GL_SRC_COLOR)
but NOT for example subtraction or difference... or am I missing something?
Jack escribió:
i forgot the patch. ++
Jack
Le dimanche 29 novembre 2009 à 15:41 +0100, Jack a écrit :
Le dimanche 29 novembre 2009 à 12:07 +0100, IOhannes m zmölnig a écrit :
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Matteo Sisti Sette wrote:
Ohhhhhhh, ok!!!
[env ( is the way the texture blends with the color of the survace (i.e. the one set by [color])!!!
ah right. that answer was late at night...
That's useless to my purpose: by blending mode I meant the way the object (with its resulting color however it results from its color and rexture) blends with its background
yep. you should be able to control this on low level with [GEMglBlendFunc] and [GEMglAlphaFunc]
Sometimes the solutions are very simple, we just need a simple OpenGL function :) I have started to read the Red Book there is few month ago, i have to finish it ! I have done this patch, is it correct to use different blend modes ? ++
Jack
At the end I think I'll use glsl: with a very small and trivial modification to the "multitexture" example I've been able to add/multiply/subtract two textures, so I'll use that to blend a [framebuffer]ed image with another one as textures.
well, if you only want to change the blending between a surface and the background, then you should be able to do this without [gemframebuffer],
but then you would have to re-implement the default fragment shader which is probably not worth it.
i wonder why i miss something like ftransform() for fragment shaders.
fgamr IOhannes
mfasr IOhannes
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAksSVfoACgkQkX2Xpv6ydvQL4gCeKrTEJ4xH5k3mqZeTpxwyB43P 2B8AoO7iI3pCXLV51RbeKwo+3RXtPo3o =7lWh -----END PGP SIGNATURE-----
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
Errata corrige:
Matteo Sisti Sette escribió:
- multiplicative blending by setting for example sfactor=GL_ONE and
dfactor=GL_SRC_COLOR
I meant sfactor=GL_ZERO
However the question remains:
but NOT for example subtraction or difference... or am I missing something?
Jack escribió:
I have done this patch, is it correct to use different blend modes ?
Errrrr.... which patch?
IOhannes m zmölnig escribió:
yep. you should be able to control this on low level with [GEMglBlendFunc]
It seems I must first enable blending using glEnable, that is, I guess, [GEMglEnable]
Having a look at this link http://pyopengl.sourceforge.net/documentation/manual/glEnable.3G.html (there are probably better resources but I found this one with google), I understand I have to send it (through the right inlet I guess) a value that corresponds to the constant GL_BLEND, which is the "capability" I need to enable.
Now the question is (and it extends to all [GEMglAnything] objects): how do I pass these constant values? I guess I cannot use symbolic names, can i? If not, then I need to figure out the corresponding numeric value??? Where do I find them? (they are usually intentionally not disclosed in most documentation...)
Another question: once I figure out how to enable blending and set the proper blending function, will I be able to enable it "under" a [gemframebuffer] only? (that is, so that things that are under that gemframebuffer are rendered using a blend function while chains "outside" the gemframebuffer, rendered directly to the gemwin, are rendered in the standard non-blending fashion)
Thanks m.
Matteo Sisti Sette escribió:
Now the question is (and it extends to all [GEMglAnything] objects): how do I pass these constant values? I guess I cannot use symbolic names, can i?
Ohhh great, it seems the answer is "Yes you can"!!
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Matteo Sisti Sette wrote:
(without having to render all the rest of the scene except the rectangle into a texture via gemframebuffer, and then blending the two textures with pix_add and friends)???
and don't do that if you can avoid it. uses shaders if possible.
fgm asr IOhannes