🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to make mesh edges to be "worn out"?

Started by
5 comments, last by AlphaSilverback 2 years ago

How do I make mesh edges (between faces that have different normals) to have different (washed out) color, like a gradient going from the edge towards the center of the face?

My best bet is to check all triangles' vertices, figure out which make matching edges, then pass an attribute color to vertex shader and somehow mix it with diffuse color via barycentric interpolation.

Am I on the right track or is there an easier/different way to do it?

Is there a standard algorithm for it?

Thank you!

Advertisement

>My best bet is to check all triangles' vertices, figure out which make matching edges

If static texturing is an option and you don't need the “worn out” look to be dynamically changeable in-game, then offloading this to the texture art phase would be a better option.

If you need dynamic wearing-out as a feature then your approach seems okay.

You could figure out offline which faces have edges with 'wear-out potential', and pre-bake such data, rather than trying to figure that out during runtime.

Instead of using the vertex / fragment shader with a color parameter and barycentric coordinates, another (unconventional) option might be to use megatexturing, and to update the virtual coordinates for those faces that need to be displayed as worn out. But that's probably only an option if you have megatexturing already set up, otherwise it might be too much of a round-about way to reach your goal.

Another perhaps more readily achievable way might be to render-to-texture, updating your texture at those places where it needs updating to have the worn visual look. This would involve again, book-keeping which faces need to be considered, and then copying texture data for those faces from a source texture (which should be a representation of the worn out surface) to the displayable texture.

Very useful, thank you!

@alikim Paint it manually. What you want to paint is “how worn it is here," rather than paint the color effect directly. Either in an alpha channel, or in some unused channel in an attribute texture (assuming you're doing a modern photogrammetric type shader.)

You can then use a shader to apply “wear” in whatever way you want – desaturate, add metal, add bumps, …

enum Bool { True, False, FileNotFound };

There offline tools to generate procedural dirt.

It's quite an interesting field. Notice the streaks from draining water in above example, that's something you can not really do well procedurally from scratch each frame.
So to me such ideas are one of the biggest arguments towards a megatexturing approach. Even if we generate at runtime, and add decals etc., we can cache the results and need to calculate only once.

Unfortunately, there's no really good and cheap way to do this in a shader. You technically could do it using a post-processing filter, but these are not exactly efficient. Wear and tear, weathering, or “worn edges” as you call them are important to give the environment a feeling that things have a history.

9 Blender 3D ideas

The best way I have found is to create a master material using 3 textures:

  1. texture you make into a color strip or base color, defining the underlying tone or texture,
  2. Texture layer
  3. grime layer.

Using 1 material for everything speeds up rendering insanely, because you have a very tiny memory footprint, and most engines know how to batch per material. Your texturing workflow is moved away from “painting” textures, to moving around the different UV channels in Blender/Max/Maya/Lightwave or whatever. Most artists prefer this method, because you also help yourself making a more clean color palette for your solution.

You can find a lot of different tutorials out there, but you can start with this one to get a feel of the concept:

Alpha Silverback

This topic is closed to new replies.

Advertisement