#### Archived

This topic is now archived and is closed to further replies.

# Trying to recreate negative blending effect.

This topic is 5436 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I''m kinda new to opengl so lemme know if this is something I should have gone across in the NeHe tutorials. I''m trying to recreate the negative sphere used in Final Fantasy X. They were used for any number of visual spell effects. It was a sphere that grew in size, sometimes there were particles sometimes not. But the main effect I''m after is making anything behind it invert in color. Or more specifically invert the hue, I want the luminosityto remain constant. And if possible I want anything inside the sphere to remain correctly colored. The inversion is the main oal and I''ll be happy with that. If anyone can gimme a hint I''d be grateful. --Toodles

##### Share on other sites
I''ve never played FFX so I''m not sure what do you actually want. But if you want to invert a color of a pixel... I''ll use an example of a pixel with 3 channel(RED, GREEN, BLUE) of GLubyte....
to invert it just substract each channel with 255(largest value of GLubyte is 255)...for example RED = 255-RED, GREEN = 255-GREEN and BLUE = 255-BLUE. To invert an image color you have to go to every pixel of the image.

If you want to apply an effect to a certain area of the screen I suggest to use the stencil buffer..(since that is the only method that I know).

##### Share on other sites
What you need to do is to draw the backfaces of a White sphere
while blending it with this blend fuction(i think, if not then start experimenting)

glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR);

[edited by - lc_overlord on January 29, 2003 3:37:05 PM]

##### Share on other sites
lc_overlord: the idea is that, except that I''d rather use : glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO)

ctoa: the stencil buffer is not needed for convex models such as spheres, when used in cunjunction with backface culling. But for concave models, either stencil buffer or multipass depth buffer is needed otherwise some pixels will be inverted twice, thus resulting in non-inverted pixels !

sirrandom: btw you can not really work on *hue* because it would need to transfert pixels from a channel to another which really a pain in the @ in OpenGL. Solutions exist, but are either not realtime-oriented or need rarerly powerful hardware (that even GeForce or Radeon can not perform!)