이 API는 실험적입니다
향후 p5.js 버전에서 동작이 변경될 수 있습니다.
Create a new shader that can change how fills are drawn, based on the default shader used when no lights or textures are applied. Pass the resulting shader into the shader() function to apply it to any fills you draw.
The main way to use buildColorShader is to pass a function in as a parameter. This will let you create a shader using p5.strands.
In your function, you can call hooks to change part of the shader. In a material shader, these are the hooks available:
objectInputs: Update vertices before any positioning has been applied. Your function gets run on every vertex.worldInputs: Update vertices after transformations have been applied. Your function gets run on every vertex.cameraInputs: Update vertices after transformations have been applied, relative to the camera. Your function gets run on every vertex.finalColor: Update or replace the pixel color on the surface of a shape. Your function gets run on every pixel.
Read the linked reference page for each hook for more information about how to use them.
One thing you might want to do is modify the position of every vertex over time:
Like the modify() method on shaders, advanced users can also fill in hooks using GLSL instead of JavaScript. Read the reference entry for modify() for more info.
예제
구문
buildColorShader(callback, [scope])
buildColorShader(hooks, [scope])
매개변수
반환값
관련 레퍼런스
baseColorShader
Returns the default shader used for fills when no lights or textures are activate.
baseFilterShader
Returns the base shader used for filters.
baseMaterialShader
Returns the default shader used for fills when lights or textures are used.
baseNormalShader
Returns the default shader used for fills when normalMaterial() is activated.