PDA

View Full Version : Blending paint again



JamesP
05-10-2001, 01:29 AM
Further to my question regarding paint type blending, can I use glBlendFunc() to do the blending?

I'm still not convinced about CMY blending. I always thought that the primary paints were Red, Blue and Yellow. What I want is something that works like paints do, as opposed to coloured filters.

I accept that a blue and yellow filter placed together transmit no light, ie black, but blue and yellow paint mixed doesn't make black (not where I come from anyway http://www.opengl.org/discussion_boards/ubb/smile.gif )


Hope someone can set me straight here!

Jim

Hull
05-10-2001, 05:50 AM
I have the same problem.

The RGB method seems all wrong when it comes to blending colors to produce real world results.

Using RGB you will get the most contrast out of the triplet, because human eyes are more perceptible to green. But this has resulted in cartoon like colors instead of a nice real world shade of grey and bluish brown.
( Must be achieved with specific texturing and lighting )

The RGB blending is a good choice for maximising color output, but we really should have an OpenGL method of using RYB if we want to. (Is there a OGL way?)

RGB blending
Blue + Green = Yellow ?? Uekk.
Yellow + Blue = Cyan?
Green - blue = (0,1,-1)??
Green - Yellow = (0,1,0) - (0,1,1) = (0,0,-1)?

RYB blending
Blue + Green = Bluish green (0,1,2) = (0,0.5,1)
Yellow + Blue = Green (0,1,1)
Green - blue = Yellow (0,1,0)
Green - Yellow = blue.(0,0,1)

And so on.
(Correct me if I am wrong)

JamesP
05-10-2001, 05:59 AM
RGB blending

these should be:

Blue + Green = Cyan
Yellow + Blue = White (Red+Green=Yellow)


Green - blue = (0,1,-1)??
Green - Yellow = (0,1,0) - (0,1,1) =(0,0,-1)?

Not sure what you're trying to do here. http://www.opengl.org/discussion_boards/ubb/confused.gif

Jim

Hull
05-10-2001, 06:08 AM
Yes, thanks on the RGB blending.

Well the operations:

Green - Blue = Yellow
and
Green - Yellow = Blue

Is the real world subtraction of colors,
the reverse order of blending yellow and blue to get green.

This is important when trying to implement real world blending of colors.

As for now, I think I have to write my own color functions that does this in RGB mode.

------
Actually, if you treat the negative blue component as a mirror of the positive red component, you can achieve the correct blending.
RGB
Green - Blue = (0,1,-1) -> (1,1,0)
Green - Yellow = (-1,0,0) -> (0,0,1)

[This message has been edited by Hull (edited 05-10-2001).]

[This message has been edited by Hull (edited 05-10-2001).]

Hull
05-10-2001, 09:17 AM
Sorry for screwing up all those color calculations, I am actually thinking about multiple color schemes all at once.

My own implementation is just trying to produce real world blending by treating blue and red as eachothers inverses:

Blue + Yellow = Green (in real world)

Achieved by interpret blue as the inverse color = negative red.

(-1,0,0) + (1,1,0) = (0,1,0)

http://www.opengl.org/discussion_boards/ubb/redface.gif

[This message has been edited by Hull (edited 05-10-2001).]

Hull
05-11-2001, 06:05 AM
This is how I want my colors to blend:
http://www.virtualchurchill.com/eddie/games/lightbox4/lb4colors.htm

bsenftner
05-11-2001, 06:38 AM
It looks to me like you want to use subtractive color mixing (the mixing of pigments) rather than additive color mixing (the mixing of colors of light.)

Here's a java applet I found that lets you switch between the two mixing types: http://www.phy.ntnu.edu.tw/~hwang/image/rgbColor.html

I don't really know much beyond that, but the above java applet I got from a www.google.com (http://www.google.com) search, searching on "paint color mixing". I'm sure that within a 30 minutes or less of searching you'd be able to locate the math/logic/settings to achieve this on your own. I also just found quite a bit with a search using "additive color mixing opengl".

Hope that helps.
-Blake

Hull
05-11-2001, 09:43 AM
Yeah, well its not the RGB blending that bothers me, its that I want to blend using the real primary colors of Green Yellow and Blue. Not Cyan, Magenta and Yellow.

I dont want my polygons to interpolate between yellow and blue , producing white, but I want yellow and blue to interpolate so that the they produce green.

Using CMY just doesnt cope it. The colors are all wrong.

Is there a way for me to tell GL to blend from Yellow to Blue creating green instead of white, without using the CMY approach.

Or am I completely wrong in saying that Yellow and Blue mix into green in real world?

Sorry about all this fuzz about colors :P

ET3D
05-11-2001, 12:13 PM
I gave it some thought and research, but I'm still stumped. You can check out http://www.csulb.edu/~percept/kyotocolor.html and http://www.csulb.edu/~percept/imaging99.html for some interesting discussion of colours, including RYB vs. RGB. It still didn't help me get to a conclusion of how RYB works. It's a fascinating subject, but I hope that you'll forgive me if I don't continue researching it.

