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

Improve documentation clarity of shader methods #5307

Merged
merged 1 commit into from
Jul 28, 2021

Conversation

JetStarBlues
Copy link
Contributor

Minor changes to the wording used in the following shader methods, with the goal of improving clarity.

loadShader()

1) Reword

Current:

Loads a custom shader from the provided vertex and fragment shader paths.

Change:

Creates a new p5.Shader object from the provided vertex and fragment shader files.

2) Omit this statement

Current:

For now, there are three main types of shaders. p5 will automatically supply appropriate vertices, normals, colors, and lighting attributes if the parameters defined in the shader match the names.

3) Be consistent

Current:

On success, the Shader object is passed as the first argument. (Optional)

Change:

p5.Shader object

4) Add disclaimer

Note, shaders can only be used in WEBGL mode.

createShader()

1) Reword

Change:

Creates a new p5.Shader object from the provided vertex and fragment shader code.

2) Add disclaimer

Note, shaders can only be used in WEBGL mode.

shader()

0) Just a thought

I think in hindsight, setShader() would have been a better name for this function. Because the shader program created by createShader() or loadShader() is what people think of as the shader.

1) Reword

Current:

The shader() function lets the user provide a custom shader to fill in shapes in WEBGL mode.

Users can create their own shaders by loading vertex and fragment shaders with loadShader().

Change:

Sets the p5.Shader object to be used to render subsequent shapes.

Custom shaders can be created using the createShader() and loadShader() functions.

Use resetShader() to restore the default shaders.

2) Parameter is not optional

Current:

shader([s])

p5.Shader: the desired p5.Shader to use for rendering shapes. (Optional)

Change:

shader(s)

the p5.Shader object to use for rendering shapes.

3) Add disclaimer

Note, shaders can only be used in WEBGL mode.

resetShader()

1) Reword

Current:

This function restores the default shaders in WEBGL mode. Code that runs after resetShader() will not be affected by previously defined shaders.

Change:

Restores the default shaders. Code that runs after resetShader() will not be affected by the shader previously set by shader()

setUniform()

1) Replace with user-friendly description

Current:

Wrapper around gl.uniform functions. As we store uniform info in the shader we can use that to do type checking on the supplied data and call the appropriate function.

Change:

Used to set the uniforms of a p5.Shader object.

Uniforms are used as a way to provide shader programs (which run on the GPU) with values from a sketch (which runs on the CPU).

2) Improve description

Current:

the name of the uniform in the shader program

Change:

the name of the uniform. Must correspond to the name used in the vertex and fragment shaders

3) Object not a valid data type

Current:

Object|Number|Boolean|Number[]

Change:

Boolean|Number|Number[]|p5.Image|p5.Graphics|p5.MediaElement

4) Replace with user-friendly description

Current:

the data to be associated with that uniform; type varies (could be a single numerical value, array, matrix, or texture / sampler reference)

Change:

the data to associate with the uniform.

The type can be:

  • boolean (true/false)
  • a number
  • an array of numbers
  • an image (p5.Image, p5.Graphics, p5.MediaElement)

Screenshots of the change

loadShader
d1_loadShader

createShader
d2_createShader

shader
d3_shader

resetShader
d4_resetShader

setUniform
d5_setUniform

@stalgiag stalgiag merged commit 1d7cedc into processing:main Jul 28, 2021
@stalgiag
Copy link
Contributor

Fantastic technical writing! Thanks for looking at the docs and suggesting changes with such care.

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

Successfully merging this pull request may close these issues.

2 participants