Jump to content
  • Advertisement
Sign in to follow this  
shanshanzg

OpenGL vertex attribute interpolation

This topic is 3550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!