I think I’ve basically solved it and it’s not even that hard. (Short answer: calculate line equation in a fragment shader and then use a lookup texture on m and b to give you the appropriate shade of gray.) But the devil’s in the details, and there sure are a whole lot of them…
-
-
Replying to @pcwalton @mcclure111
so we have this shaders, i wonder how close are they to what you have in mind? https://github.com/solvespace/solvespace/blob/master/res/shaders/edge.vert …https://github.com/solvespace/solvespace/blob/master/res/shaders/edge.frag …
1 reply 0 retweets 2 likes -
Replying to @whitequark @mcclure111
Smoothstep is a very poor mapping from distance to area. Common mistake. Even linear interpolation is better. (I posted a graph a while back.)
1 reply 0 retweets 4 likes -
(Referring to https://github.com/solvespace/solvespace/blob/master/res/shaders/edge.frag#L28 … here.)
1 reply 0 retweets 3 likes -
Try replacing smoothstep with this function: https://github.com/servo/webrender/blob/ad6cec76254030e8fcc4e6c7e5e300c69b6d36ca/webrender/res/shared.glsl#L91 … You’ll get a much better result. (I wrote the error bounds in the comment there.)
2 replies 0 retweets 7 likes -
Replying to @pcwalton @mcclure111
I have no idea how to do that :/ I tried a few permutations that look reasonably correct to me but they all produce wildly wrong result after rendering, which is my quintessential computer graphics experience
1 reply 0 retweets 2 likes -
Replying to @whitequark @mcclure111
Try replacing smoothstep with this (untested):https://gist.github.com/pcwalton/3834632f696e02c72cf93adf09b7afa5 …
1 reply 0 retweets 0 likes -
Replying to @pcwalton @mcclure111
thank you! that looks similar to one of my attempts, but the result is kind of strange, especially for thin lines left: old, about what I would expect right: your replacementpic.twitter.com/bDrOZECZG5
1 reply 1 retweet 4 likes -
Replying to @whitequark @mcclure111
I think the problem is the arguments you’re passing into smoothstep. Don’t have time to debug it right now but in general the polynomial wants to take absolute distance (so 0 is center of pixel is right on the line, sqrt(2) is max distance, etc)
1 reply 0 retweets 4 likes -
Replying to @pcwalton @mcclure111
alright, I'll keep it in mind for when I next work on this code. thanks anyway for your time.
1 reply 0 retweets 0 likes
No problem, sorry it was giving you trouble
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.