BTW, I think that most of the online examples of RYB aren't correct. You just can't get light green from blue and yellow. You get dark green, since blue is much darker than green. Light blue is actually (in RGB) blue with a lot of green - RGB(0,0.5,1) and even RGB(0,0.8,1). It really starts feeling like cyan only when green is almost saturated.

The difficulty for me in concluding anything from such observations is that the colour scales (intensities) aren't linear, so I can't really compare 0.5 and 0.8 values for green - the latter is not "60% brighter" but actually more than twice as bright. This non-linearity means that I can't really think of RYB and CMY as two bases for the same linear space, which would likely have helped draw some conclusions.

Hull
05-11-2001, 12:41 PM
I know what you are up against, I have been trying to find solutions to this for many days now, without finding anything but the statement that 'we use Red Green and Blue as primary colors'.

I will give this up for now aswell, and revert to careful texturing and controlled lighting, because lets face it, you just cant alter the way video graphics have been manufactured.

But one of these days, RGB wont suffice for real time rendering anymore, because of the problems with color blending as described. But thats way in the future, and then we are probably using quaternions instead of RGB pixels. (ColorShperes).

http://www.opengl.org/discussion_boards/ubb/smile.gif
---
Oh, and that article about Green being White, is pure nonsense, the guy is trying to use the false, RGB method to explain hue in the RYB spectra. He places white between blue and yellow because there is where green will emerge, whereas in the RGB method, white will emerge. RGB vs RYB is simply a matter of which color goes to what axis.
I would, as an artist, prefer RYB. But that seems just to be a dream.



[This message has been edited by Hull (edited 05-11-2001).]

ET3D
05-12-2001, 02:43 AM
Hull, I don't think that "RGB vs RYB is simply a matter of which color goes to what axis". If this was true, then RGB and RYB would be equivalent representations of the same colour space, which they aren't. RYB can produce more limited colours than RGB. The axis representation is more a convenience than a mathematical description of colour, IMO.

About the "green is white" article, I do think he's got a point, even though I think he got carried away a little. At least in RGB, green contributes more to brightness than red and blue combined. Light blue in RGB is actually more green than blue (in terms of brightness, not RGB value). So there seems to be some value to this observation.

[This message has been edited by ET3D (edited 05-12-2001).]

LordKronos
05-13-2001, 10:54 AM
One thing to take into consideration which may help is the concept of dilluting(sp). When you have pure blue paint, it absorbs all of the red and yellow. Now, if you add an equal amount of white paint to it, you still have the same amount of blue pigment, but it is spread out half as thin so it absorbs less red and yellow photons than pure blue paint would, giving you light blue. Likewise, adding an equal amount of black paint to blue would provide the same density of red and yellow absorbing pigments, but would add some blue absorbing pigments, giving a dark blue.

ET3D
05-13-2001, 11:37 AM
Thinking of what LordKronos is saying, I'm starting to really believe in that "white is green" (or is it "green is white" :) stuff.

In RGB, you take blue, add green and you get light blue. Similarly, you take red+blue (violet), add green and you get pink.

Maybe there's something to be learned from this.

Hull
05-13-2001, 05:42 PM
You might be right, Lord of the Time.

That's it.
Im taking out the prisms.

Time for some serious empirical studies.

Now how do I get that blue umbra ... http://www.opengl.org/discussion_boards/ubb/smile.gif

JamesP
05-13-2001, 11:16 PM
Thanks everyone for your input to this problem. I too am not really happy with the CMY scheme, although it may be more versatile in many ways.

At least I'm not alone in being able to figure out even an imperfect RYB blending alorithm. I'm sure there MUST be one somewhere, otherwise custom paint manufacturers must waste a lot of monet, whoops, money http://www.opengl.org/discussion_boards/ubb/smile.gif

I suppose I'll have to go for some other blend mechanism in the meantime.

Cheers,
Jim

