RenderPass(vertexShader, fragmentShader, computeShader, workgroupCountX, workgroupCountY, workgroupCountZ, init)
A RenderPass is a way to have a block of shaders to pass to your application pipeline and these render passes will be executed in the order you pass them in the Points#init method.
Constructor
new RenderPass(vertexShader, fragmentShader, computeShader, workgroupCountX, workgroupCountY, workgroupCountZ, init)
A collection of Vertex, Compute and Fragment shaders that represent a RenderPass. This is useful for PostProcessing.
Parameters:
Name | Type | Description |
---|---|---|
vertexShader
|
String | WGSL Vertex Shader in a String. |
fragmentShader
|
String | WGSL Fragment Shader in a String. |
computeShader
|
String | WGSL Compute Shader in a String. |
workgroupCountX
|
String | Workgroup amount in X. |
workgroupCountY
|
String | Workgroup amount in Y. |
workgroupCountZ
|
String | Workgroup amount in Z. |
init
|
function | Method to add custom
uniforms or storage (points.set* methods).
This is made for post processing multiple |
- Source:
- RenderPass.js, line 29
Examples
import Points, { RenderPass } from 'points';
// vert, frag and compute are strings with the wgsl shaders.
let renderPasses = [
new RenderPass(vert1, frag1, compute1),
new RenderPass(vert2, frag2, compute2)
];
// we pass the array of renderPasses
await points.init(renderPasses);
const waves = new RenderPass(vertexShader, fragmentShader, null, 8, 8, 1, (points, params) => { points.setSampler('renderpass_feedbackSampler', null); points.setTexture2d('renderpass_feedbackTexture', true); points.setUniform('waves_scale', params.scale || .45); points.setUniform('waves_intensity', params.intensity || .03); }); waves.required = ['scale', 'intensity'];
init param example
Members
computeShader
get the compute shader content
- Source:
- RenderPass.js, line 140
fragmentShader
get the fragment shader content
- Source:
- RenderPass.js, line 147
index
Get the current RenderPass index order in the pipeline. When you add a RenderPass to the constructor or via Points#addRenderPass, this is the order it receives.
- Source:
- RenderPass.js, line 122
instanceCount
Number of instances that will be created of the current mesh (Vertex Buffer)
in this RenderPass. This means if you have a quad, it will create
instanceCount
number of independent quads on the screen.
Useful for instanced particles driven by a Storage buffer.
- Source:
- RenderPass.js, line 315
required
List of buffer names that are required for this RenderPass so if it shows them in the console.
- Source:
- RenderPass.js, line 304
vertexShader
get the vertex shader content
- Source:
- RenderPass.js, line 133
workgroupCountX
How many workgroups are in the X dimension.
- Source:
- RenderPass.js, line 238
workgroupCountX
- Source:
- RenderPass.js, line 245
workgroupCountY
How many workgroups are in the Y dimension.
- Source:
- RenderPass.js, line 252
workgroupCountY
- Source:
- RenderPass.js, line 259
workgroupCountZ
How many workgroups are in the Z dimension.
- Source:
- RenderPass.js, line 266
workgroupCountZ
- Source:
- RenderPass.js, line 273
Methods
init(points, params)
Function where the init
parameter (set in the constructor) is executed
and this call will pass the parameters that the RenderPass
requires to run.
Parameters:
Name | Type | Description |
---|---|---|
points
|
Points | instance of Points to call set* functions like Points#setUniform and others. |
params
|
Object | data that can be assigned to the RenderPass when the Points#addRenderPass method is called. |
- Source:
- RenderPass.js, line 286