How does one crop a texture?

Moderator note: 

We added a `Crop Image` node in Vuo 0.6.0.

Comments

That seems fine to me. The

George_Toledo's picture
Submitted by

That seems fine to me. The other thing you can do is make a custom filter and discard frag or make alpha wherever you want (via maybe referencing texture coordinates or a shape function), but you output the same input size. Playing with this a bit, it's workable.

I see the line:

adjustedImage = VuoImageRenderer_draw((instance)->imageRenderer, (*instance)->shader, image->pixelsWide, image->pixelsHigh);

Maybe that can be adjusted to output less than input safely (haven't tried). Then of course texture origin can be changed via tweaking the fragment coord, regardless of if that works I guess.

I guess the browser demon ate

George_Toledo's picture
Submitted by

I guess the browser demon ate my response ... That looks OK and workable to me.

Also...

Looks like maybe the output pixel w/h can be set to less than input size in the image filter example (haven't tried it). I don't know if that's safe to do or not.

Either way, another thing one can do is make an area in a fragment shader (via the Image Filter project), be alpha, or discarded, and offset the area of interest created however one wishes.