Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve shading to properly display blind holes #2161

Open
hannobraun opened this issue Jan 16, 2024 · 0 comments
Open

Improve shading to properly display blind holes #2161

hannobraun opened this issue Jan 16, 2024 · 0 comments
Labels
good first issue Good for newcomers topic: display Displaying Fornjot models type: feature New features and improvements to existing features

Comments

@hannobraun
Copy link
Owner

Problem

This is how blind holes currently look:
Screenshot from 2024-01-16 11-28-41

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 within shader.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 issue Good for newcomers .

@hannobraun hannobraun added type: feature New features and improvements to existing features topic: display Displaying Fornjot models good first issue Good for newcomers labels Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers topic: display Displaying Fornjot models type: feature New features and improvements to existing features
Projects
None yet
Development

No branches or pull requests

1 participant