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

Limit Scope of Default Uniforms #5279

Open
1 task done
JetStarBlues opened this issue Jun 1, 2021 · 2 comments · May be fixed by #5280
Open
1 task done

Limit Scope of Default Uniforms #5279

JetStarBlues opened this issue Jun 1, 2021 · 2 comments · May be fixed by #5280

Comments

@JetStarBlues
Copy link
Contributor

How would this new feature help increase access to p5.js?

Makes writing custom shaders more transparent.
Currently there are a couple of uniform names that are used by the default shaders. If a user uses these names in their program, the uniform values they set will get overwritten with the default values (and their program won't behave as they expect it to).

Most appropriate sub-area of p5.js?

  • WebGL

Feature enhancement details:

The default shaders declare and use some uniforms. These reserved names are not known to a user. Rather than telling the user not to use this seemingly arbitrary list of reserved names, a better solution is to just not set these default uniforms when a user-defined shader is used (via shader()).

More discussion on this can be found on the related issue on the p5.js-website repo.

@JetStarBlues JetStarBlues linked a pull request Jun 1, 2021 that will close this issue
@stalgiag
Copy link
Contributor

stalgiag commented Jul 1, 2021

Hi! And apologies for letting so many of your issues and PRs sit for so long. There are only a few WebGL maintainers on this repo at the moment so our availability can be spotty.

I am not sure that the default uniforms should not be modified in custom shaders. I can imagine a case in which someone wants to distribute custom shaders for p5.js for people that don't know GLSL wherein the default uniforms with the p5 functions like fill() and stroke().

I am not committed to this stance as I am not sure if this case or the case in which there is an accidental uniform naming collision is more likely.

@JetStarBlues
Copy link
Contributor Author

JetStarBlues commented Jul 1, 2021

Hi, no worries, understandable! I'm very grateful for all the work you and fellow maintainers do =)!

I see, that is a cool use case. Reminds me of the shader mods people make to games like Minecraft. In that case, I can try my best to document what each of the default uniforms do.

---

What do you think of the last two commits, where the declaration of uViewPort and uPerspective are moved to the same location as other related uniforms. (uViewPort is no longer randomly on its own. uPerspective is moved from the matrix uniforms to the general stroke uniforms). If it the moves makes sense, I can create a separate PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Documentation
Development

Successfully merging a pull request may close this issue.

3 participants