feat(render3d): a rim outline around a highlighted actor

An actor gains `outline` (metres of rim) and `ocol` (its colour). The pass draws
the model a second time with its vertices pushed out along their normals and its
front faces culled, so only the far side of the swollen shell survives - a
silhouette exactly `outline` metres wide. It is depth-tested against the scene,
so anything standing in front of the actor hides the rim too.

skin.vert grows an OUTLINE path for the push; outline.frag is the flat-colour
fragment shader it pairs with.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-10 16:15:12 +03:00
parent 9d1df6ec32
commit 2542cb591d
3 changed files with 70 additions and 1 deletions

View file

@ -0,0 +1,14 @@
// the inverted-hull shell (skin.vert with OUTLINE): a flat colour, no shading. Cut-out
// meshes still need their shape, so the alpha test comes along.
uniform vec3 u_outline_col;
out vec4 o_color;
#ifdef ALPHA_TEST
in vec2 v_uv;
uniform sampler2D u_diff;
void main() {
if (texture(u_diff, v_uv).a < 0.45) discard;
o_color = vec4(u_outline_col, 1.0);
}
#else
void main() { o_color = vec4(u_outline_col, 1.0); }
#endif

View file

@ -12,6 +12,9 @@ uniform float u_skinned; // 0: a rigid model on the same path
uniform mat4 u_view;
uniform mat4 u_proj;
uniform mat4 u_light_vp;
#ifdef OUTLINE
uniform float u_outline; // metres the shell is pushed out
#endif
out vec3 v_wpos;
out vec3 v_nrm;
out vec2 v_uv;
@ -28,6 +31,11 @@ void main() {
m = u_model * sk;
}
vec4 w = m * vec4(a_pos, 1.0);
#ifdef OUTLINE
// an inverted hull: the shell is pushed out along the world normal and drawn with the
// front faces culled, so what survives is a rim of `u_outline` metres around the model
w.xyz += normalize(mat3(m) * a_nrm) * u_outline;
#endif
v_wpos = w.xyz;
v_nrm = normalize(mat3(m) * a_nrm);
v_uv = a_uv;