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

Please add some detail explanation about the most important 2 lines of code #1

Open
star8ks opened this issue Dec 21, 2017 · 0 comments

Comments

@star8ks
Copy link

star8ks commented Dec 21, 2017

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?

"float r = mixRatio * (1.0 + threshold * 2.0) - threshold;",
"float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);",

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant