Want good color interpolation for my square

Member
Posts: 749
Joined: 2003.01
Post: #1
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.

[Image: 180px-Bilininterp.png]

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
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Yes, you can do it with shaders, but you may not need to.

http://www.r3.nu/~cass/qcoord/
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #3
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.

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  ? Find color value of 'pixel' in color buffer? Elphaba 1 4,492 Jul 22, 2009 01:23 PM
Last Post: Bachus
  Trying to make a square... there's a triangle! TimMcD 4 3,865 Jun 2, 2009 03:41 PM
Last Post: AnotherJake
  texture no square surface kendric 7 4,539 Mar 20, 2009 05:26 PM
Last Post: kendric
  Non-square, non-POT, hardware-accelerated surfaces... NekoYasha 13 5,840 Oct 25, 2005 03:06 PM
Last Post: NekoYasha
  Non-square textures in OS X OpenGL tigakub 18 7,878 Apr 1, 2005 01:29 PM
Last Post: arekkusu