I’m making 3D models of weathered gravestones with photogrammetry and using the textureless model with simulated shadows to read the engravings:
It works pretty well, but it’s much more legible if I make the engravings black and the surface white and don’t depend on shadows. For flat stones, I figured out I can do this in Blender by importing the .obj file, and making a shader that divides the world into white and black by coordinates, then very carefully rotating and shifting the model until the surface is in the white zone and the engravings are in the black zone:
This is tedious, and doesn’t work at all if the stone isn’t perfectly flat, like if it bulges out in the middle, etc. You can see how the area around “July” is darker because it’s not quite flat there:
How can I make only the engravings dark and the flat parts white, in a way that ignores broad curvature and doesn’t require me to rotate it manually to a specific angle? Is there some kind of “color by local depth while ignoring global depth” shader? Conceptually, something like:
Take the median position of the connected vertices within a certain radius and then shade based on Y depth relative to that median
Anything that can be touched by a 10 mm rolling ball is colored white and everything it can’t reach is black
Smooth the surface in a way that removes the grooves (median lowpass filter?) and then slide that back a bit to act as the “cutting plane” that separates the white/black colors?
I tried just using the pointiness output but it doesn’t work well:
I can’t select the letters by hand. The whole point is that the letters are hard to read and distinguish and I’m trying to make them more visible. Shading by depth works, but I need that depth to be relative to the surroundings.
Try the “Ambient Occlusion” input node. It lets you configure the distance, which might be enough flexibility for engravings like this. And you can have multiple different nodes at once.
Did you follow the second tutorial? As it looks as if you set the material on the whole mesh … the process creates a mask that is used as a factor placing the dirt / grim only in the cavities… and like in the tutorial perhaps you need the color-ramp to make it show better, also you might try it and don’t set it for Dirt only. I have used it and it will work on anything with an indent.
Ok, that all looks ok…now have you added the Attribute node and second Principled etc etc.
It is the color ramp that will add to and make darker…
? This does have a UV correct, and the base color from the scan?
Did a quick one with a deep blue color so you can see the effect…EeVee in lookdev mode…
I asked about the UV as that would be why nothing showed up in the Blank Square when switching to Texture Paint…It’s not that important as it will all be mapped as a Generated texture by default…
I would still use the original texture in the first principled and add the dirt Noise to the second as in my example…and really play with the color-ramp to push up the contrast for the dirt…to might need to change the Reflection angle and/or the Dirt angle…also you might need to reverse the color-ramp it does make a difference…
Highlight at 60 degrees, dirt at 45 and color-ramp reversed…
Ok, do you understand the Reflection angle and/or the Dirt angle and how to set them?
Conceptually, what I would like to do:
for every vertex in the mesh:
s = set of all vertices that are connected to this one, within a certain radius
calculate the median x position of s
shade vertex based on difference between its x position and the median x position (so that 0 distance is white and engraving depth is black)
Then it would shade small features while ignoring large features/warping/drifting
duplicate your scanned geometry
apply a remesh modifier to the duplicate to get the overall shape of the background stone without the engraving
UV unwrap the low poly remeshed model
bake a displacement map from the hi poly version to the low poly version
This displacement map should capture those details fairly well.
We’re all just shooting in the dark here without a mesh to test on, can you share a .blend?
Alright, I forgot that cycles can’t bake displacement for some reason, but I was able to play with it a little bit to try to find a way to streamline this a bit:
First off, I went into edit mode, selected the main mesh by selecting one piece of it and pressing ctrl+L to select all linked pieces, then I inverted the selection to get all of the loose pieces left over from the photogrammetry mesh generation:
The best thing I’ve tried is to modify my white/black shader so that it includes a little bit of Y and Z coordinates, too, and taper it off a little in those directions so it matches the surface of the stone. It’s very tedious, though.