[Godot 4] How to offset vertices away from the camera in Visual Shader?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By unfa

I am drawing an outline using the typical grow + front face culling + unshaded technique. However, I’d like to get rid of lines that are not part of the silhouette.

I figured it’d happen if I offset the geometry away from the camera.
The problem is - I was unable to figure that out in the vertex shader.

I am working with visual shader, but if something can be done with an expression there that’d be fine.

One pitfall here is that the offset vector I need is not just the Z axis of the camera - it’s a ray from the camera center towards the vertex being considered - the angle here can vary.

Otherwise my outlines would be pushed towards the center of the frame.

I was trying to figure something out with transforms but no go so far. The best I could do was working only when looking from a certain direction.