Image Clipping Module

Seems cool. I’ll try this when i want to add PFPs to my game(s).

3 Likes

Very nice job, never thought this was possible!

3 Likes

Looks great! I will be using this for sure soon!

1 Like

Apparently, this has some extremely unpredictable behavior. I won’t report it as a bug yet, in case it’s on my end.

image

Sometimes, the image will be rendered with some strange triangular distortion. (Look at his neck) The mesh it is displayed on is only a single face, no odd triangle there for it to do this.

There’s no repro for this bug, as it happens randomly, and only a small percent of the time. The way I found it was by creating 1000 images in a stress test, and instead found that quite a few of them had this weird bug despite being created identically by the same looped code.

Anyone have any ideas?

3 Likes

I am having this same issue, am trying to find source of this bug, if/once I do I will report back here.

1 Like

How did you decide on it being 62 degree FOV?
I thought it should be 58 because

print(math.atan(.5/.9)*2*math.deg(1))--math.atan(faceSize/2/distanceFromCameraToFace)*2*math.deg(1)

62 fits the 1x0.2x1 MeshPart (with a tiny bit of extra space just in case).

I picked it just by doing a loop of numbers 20-130 and picked the one I thought looked best. Feel free to tinker with it and show me what you come up with!

2 Likes

Why not move the camera instead of tweaking the FOV? I’ve found that moving the camera gives more precise control over the edges. Getting the height you need to move to is surprisingly simple:

RADIUS / math.tan(math.rad(FIELD_OF_VIEW) / 2)

This is what I used in my implementation of this a while back.

3 Likes

Super Awesome! I am glad someone eventually made this. To be perfectly honest, this is something Roblox should have implemented themselves a long time ago.

This is a great method, and I’ll tinker and see how I can use this to allow a wider range of customization. Thanks for sharing!

Edit: I now use this method, and all original files have been updated.

I want to support non-square images. Currently, any non-square image gets stretched, as Decals do not support any other form of image wrapping.

The downside to Decals on MeshParts is that they distort to the part’s size. Thanks to the method shared by @Reselim, I can easily modify the code to handle parts of varying sizes, and then I’d simply have to size the mesh based on the image’s aspect ratio.

However, I don’t know how to get image aspect ratio from an asset id. Is there a method or API call that I am unaware of, or will I have to add another argument .new() in which the user passes the ratio.
I’d much prefer the module handles it automatically, so please let me know!

EDIT:
Apparently, you have to use external HTTP work to get it. I’ve found this amazing plugin by @evaera that gets the image dimension with an HTTP request.
However, HTTP requests can only be handled by the server, whereas this module is client-sided. To get around this, I’d have to create a remote event system. It’s not complicated, but it would transform this project from a simple plug-n-play module to a system requiring some setup.

I made a version using some of @Quenty’s modules that I rewrote. It has support for Promises!

ImageMask.rbxm (20.3 KB)

4 Likes

Thank you so much! This was really simple to carry out and I’m now using it in my upcoming Halloween game for a dialog ui.

2 Likes

my god is this helpful thank you so much would use for sure

1 Like

Does this support ViewportFrames?

This is a VPF? What do you mean?

See this post. This is what lead me here.

For some reason, it won’t show the image of the Player in Billboard Guis. Its there but it won’t show for some reason. Any clue why?

Can I make custom ones too? Like a plus for example

That’s in the original post. Please read the post carefully before bumping a half-decade old thread.

1 Like