vertex attribute interpolation

Started by
0 comments, last by JackTheRapper 15 years, 2 months ago
Hi, I am doing image based rendering 3d warping for my project. The reference image is treated as a triangle mesh (2d) and each triangle vertex is warped by using a warping equation. During warping there are other two float values generated for each vertex. As I have the new position and color at each warped vertex afterwards, I can let opengl draw the 2d triangles and interpolate colors in each triangle. However I don't know how to make opengl interpolate those float values. I can abuse alpha channel to interpolate one of the two by doing glColor4f(r, g, b, some float value), this float value is between 0 and 2. As a test I read pixels after calling draw function, and output the interpolated float value. It's either 0 or 255. Can someone tell me why? I will do one more pass to interpolate the other float value, that's the solution so far. I will move on to vertex shader after I can get this run. Thank you, Shanshan
Advertisement
I use tex coords form a spare texture stage on my GPU to pass data between vertex and fragment shader. It works (interpolates... ticking all the boxes so far) but am not sure if it's the most ideal solution... all the nVidia CG examples do it, but I'd like there to be a better approach as I am unsure whether using tex coords for, stage X will work if the target GPU doesn't support tex stage X (i,.e. only 4 stages or something, and X > 4).

Bear in mind u can pass up to 4 components for tex coords, so u could use stage one's coords even if they're already used for actual tex coords: pass a 2 component tex coord to the vertex shader and pass it onto the fragment shader as a 4 component tex coord. Pick out the original 2 components 4 texture lookups and use the other 2 as u desire, safe in the knowledge that they will be interpolated for each fragment. I could well be doing it wrong though :D

This topic is closed to new replies.

Advertisement