Best way to create a smooth white overlay over model?

I’m trying to program a fairly simple highlight/overlay for highlighting interactable objects that you mouse over. I followed an approach basically identical to this post which followed another example before.

The script runs locally in a ViewportFrame parented to a ScreenGui, when your Mouse.target is a bounding box for a highlightable object it adds it as the Viewport frame target, sets the viewport frame camera to workspace.Camera, and sets all parts materials to neon with a pure white color. This is overlayed with transparency achieving a pretty decent effect.

The problem I’m having however comes from anything being in front of the camera such as my Character in the video above. Since it’s a ScreenGui, it’s rendered on top of everything else. I tried switching to a Billboardgui approach setting the adornee to the bounding box as needed, however a new problem quickly showed up. Since the ViewportFrame in the BillboardGui doesn’t take up the entire screen the effect is thrown off entirely.

I’m basically looking for a way to either correct the issue with a BillboardGui approach scaling it properly to the camera so that the objects line up again, or a way to make it so the ScreenGui approach renders beneath obstructing objects, or an alternate approach altogether that others have used. The primary use of this will be highlighting NPCs hence why I’m wanting a clean overall overlay despite the various parts that makes up a character.

I can post specific code if needed, however this is more a matter of how to approach it vs specifically how to program it.

Off the top of my head, I feel like the most you could do is use raycasting with the workspace model toward the camera (or the reverse) to see if there is any visual obstruction. If so, hide the targeted part proxy in the ViewportFrame.

Another solution might be to just not use a ViewportFrame and instead just physically layer a clone on top with slightly a slightly larger scale. But I doubt that will be as nice as the desired effect. It would be nice if Roblox had a layering property for models like it does with UI elements.

3 Likes