How to get the perfect outline

I tried several methods, but the results were not very good;

I just need the outline of ground !!!

Hi,
May I just ask what for you is “the perfect outline”?
You have 5 methods (may be more) to make an outline of your mesh. I can see you tried your luck on 3 already.
I believe two more would be using the line system to create lines around your ground.
The other would be get adjacent vertices and color them.

So, what should your perfect outline look like? Blured, sharp, thick, tiny, displaced?

Please ignore that the line segment is not straight

I want it to look like this

I’ve seen other PGS on the forums, but I can’t reproduce some of the effects

I see. Ideally, you would use the edge rendering but there’s an issue with objects not having smooth edges. This issue is described here and here.
A solution can be found in this PG

Else, applying this method on sharp edges will turn like this

2 Likes

The minimizeVertices function is now part of the core as ‘forceSharedVertices’ so PG is now

6 Likes

Awesome. :yum:Thx for the info. Bookmarked it. Makes things just so much easier :smiley:

What if there are multiple meshes in the scene

I also think the outline approach looks like copying a source mesh and hiding it behind the source mesh with depth properties. This is why there is no stroke below ground in the image

1 Like

You can solve this with a thin box

This is the best I can achieve with the two meshes

1 Like

This might seem like a bad idea to implement in Blender if you just use existing apis

https://threejs.org/examples/?q=outline#webgl_postprocessing_outline

I have also used this function of three.js, but it is implemented in the late stage, and the calling process is complicated

1 Like

Is this still a question or some sort of feature request? Thx,

Would love for a way to implement these kind of outlining shaders ourselves and apply them to the meshes. @ecojust

forceSharedVertices() does not work well with all meshes, for example animated meshes and the ones involve a mesh hierarchy (consider imported files). So such a feature could be useful :pray: :grin:

The perfect outline of a mesh

take a mesh, duplicate it and scale an offset
then convert meshes to CSG and subtract
the inner mesh from the outer mesh

perfect outline

image

the attribute “perfect” deserves it from the idea that you can take any mesh to create an outline. If you need just a slice then cut the mesh.

Here is a shader for outline the hole scene

Test porting xeogl camerawork to Babylon.js | Babylon.js Playground (babylonjs.com)

via
Porting example by ChatGPT (Porting from xeogl to Babylon.js) - Demos and projects - Babylon.js (babylonjs.com)

1 Like

Not sure if this will work well on meshes with irregular shapes and holes.

Logically, it should work. I have not tested the subtraction function on complex formations.

What I can offer you as an idea is this example that I programmed years ago to calculate a shadow.

If you take the same point of view with the camera as the sphere, you can see a grey outline around the box. this is your outline.

if i were you, i wouldn’t take the sphere, but the camera. the plane should be statically attached to the camera and always look at the camera.

shadow generator

image

There are more techniques for creating an outline with blender on youtube.