I need to fill a triangle, but i do not want to use the method supplied by opengl, which is: specify a color value of the vertex and put the pixel, opengl will do all the things. My problem is that: if i have specified the color of each three vertex, i need to fill the inner part use my own color table, say 1024 color entries. For example, if vertex 1 is color 012, vertex is color 500, then i need to fill the pixel between them using the color from 012 to 500 in my color table, not the one that calculated by opengl. how can i implement it?
Sounds like an ideal solution is using color index mode rather than rgba mode. Don’t know if you can get an index buffer that big however. I’ve never used color index mode so my knowledge of it is very fuzzy.
Color index is not well supported in hardware cards. In fact , I dont know a single one that does support it (maybe some old Sun or SGIs).
Instead of defining colors at the vertices, define texcoords and use a 1D texture as a lookup to a palette of yours, coded in the texture.
Ah yes, a 1D texture, perfect solution! I totally forgot about 1D textures.
and wilder effects could be achieved with 2D textures i guess…
Wow, it could get even wilder with 3d textures…
Yo michael, thats true! You can posibly achieve pretty psycodelic effects, that’s for shure.
Now being serious, you could do some kind of true color mapping with a 3d texture as a 3d lookup space (instead of a color index with 1D), having a 3d texture where texcoords u v and w are mapped to a different color space than rgb, which you define in the texture texels. I guess you can make someone vomit with such tools.
Actually I am not an advanced opengl programmer as you are, so can somebody please tell me exactly how to apply a 1D texture on a triangle, and the problem is that do i need to change the texture when rendering? because the color transition from vertext to vertex is different, so what should i do? Most the tutorial i found only focus on 2D textures, so i am even not familiar with 1D texture. Can somebody suggest me some on 1D? By the way, is this method fastest?
> and the problem is that do i need to change the texture when rendering? because the color transition from vertext to vertex is different, so what should i do?
If you need to change it frequently - then it’s better to use 2D texture as an array of 1D textures.
In this way you’re using one texture coordinate as a position in the color table, and another - as index in the array of color tables.