Improve shading to properly display blind holes #2161
Labels
good first issue
Good for newcomers
topic: display
Displaying Fornjot models
type: feature
New features and improvements to existing features
Problem
This is how blind holes currently look:
You can reproduce this picture, by running
cargo run -p holes
from the repository root, then rotating (drag while left mouse button is pressed) and moving (drag while right mouse button is pressed) the model until you see the blind hole.As you can see in this screenshot, the surface of the part and the bottom of the blind hole look exactly the same. This is because they are parallel, and the shading only depends on the angle between a surface and the viewing direction.
Solution
I'm not an expert on graphics, and I'm sure there are many ways to improve this. If you know of one, feel free to implement it!
The solution that comes to my mind, is to make shading also depend on the distance to the camera. This would have to be carefully tuned, to make cases as the one shown in the screenshot look decent, without making far-away parts completely black. It might make sense to clamp the result in such a way, that the effect of distance can never make a part too dark.
Implementation
Rendering is implemented in the
fj-viewer
crate, specifically withinshader.wgsl
. It's possible that this issue can be completely addressed with only changes to the linked shader function. It's also possible (especially, if a more advanced solution is chosen), that this requires changes to the larger graphics system.In any case, implementing this will only require knowledge shader languages (I'm guessing that WGSL is pretty easy to understand for anyone familiar with other shader languages), and possibly Rust and wgpu. It won't require knowledge of other Fornjot internals. For this reason, I'm tagging this as a good first issueGood for newcomers
.
The text was updated successfully, but these errors were encountered: