OpenGL-keep track of texture shape

Started by
3 comments, last by Nanoha 8 years, 5 months ago

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)

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.
My current game project Platform RPG

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

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?

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).

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

This topic is closed to new replies.

Advertisement