Want good color interpolation for my square
I have a square, with all the vertices having different colors varying at runtime.
Normal Opengl has this problem with doing nice color interpolation for a square, it splits it up in 2 triangles and there are some issues with this.
What I would like is bilinear interpolation, which is pretty simple in theory, you get the colors of the vertices pixels, do the weighted average on the x axis, then on the y axis and you're done.
I am a noob with shaders so before I get into it, is this possible to do with shaders? I know opengl works with triangles at a basic level, here I would need the colors of all 4 vertices of the square to find out the color of each pixel...
Any guidance appreciated.
Normal Opengl has this problem with doing nice color interpolation for a square, it splits it up in 2 triangles and there are some issues with this.
What I would like is bilinear interpolation, which is pretty simple in theory, you get the colors of the vertices pixels, do the weighted average on the x axis, then on the y axis and you're done.
I am a noob with shaders so before I get into it, is this possible to do with shaders? I know opengl works with triangles at a basic level, here I would need the colors of all 4 vertices of the square to find out the color of each pixel...
Any guidance appreciated.
Â©hâ‚¬ck Ã¸ut Âµy stuÆ’Æ’ Ã¥t ragdollsoft.com
New game in development Rubber Ninjas  Mac Games Downloads
Thanks OSC, though I didn't manage to understand how the link helped or how to do it with shaders.
However, i found out a simple way to smooth out a grid of colored points is to pass the points colors to a texture, then enlarge the texture as needed, it gets linearly interpolated automatically, looks good and is also pretty fast.
I'm pretty sure this is the way apple does it's screensaver, it uses a relatively small grid of points on which it does its color calculations, then passes to a texture and scales up. This works better than "smooth" quads with different vertices colors, as it automatically interpolates bilinearly and avoids the "2 triangles" issue.
However, i found out a simple way to smooth out a grid of colored points is to pass the points colors to a texture, then enlarge the texture as needed, it gets linearly interpolated automatically, looks good and is also pretty fast.
I'm pretty sure this is the way apple does it's screensaver, it uses a relatively small grid of points on which it does its color calculations, then passes to a texture and scales up. This works better than "smooth" quads with different vertices colors, as it automatically interpolates bilinearly and avoids the "2 triangles" issue.
Â©hâ‚¬ck Ã¸ut Âµy stuÆ’Æ’ Ã¥t ragdollsoft.com
New game in development Rubber Ninjas  Mac Games Downloads
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
? Find color value of 'pixel' in color buffer?  Elphaba  1  5,222 
Jul 22, 2009 01:23 PM Last Post: Bachus 

Trying to make a square... there's a triangle!  TimMcD  4  4,588 
Jun 2, 2009 03:41 PM Last Post: AnotherJake 

texture no square surface  kendric  7  6,144 
Mar 20, 2009 05:26 PM Last Post: kendric 

Nonsquare, nonPOT, hardwareaccelerated surfaces...  NekoYasha  13  6,935 
Oct 25, 2005 03:06 PM Last Post: NekoYasha 

Nonsquare textures in OS X OpenGL  tigakub  18  8,832 
Apr 1, 2005 01:29 PM Last Post: arekkusu 