Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Triangle gradient with vertex array

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2013
    Posts
    4

    Triangle gradient with vertex array

    Hello,

    I'm trying to make a triangle like the one in the right in the following picture:

    Click image for larger version. 

Name:	yOrs1NR.jpg 
Views:	204 
Size:	31.4 KB 
ID:	1009

    The problem is that what I want to achieve is a gradient of color from vertexes 1 and 2 proyected from C.

    As far as I know this is not possible since vertex C must have a color on it's own, which will also blend into 1 and 2's colors, like in the left triangle of the picture.
    If I set C to a middle point color, this generates an undesired result, since the taller the triangle is made, the less noticiable are the other vertex's colors.

    Line C1 should be black, and line C2 should be white.

    Is there any way to achieve this in OpenGL?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,105
    You use a shader and texture coordinates, set the u coordinates to 0 at 1, 1 at 2, and 0.5 at C, then manually blend the 2 colours based on the value of u

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •