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

22 Likes

Very good tutorial, this is very interesting.

1 Like

wow this is pretty cool :money_mouth_face:
the mario vibes are real

Hi, this looks awesome, but is there a way of making it work with R6? Here’s a clip of me testing this with R6, which is pretty broken, and then with R15, which pretty much fixes it
(sharing google drive link because of roblox's stupid 10 MB filesize limit)

1 Like

Thanks for the reply and for pointing that out!

I forgot to implement the script for R6 rigs. The script skipped over everything except MeshParts in the character which is why it didn’t work with R6.


I updated the code to work with R6 as well now. I also created a Module script for easier use of this highlighting method. With it you can create a Highlight, which gets only rendered over other objects, with the following function:

module.ApplyHighlight(
	object: BasePart | Model,		-- Object to apply highlight to
	highlight: Highlight,			-- Highlight to be used for the given object
	scaleFactor: number,			-- How much masking object is scaled towards camera
	waitBeforeApplying: boolean?,	-- Wait for given Model to load (right now only waits 2 seconds)
	isCharacter: boolean?,			-- Characters are handled differently by the script
	hasMovingParts: boolean?)		-- Models with moving parts are handled differently as well

The highlights can also be removed with the following functions:

module.RemoveHighlight(object: BasePart | Model)

module.RemoveAllHighlights()

Here’s the updated place file: Highlight_Over_Objects2.rbxl (126.8 KB)

6 Likes