Jump to content
  • Advertisement
Sign in to follow this  
alireza.pir

OpenGL OpenGL-keep track of texture shape

This topic is 972 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

I have a Rectangle with a texture bind to it like this:

F3YhU.png

(black dashed line around the rectangle is Not drawn On the scene and i just draw it to show the rectangle which the texture is on It)

I want to somehow keep track of this texture Polygon that is drawn on the rectangle.(the rest of texture except the blue part is transparent) and check if it fits a polygon that its vertices are Specified(For Example the white dashed shape)

Should I Use Image Processing to achieve this? I want to do this dynamically because my texture on the rectangle changes every frame from FBO, so it shouldn't be Expensive.

How can i do that? (Just an Idea of it)

Share this post


Link to post
Share on other sites
Advertisement
If you have the triangle list used to render the shape, I would just solve it by comparing the shape data, not by checking the final visual rendering of the shape. It would be faster and more accurate.

Share this post


Link to post
Share on other sites

i dont quite understand what are you trying to achieve but you could use transform feedback (draw first the white shape) then blue shape on top of it (you compare pixels and output the data via tfb) then process results on cpu

Share this post


Link to post
Share on other sites

i dont quite understand what are you trying to achieve but you could use transform feedback (draw first the white shape) then blue shape on top of it (you compare pixels and output the data via tfb) then process results on cpu

 

Im trying to make an origami like game, and i want to know does the texture on the rectangle fits my Known shape or not, and rate the user if it does.

 

thanks for your reply, but i didn't get what should i do, could you please give me some link to get the way?

Share this post


Link to post
Share on other sites

Interesting idea you have there, the image you posted looks appealing too, I like the style.

 

If I understand this correctly you should draw both textures (the user's and your own) onto another frame buffer/texture by combining them using XOR. You could do this using the alpha channel of the texture assuming the alpha is either 0 or 1 using a simple shader. If the values of the textures are different (one is 1, the other 0 or vice-versa) then you color the pixel on your 'checking' texture that you are creating otherwise you leave it black. That should then give you a sort of error mask with the parts that are different/wrong being colored in. You just have to count up the pixels that are colored and that should give you an error value (0 would be perfect) but how far off they are will depend on the size and resolution of your texture.

 

In the above image you would end up with a big black texture with the blue part being white except for where the blue and the white inner shape overlap (that would also be black).

Edited by Nanoha

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!