Could someone please help me bridge a gap in my opengl knowledge (which at this point is not much). I have an 8 by 3 color gradient, 8 levels with rgb settings. I bind this texture to a name. I am using quads and I want to do 1d texturing. First of all if the quad should show the 4th, 5th and 6th colors in my texture, how does this get translated to my quad.
A quad is four points how do you translate the portion of the texture to the four points.
I am iterating thru points on an height map and need to do this for every quad. Right now this works great with glcolor3f but I get to have a color gradient. If anyone has an example to do a height map using 1d texturing with quads that would be wonderful, or just explain to me how to do it.
Haven’t ever actually used 1D textures but AFAIK things look like this:
1D textures are normal textures with the exception that their high is always 1.Therefore they only have on dimension(along the x axis) or in other words consist of a single line of pixels.Other than that things are the same as in 2D textures.A texture coordinate of 0 maps to the first pixel,1 maps to the last,0.5 is the center etc.
If you want to see things more clearly(as they really are) don’t think of textures as pictures which you put on your geometry.All they are are lookup tables with colors.The textures coordinates are used to get an index into the table.2D tables require two coords,1D tables just one.
So if you want to paint all the pixels according to their height,just load a gradient(in a single line of pixels) and calculate a texture coord based on the height.To make it more clear:say height ranges from 0 to zmax and texcoords range from 0 to 1.As you might have guessed to get a coordinate out of the height z you do this:
After you have that working try usig texgen.Good luck.
PS:If you mean that your texture is 8x3 in size then it isn’t 1D.Read the gl specs regarding 1d texturing for more detail.