I am doing the following transformation to some images which are being displayed as textures in a Quad node:
scale
translate
rotate
Since textures are loaded as squares, I am scaling X and Y with different values in order to get the original proportion of the images.
For some strange reason, when I rotate after scaling the rotation distorts the image, stretching it depending on its proportion. How can this be avoided? How can I rotate a rectangular image maintaining its aspect ratio without distorting it?
This doesn’t happen if I rotate before scaling, but I think I really need to maintain that order.
Why? Well, my problem is that I have some translation, rotation and scaling values already in a file. These are being used in a “Processing” sketch and they work fine with the above order. Unfortunately “Processing” has a memory leak bug related to the use of many images in OpenGL mode so I decided to reimplement the project using vvvv. Now I’m trying to get the same transformations to happen but I still didn’t get it right. I need to get exactly the same layout when I overlap several images but for some reason I keep getting different results.
there must be a way ;) if you are using processing/openGL i am quite sure that it uses matrix transforms like they are in vvvv. but, since AB is in most cases not BA its very important to figure out the multiplication order in processing. if you know that, patch the same order in vvvv. you can do this either by chaining them or using * (Transform) .
another thing is the projection matrix, maybe you are using an orthogonal projection in processing…?
Thanks. Here attached are both versions of my project, the Processing version which displays it correctly but crashes after 20 minutes and my attempt at porting it to vvvv.
As you can see from the Processing version my goal is to overlay several pictures of this girl in a way that her eyes are in sync.
If you have the time and patience please have a look.
Note: pictures contain some nudity.
Please understand that the vvvv version is a little messy. Particularly the “barbara_texture” patch in which I was trying to apply some silly calculations to x and y in an attempt to get it right. Didn’t work. I believe x and y and image size are corelated but I still didn’t get how. You see, in Processing when I use “texture(bitmap)” to print a texture it is already scaled to its original size and proportion while in vvvv it is square by default and I still have to scale it.
Meanwhile I’ll try to use the *(Transform) as you suggested.
I did some experiments with this and I can’t see any bug in VVVV myself.
If I create two quads (one with rotation and one without) overlayed then the proportions on the two figures look exactly the same on my machine. In the zip is a screen shot showing the overlay for one image.
There are a couple of odd things about your patches though:
Really best to avoid hitting FileTexture again and again. I changed to spread the inputs and then select from output spreads.
For some reason it is impossible to edit/view barbara_transformation. I had to rewrite it. Don’t know why this is.
Your processing patch didn’t work on my machine :-( don’t know why.
Here is the zip with my mods and the screenshot. My best guess is that either your raw data is wrong or the VVVV version of the algorithm isn’t quite right.
For some reason it is impossible to edit/view barbara_transformation. I had to rewrite it. Don’t know why this is.
try ALT+E, locks a patch ;)
besides what alphabetter said, i have seen in the processing source, that you create quads with the exact pixel size of the images. in vvvv the quads have equal size. thats the first thing.
so for your quads, try to scale them by the pixelsize of the images. that would be the transform next to the quad. then try to transform the quads as you do it in processing (same numbers). that will result in very big images, but you can scale everything down with the UniformScale at the Renderer.
and to underline what alphabetter said, loading an image every frame is really, really inefficient ;)