question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documenting available attributes and uniforms on the Reference page

See original GitHub issue

Actual Behaviour

There is currently no documentation on the attributes and uniforms that are available when writing shaders in p5. For example, the aPosition attribute is used in all vertex shader examples, but there is no associated documentation on the Reference page. Similarly, there are a lot of useful attributes and uniforms (such as uProjectionMatrix), which do not appear in any of the available examples. The only way to learn about them is to dig into the p5 source code.

Expected Behaviour

Ideally, a list of the available uniforms would be listed in the setUniform() documentation page. Each listing would have a brief description of what the uniform does. (This would have the added bonus of giving the user a hint as to which uniform names are unavailable for use).

Similarly, a list of available attributes would be listed. If a setAttribute() method existed in p5, its documentation page would be the ideal place to list them. However, they can be (together with the default uniforms for consistency) be listed in the p5.Shader documentation page.

Since a lot of these default attributes and uniforms are used for the default shaders, not all are immediately relevant to outside use. Here is a list of the most useful I have been able to identify so far (source1, source2):

  • Attributes
    • aPosition
    • aTexCoord
    • aNormal
    • aMaterialColor (aVertexColor might be a better name)
  • Uniforms
    • uProjectionMatrix
    • uModelViewMatrix
    • uViewMatrix
    • uNormalMatrix

Ideally, additional examples (such as this one (live, src by aferriss ) would be added to demonstrate the usage of some of these attributes and uniforms.

Would you like to work on the issue?

Yes

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:22 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
JetStarBluescommented, Dec 27, 2021

Hi @aferriss

I will clean this PR up. There are a few outstanding questions, but I’ll compile a list at the end.

One thing I would love your opinion on is this PR (and related issue) that limits the scope of the default uniforms… this would greatly reduce the number of things we have to tell people they can’t use.


I will also create a single PR that updates all the shader examples. It will be a combination of the discussions (and draft PRs) here:


Two PRs in total. Or potentially one, since the order of the examples seems to be determined by the number prefix on the filename, and it would be ideal to place this documentation as the first entry (which would require a rename of all examples to place this as 00_)

00_geometries.js
01_sine_cosine_in_3D.js
02_multiple_lights.js
03_materials.js
04_textures.js
...
1reaction
aferrisscommented, Dec 20, 2021

@JetStarBlues I wanted to see if this was still in progress and where you ended up with documenting the uniforms. I’ve seen some other issues lately for people asking for documentation. Since this work was already done it might be worth putting up as a PR to review.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data in WebGL - Web APIs - MDN Web Docs - Mozilla
Uniforms. Uniforms are set by the JavaScript code and are available to both the vertex and fragment shaders. They're used to provide values ......
Read more >
Fields | React form library for building forms from any schema
uniforms provide a set of predefined components that can be used as form fields. Automatically renders a given field. Automatically renders given fields....
Read more >
WebGLProgram – three.js docs
WebGLProgram. Constructor for the GLSL program sent to vertex and fragment shaders, including default uniforms and attributes.
Read more >
Program Introspection - OpenGL Wiki - Khronos Group
2.1 Attributes; 2.2 Fragment Outputs; 2.3 Uniforms and blocks ... It is all documented on glGetProgramResource's reference page, ...
Read more >
Shading language - Godot Docs
Like uniforms, global constants are shared between all shader stages, ... For a list of the build-in variables that are available, please see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found