Render Highlight only on top of other objects

I recently figured out a way to make a Highlight only appear over other objects in front of the Highlight. This effect requires 2 separate Highlights and a duplicate of the object you want to highlight. In this quick tutorial I’ll be explaining how to achieve this effect.


Video of the effect


How to create the effect

  1. Add a desired AlwaysOnTop Highlight to the [Blue] object you want to highlight.

  2. Create a clone of the [Blue] object.

  3. Convert the [Red] cloned object to be glass with 1 Transparency. If the object is a MeshPart or contains them, give them any TextureID to remove all specular highlights.

  4. Scale the [Red] object towards the camera so that it appears the same size from the camera’s perspective while always remaining in front of the other highlighted [Blue] object.

  5. Give the [Red] object an Occluded Highlight with 1 FillTransparency and 0.9999999 OutlineTransparency so that it’ll mask out the Highlight of the [Blue] object while remaining nearly invisible.

image

Now when the player is behind a wall, the Occluded Highlight gets blocked by the wall, while the AlwaysOnTop Highlight appears over it:

image


Place file

Highlight_Over_Objects1.rbxl (172.1 KB)


Notes

When the glass meshes used for the masking Highlight object have a WrapTarget and are parented under a character with a Humanoid, they can’t be fully invisible (Transparency has to be at 0.9999999).

SpecialMeshes don’t need to have a TextureId, they already don’t have specular highlights when they’re glass and fully trasparent.

Using shift lock causes issues with the effect since the masking Highlight object doesn’t seem to get updated to the real character correctly:

image

Objects with this effect don’t get highlighted over other objects that also have the effect:

image

image

9 Likes

Very good tutorial, this is very interesting.

1 Like