Skip to content

"Shader as Texture" example #1020

Open
Open
@JetStarBlues

Description

@JetStarBlues

The current example "Shader as a Texture" uses createGraphics() and texture() to apply the output of the shader as a material for the geometry.

However, I think a better approach would be to just use the shader() function and avoid all these extra steps. Here is a live example of said changes (and a simpler example by aferriss (live, src)). The example can then be renamed as "Shader as a Material".

function preload() {
  myShader = loadShader("shader.vert", "shader.frag");
}
function draw() {
  ...
  // shader() sets the active shader with our shader
  shader(myShader);
  ...
  // Draw some geometry to the screen
  box(width / 4);
}

To demonstrate how createGraphics can be useful with shaders, I propose adding a second example titled "Multipass Shader" that demonstrates how createGraphics can be used to achieve multiple render passes. For this second example, I would like to add the Texture Delay example (live, src) by @aferriss. (Or maybe the Multi-Pass Blur is a better example due to simpler code (live, src). Though it is not as visually striking with regards to multiple passes).

Would you like to work on the issue?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions