LWJGL Forum

Programming => OpenGL => Topic started by: awesomelemonade on November 27, 2015, 22:09:41

Title: Color Interpolation
Post by: awesomelemonade on November 27, 2015, 22:09:41
Hi, I have a simple question: Why aren't my colors interpolating? (gradient)

I've been trying to solve this all day, and even wrote a bare-bone code, and it still doesn't work.

Here is the relevant code: http://hastebin.com/bebicizata.avrasm
Shaders: http://hastebin.com/exaledifoz.avrasm

Result: http://imgur.com/DVTlRQI
What I want: a gradient between the colors of red, green, and blue.


Thanks in advanced,
Lemon
Title: Re: Color Interpolation
Post by: Kai on November 27, 2015, 22:32:11
If you look closely at the rendered image especially at the edges of the triangle you see that it does interpolate.
It's just that your color values are far outside the range of valid values [0..1]. You use 255 as the largest value.
Everything above 1.0 (which is the max value of a color component) will be clamped to 1.0.
A value of 255, as seen in many libraries/APIs, is only necessary when storing colors using integral numeric type, such as byte or int, as opposed to a floating-point type as used by OpenGL.
Title: Re: Color Interpolation
Post by: awesomelemonade on November 28, 2015, 02:04:25
I knew I was doing something dumb xD


Thanks :)