Skip to main content

Using GPU parameters

GPU parameters control culling, depth and stencil tests, blending, and rasterization. Choose the owner from when the value needs to change:

StateWhere to set itWhen it can change
Culling, depth tests, blending, multisamplingRenderPipelineProps.parametersCreate a different pipeline; Engine Model.setParameters() manages this for you.
Clear values and read-only attachmentsRenderPassPropsBegin a new pass.
Viewport, scissor rectangle, blend constant, stencil referencerenderPass.setParameters()Between draws in the same pass.

Configure a model​

model.setParameters({
depthWriteEnabled: true,
depthCompare: 'less-equal',
cullMode: 'back'
});

const renderPass = device.beginRenderPass({
clearColor: [0, 0, 0, 1],
clearDepth: 1
});
model.draw(renderPass);
renderPass.end();
device.submit();

The target must have a depth attachment compatible with the pipeline's depthFormat. Inside AnimationLoop.onRender, the loop handles submission.

Change a viewport between draws​

renderPass.setParameters({viewport: [0, 0, 800, 600]});
model.draw(renderPass);
renderPass.setParameters({viewport: [600, 0, 200, 150]});
model.draw(renderPass);

Viewport and scissor coordinates use drawing-buffer pixels, not CSS pixels. Use scissorRect to restrict writes; changing a viewport alone does not clip to its rectangle.

Next steps​