# Undistort Projection on a cylindrical object

Hi community,

I’ve made my experiences with projecting quads to flat surfaces. No problem with that. Also matching some geometry workes fine. Now I want try something else. I want to project an image onto a punchback for boxing, and I want it to look like an undistorted image inside, and not like it’s wrapped around.

Do I need to somhow invert the z-coordinates of the real cylindrical geometry inside vvvv to undistort?

I’ve attached a beautiful masterpiece of sketch to clarify ;)

greetings,

Alex

Try to imagine the punchback’s geometry. The part to be projected on it’s basically made of tall and narrow polygons.
So if you think again, you’ll see that these polygons, if vertically cut behind the punchback and unbent, they make a plane of N regular columns\polygons and zero rows (or, better, one row).
Since you don’t need all of them, take just the half of these columns\polygons, thus representing punchback’s front face.
Since it’s a 2d plane, we can apply texture to it.
Now you’ll just need to adjust the width of the columns, and a little bit the vertices - note that this can be done symmetrically.

tl;dr;
Apply a texture to a plane with N number of polygons\columns in one row. Adapt plane geometry to punchback.

hey h99,

I really tried to follow you, but I’m a geometry-moron. Now I tried this little patch. Is that coming close to what you meant? Even if so, there’s still a few things I don’t get:

• Depending on the curvature, there’s a Z-Axis offset. How can I correct for that
• I used Linear Spread for creating the z-offset. Is there a way to do that in a parabolic curve, that I can adjust… something like an exponential spread?
• I understood, that I just need a grid resolution of Nx1, but I couldn’t find a way to get that to work with Nx1 Control points.

Thanks for the patience,

Alex

Grrr… I keep forgetting to attach stuff ;)

undistort_mapping_cyl3d.v4p (12.7 kB)

Basically, projection mapping is the same thing as texture mapping. I have a texture, which as two dimensions, that have to be applied to a solid, which as three dimensions, or anyway exists in a 3 dimensions space.
Every polygon of the solid has spatial coords and has also texture coords: these define which parts of a texture will fill \ cover \ be applied to that polygon.
While objects - or any of its component: point, line, polygon - have XYZ coordinates, a 2d texture, when it comes to mapping, has UV coords.
Now, if I recall correctly, as a puppy dog has just entered this house with all its pee and poop gifts - still no barf, though -, opengl and directx assign these coords differently. DX assigns to the top left corner of the texture the UV(0,0) coords and to the bottom right the UV(1,1), where U is the horizontal axis, and V the vertical one. See example 0 in attached patch.

vvvv’s Grid (EX9.Geometry) has fixed texture coords: this means that if you squeeze it in one dimension, the applied texture will squeeze accordingly.
In example 0 switch from native to transformed, and notice that South-America is not affected by geometry changes - except Venezuela and Colombia, poor guys.

Try to look at real life objects as a grid of regular polygons - don’t do this at parties: they’ll think you’re a weirdo; trust me, it will happen, though it depends on the kind of party, I guess. Oh well. -: the more the polygons go away from you, the smaller they get. The same thing happens in a renderer, which is, in fact, a 2d space.
So, since the Z axis is the depth one, how renderer manages depth, in this case? Making the polygons smaller the more they are far. What should you do to correct this? You should inverse the shrinking - assuming the projector is perpendicular to the projection surface. See example 1 and 2 in AP.

Since the punchstuff is circular, I’d use CircularSpread. Factor=0.5, I guess. Or GetSlice.

I see you are using dx11, which is not my case, so I don’t know which and how parameters and nodes should be used with this engine. For sure theory doesn’t change.
Anyway I think that from AP you should be able to understand how to do this with dx9, so you could then transform it to dx11.
There are also a few mapping tools and tutorial in contributions, one very well made by elliotwoods.

I hope this is of some help.

for_drehwurm.zip (8.7 kB)

Thank you h99 for your time. I love your humor :-) I need dive in that topic deeply, and you’re helping me a lot. I’ll bother you again and again. This weekend I might find time to learn :-)

Wow h99,

That actually is the best help I ever got! Thank you so much. Your patch and post should be added to girlpower or to the tutorials-section.

I feel pitty for columbia, too, but I’m happy brazil is fine! If we ever should meet at node15, we should talk about that puppy-thing. Sounds like a trauma. Maybe we find professional help ;)

Now for the math…

You really enlightened me about the way how to think about projection mapping. How would you calculate the correct XY Coordinates for the setslice in example 2? Of course you simply could adjust them by eye-measure and trial and error, but there should be a formula for that, shouldn’t it?

Greetings,

Alex

The 2 months old puppy thing is a trauma, definitely. For carpets.

You should have a look at a contribution from @Joanie_AntiVJ, too.

Then, math is surely involved, since it’s the common language to all things.
To reach perfection, it would include

• measurements of projection surface
• projector’s field of view - or how is it called in English? Anyway its focal length
** its lens distortion too - yours has pillow or barrel distortion?
*** nah, joking. Usually distortion is not perceivable. OR NOT?
• the ratio of projection
• possibly the number of the winning ticket of the next lottery, which would lead to pay someone to do calculations for you.
I guess it’s possible to find a “formula” to fit every installation, but honestly, I never spent time really thinking about this. Most of my knowledge comes from some modelling experiments, something like “perspective modelling”, which led to various findings about texturing, and not in a vvvv scenario, anyway; to hard to describe right now.
Anyway, “by-eye-measure”, I think it’s the most used technique out there by our fellows pro vvvvers.

Jokes aside, first step it’s into trigonometry, I’d say. Know your triangles, dude.
Generally speaking I think that once you know the triangles resulting from the sections - for both width and height - of the pyramid of light projection from projector to projection surface - and its triangles, too-, you can then calculate with pixel precision where a point should be in the renderer.
How? You’d say. My guru tells me I have to die and get born again another three times to gather the necessary knowledge. Or, alternatively, have a job in this field.
So B.E.M. is best solution for me right now.