Download

Silhouette/Outline on mouse over

I am trying to recreate a basic object highlighting that many games are using. When you mouse over an object you will see a colored outline around the object.

Here is how I would do it:

Create a second material for the silhouette effect, with a material parameter. The second material is blended over my standard material. When I mouse over an object I just set the second material parameter to 1.

I think I would create the second material like this:

Render the object without any light information, then I get the silhouette for my object, but it is completely filled which I don’t want.

Now I would probably scale this silhouette and subtract it with my original silhouette. I think I would have to do this in a post process shader.

I don’t have much shader experience and I haven’t created any complex materials in UE4 yet. Am I on the right track? How would you create this effect?

Is this something like what you’re looking for?

If yes, check out the second last example in the Blueprint Communication level.

EDIT:
The key is the Render Custom Depth property on the Wheel Highlighted component in BP_Interactive_Crank.

Thanks, I’ll have a look.

I am also looking for something like that. The Problem with the Example is that it is based in a Trigger. When you are in the Trigger the Object gets an outline, but it has nothing to do with actually looking at the Object. I see the only way to always shoot Line Traces and then on the Hit Object change the Texture/Model but I don’t know how much it would hit the performance.

You could also do it the other way. Instead of putting a trigger around the object, attach the trigger to your player. Make it a cylinder or cone or something. Like the camera in the Blueprint Office example.

The highlight effect shown in the screenshot above is due to a post process material used in the level. If you find the post Global PostProcess volume in the Scene Outliner, then search its properties for “Blendables”, you’ll find the material is assigned in there. You could try migrating that material to your project and tweaking it to your liking - there are parameters for outline thickness and color, for example.

Next, you determine which meshes the outline will be used on by enabling “Render custom depth” in their details, as Bajee mentioned. At the time that I made those Blueprints, this checkbox couldn’t be set by Blueprint script, which is why it’s using a visibility toggle for highlighted/non-highlighted versions of the mesh instead. I think you should just be able to set the property and just have one mesh in the current version of the engine, though.

Thanks this helped me a lot.

Does this mean I can only do post processing on the entire render texture?

I have never done much graphics programming but I always assumed it would be something like this:

I know that UE4 uses deferred rendering, so I assumed I could create a scene with tons of different spheres and they all have different materials.

But I thought I could also add a second material to all spheres that would just fill it without any light information. So the render of the second material pass would look like this http://i.imgur.com/HB5loMA.png

Now I thought I could do some PP on this image and blend if over the final image. Would this be possible? Or can I only do post processing globally?

What if I wanted different outlines for different objects? It seems that there is only one custom render depth buffer.