three.js-demos
three.js-demos copied to clipboard
Please add some detail explanation about the most important 2 lines of code
Thank you for your demo, it helped me. But I don't fully understand why.
I think as a demo, it's important to explain the thinking process of the key thing you demonstrate, for the learners who come to find technical detail instead of just "shader magic".
Would you please comment this 2 lines?
https://github.com/fernandojsg/three.js-demos/blob/40a8ec125f645e67aa89b8967c2f955530b71a71/crossfade/js/transition.js#L73-L74
I understand that as third parm of mix, mixf
have to clamp from 0.0 to 1.0, but what does float r = mixRatio * (1.0 + threshold * 2.0) - threshold;
means?
And why we have to (transitionTexel.r - r)*(1.0/threshold)
?
Is this your own invention or you see from somewhere?
I'm really enjoy shader programming, and really feel a door closed when I see magic uncommented shader code like this.