ET3D
05-14-2001, 06:07 AM
BTW, there's something that bothered me in LordKronos' description, and that's the talk of yellow, red and blue photons. After all, what light is a combination of all wavelengths from violet to red, not just three wavelengths. Our perception combines wavelengths into colours represented by other wavelengths, for example green and red into yellow. Knowing what wavelengths a painter's colour really reflects might help in understanding the result of mixing them. Or maybe understanding how our eyes perceive colour (there's a diagram in Foley et all - not too precise, but may be worth studying) might help.

Hull
05-14-2001, 01:04 PM
Magenta sure is an interesting color.

It is a blend of red and blue (RYB method) but in the spectra of light, there is no such color, because beyond blue there is ultraviolet, and beyond red there is infra red. Magenta is therefore something like an 'open' color, and could actually be any of the colors we cannot percieve.
(I actually tried a colorcircle using 3 new colors instead of magenta, namely ultra, hypra and infra. The complement of each color then yielded magenta, instead of brown)


Blending of colors should not be represented by a 3 dimensional vector, placing 3 basic hues on each axis.
A color would rather be represented by a point within or on the surface of a ColorSphere.

All the hues, except white and black lie on the equator of the sphere surface, and there will be two poles, one black and one white.
The major hues will be placed simply by specifying a angle range from 0 to 360 for each of them. Assume red, orange, yellow, green, cyan, blue and magenta as basic hues.

To simplify the current [0.0 - 1.0] range in the 3 dimensional color of todays RGB hardware, we put the white pole at (1,1,1) and the black pole at origin (0,0,0), we would still have all the greyscales at the center axial line { (0,0,0) to (1,1,1) ).

The sphere could then be rotated around its center axis and produce color rotation for all current set color values.

We still use a 3 dimensional color value, but the colors are perfectly blended throughout the interior and the surface of the sphere, creating all possible mixes of color.

Now all we have to do is to put the hues in a specific order on the equator, and this could be USER DEFINED. Allowing us to create our own spectras.

If blending paint and blending light should be handled differently, just change the spectra.

I would love the gl_ext_colorsphere_spectra extension that would allow this.

i.e.



// Place a color on the equator
gl_ext_colorsphere_spectra(GL_SPECIFY, GL_RED, (GLfloat)angle);
// Set the default RGB spectra.
gl_ext_colorsphere_spectra(GL_SPECTRA,GL_RGB,0.0);
// Set the complement of a color.
gl_ext_colorsphere_spectra(GL_COMPLEMENT,GL_RED,(G Lfloat)angle);
// Rotate the colorsphere for the current primitives to draw.
gl_ext_colorsphere_spectra(GL_COLOR_ROTATE,GL_EQUA TOR,(GLfloat)angle);
// and so on.


Just some dreams of mine, and maybe an important part of the future.




[This message has been edited by Hull (edited 05-14-2001).]

ET3D
05-14-2001, 01:17 PM
I think that you meant to say that Magenta is blue plus red in RGB. You can't get it in RYB, nor can you get cyan (RGB blue+green). In RYB you get purple.

What you suggest about the colour sphere could possibly be done using an env map. The main problem, of course, is how to actually do the blending of these colours. You just moved the RYB blending problem to the drivers http://www.opengl.org/discussion_boards/ubb/smile.gif

Hull
05-14-2001, 01:51 PM
Exactly, and it is the drivers task to provide what we desire (and the market for craving the new cool products, and think about all that money they would make, providing the very first RYB extension. 'Maybe I will mail ATI. http://www.opengl.org/discussion_boards/ubb/smile.gif ' ).

Well, RYB in the fashion of RGB is just a way of moving the focus of Green to Yellow in the color spectra, you would still be able to create all the colors you could with RGB in RYB. The problem is that we loose some of the precision between green and blue, where the human eye is the most sensitive about hue.
So we would actually LOOSE some color by using RYB, but the gains in letting us do this would be potentially humongus.
I personally believe that using RYB would create more realistic colorblending in many cases.

Note that I actually don't know if this is doable in hardware today, due to the raygun set of blue,green and red. Maybe we need blue, yellow and red raygun hardware aswell.

It would be possible to simulate though.
http://www.opengl.org/discussion_boards/ubb/tongue.gif

ET3D
05-14-2001, 01:59 PM
I is possible to simulate, and there's even a product somewhere that does it (forgot its name). But I just wish I knew how. It's not that easy. For one, you can't really create all RGB colours in RYB, so they are not equivalent spaces. Like I mentioned before, magenta and cyan aren't in the RYB space. And the selection of RGB for the phosphors is because our eyes have receptors for these colours.

Still, it's obviously possible, since someone managed to produce software that can do it.

Hull
05-14-2001, 02:26 PM
Is there a way to rotate the colors in OGL today?

Like this:
(Red, Green, Blue) maps to (Blue, Red, Green) instead?

LordKronos
05-14-2001, 02:56 PM
Originally posted by Hull:
A color would rather be represented by a point within or on the surface of a ColorSphere...All the hues, except white and black lie on the equator of the sphere surface, and there will be two poles, one black and one white.
The major hues will be placed simply by specifying a angle range from 0 to 360 for each of them. Assume red, orange, yellow, green, cyan, blue and magenta as basic hues.


You have just described how HSL (hugh, saturation, luminance) is conceptually laid out. You may notice that HSL is the other option that you typically see in the standard "Select Color" dialog box.

LordKronos
05-14-2001, 04:12 PM
Originally posted by Hull:
Is there a way to rotate the colors in OGL today?

Like this:
(Red, Green, Blue) maps to (Blue, Red, Green) instead?



You could use register combiners to perform a vector transformation on the color per-pixel.

Hull
05-15-2001, 09:45 AM
Thanx LordKronos.

I actually didnt know about HSL, and ended up creating something that already was invented. Thats cool http://www.opengl.org/discussion_boards/ubb/cool.gif




[This message has been edited by Hull (edited 05-15-2001).]