How does one crop a texture?

How does one crop a texture?

Quite awkwardly. But this seemed to work.

Get Image->Make 3d Object From Image->Render Scene to Image

The width of the Make 3d Object From Image and the width and height of the Render Scene to Image can be used to control the cropping

Download example.

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 my response … That looks OK and workable to me.


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.