I was trying to use an outline shader from the Godot shaders site ( Outline Shader (for stylized games) - Godot Shaders ), but it’s giving me some deranged artifacting, even on simple meshes. Every other outline shader I’ve tried has similarly odd behavior. Bizarrely, it shows up fine in the camera preview, even though it’s busted in game and in the editor, and the artifacts seem to be affected by things like nearby editor gizmos. It’s also not consistent - at one point I was getting normal outlines but everything else was black, using the exact same code. Really confused by this one.
Sorry, I forgot to include the screenshot of the issue on my original post. This the outline shader applied as a next pass to a default StandardMaterial3D, on a default sphere and cube MeshInstance3D. The only other node in the scene is the Camera3D.
Ah. I missed that was a spatial shader. 3D outline shaders have notoriously been a problem in Godot. Version 4.5 introduced Stencil Buffer Support which is supposed to improve it, but I haven’t tried it yet. There are lots of options out there for 3D outline shaders. I’d recommend trying a few other and see if the problem is the shader, or something else.
if you just want outlines, you don’t need a shader, just enable stencil outline in StandardMaterial.
that shader is using depth for outlines, maybe you need to put it in a quad in front of the camera, not as next pass. and that might be why it looks like that.
the shader takes the albedo and depth of the screen and renders over it, which is why you are seeing artifacts with gizmos and other materials.
and there might be a way to not outline everything now that we have stencils, but I would need to test that.