Outlines on edges.

Started by
4 comments, last by SeanMiddleditch 8 years, 2 months ago

I have a lot of geometry with per-vertex position and normal.

I would like to render outlines on edges with significant difference in per-face normals like on right geometry.

I am looking for solution to render the outlines with variable thickness (not wireframe mode).

[attachment=30745:Outlines.png]

Are there any ways to implement it?

If it useful, I am using D3D11.

Thanks in advance.

Advertisement

You can render variable-width outlines with barycentric coordinates in the pixel shader, and it's even more flexible if you have geometry shaders available.

Ah, there's the original paper I was looking for.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Thank you, Swiftcoder.

It seems the algorithm is not what I am looking for: it describes how to render wireframe.

Please take a look on a right geometry on my picture: there is no outline between 2 triangles on a top.

I am looking for solution how to make outlines on significant edges, not on all edges.


I am looking for solution how to make outlines on significant edges, not on all edges.

The algorithm I indicated gives you the tools to render variable width edges. Choosing which edges is up to you.

Off the top of my head, if by "significant edges" you mean hard edges, then you should just be able to select edges that have a significant change in normal direction.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

So algorithm would look like this:

1. For each frame

2. For each geometry

3. For each triangle

3.1 Find sides of the triangle needed to be outlined

3.2 Render outlines on chosen edges.

It seems a lot of computation for real time rendering.

I think it's better to precompute some info and store it as per-vertex data.

I think [3.1] should be precomputed for sure.

So, [somehow] I need to find for each model edges with big difference between normals.

if I have per-vertex data about outlines I need to render: v0<->v1 + v1<->v2

[attachment=30747:Outlines2.png]

Also I have size of a triangle (in object space) => I can find absolute outline coordinates.

What is the best way to encode this information as per-vertex data?

I would like to minimize computation in runtime.

Probably it should be look like:

1. Vertex shader receives this value

2. Pixel shader applyes [a texture?] on each pixel of the triangle.

So algorithm would look like this:
1. For each frame
2. For each geometry
3. For each triangle
3.1 Find sides of the triangle needed to be outlined
3.2 Render outlines on chosen edges.

It seems a lot of computation for real time rendering.


Only if you're doing all that on the CPU. A GPU can chew through those kinds of calculations very very quickly.

I would like to minimize computation in runtime.


Do remember that in with modern architectures, memory access can often be more expensive than computation. The cost of transmitting and accessing precomputed values needs to be weighed against the measured cost of the computations on target hardware.

I'd start with the GPU solution, measure it, then _try_ the precomputed approach as an experimental optimization, and see if it really does help or not (remember to try it at scale in a complex scene with complex objects so that you aren't getting fooled by a microbenchmark).

Sean Middleditch – Game Systems Engineer – Join my team!

This topic is closed to new replies.

Advertisement