In many 3d games (like Overwatch, Cyberpunk 2077, Halo, Apex Legends) you can get a outline and tint overlay of important mesh objects.
In Halo for example enemies are drawn red, friendlies and items blue, special items gold.
The outline and tinted overlay are drawn on top of everything else and also have an alpha so you can see the meshes and material behind it.
These outline and tinted overlays also only should appear when specific criteria is for example the mesh objects are within a specific area or within distance to something.
How do you do this in godot?
An example project would be appreciated.
How to do outline and overlay of 3d meshes?
I think those games use a stencil buffer, but we don't have access to stencil in Godot. You could just make a dummy duplicated mesh and overlay it with a different material.
- Edited
I found these 2 shader from arlez80 on youtube and godotshaders.com:
Silhouette Shader for Godot Engine
Outline Silhouette Shader
downloads:
https://bitbucket.org/arlez80/silhouette-shader/src/master/
https://godotshaders.com/shader/outline-silhouette-shader/
These two shaders (actually three because outline silhouette uses two shaders) do almost exactly what I want.
There's only two more things that I want that these 2 shaders don't do:
1. Encompass the whole mesh, not just the parts that are blocked by other meshes.
2. Alpha part is wrong, it looks like x-ray effect which I don't want.
The shaders are very small but I'm more of an artist than a shader programmer so I'm out of my depth, I would appreciate anyone to help perfect these shaders.
here is a small sample project
Here I fixed it for you. Happy new year!
- Edited
Almost perfect, you fixed the first thing I mentioned, what about when using alpha it produces sort of an x-ray effect (the areas where overlapping mesh)?
I would like the overlay to be uniform like in the first post of halo.
- Edited
That is somewhat hard to do because of the way objects are drawn in OpenGL (or any API really). When you use alpha on a 3D object, it doesn't do the normal depth writing/checking, meaning that sub-objects will be overlapped. I might be able to fix it, give me a second.