Engine API Reference - v2.24.0-beta.28
    Preparing search index...

    Function drawQuadWithShader

    • Draws a quad with a shader into a render target, covering the whole render target, or the viewport rectangle. It draws immediately, outside of the frame graph: each call creates a RenderPassShaderQuad, renders it, and destroys it, so it allocates on every call. This suits a single draw, for example to generate a texture once. To draw a quad every frame, as part of a frame, or with its own render states, use a RenderPassShaderQuad instead, which is created once and reused.

      The content of the render target is loaded, and not cleared. The quad is drawn with the blend state currently set on the graphics device, see GraphicsDevice#setBlendState, and without depth test, face culling or stencil. The parameters of the shader are set on the scope of the graphics device before the call, see GraphicsDevice#scope.

      Parameters

      • device: GraphicsDevice

        The graphics device used to draw the quad.

      • target: RenderTarget | null

        The render target to draw into, or null to draw into the back buffer.

      • shader: Shader

        The shader used for rendering the quad. Its vertex shader receives the corners of the quad in an attribute using SEMANTIC_POSITION, which the quadVS shader chunk implements, see RenderPassShaderQuad.

      • Optionalrect: Vec4

        The viewport rectangle of the quad, in pixels. Defaults to fullscreen: [0, 0, target.width, target.height].

      • OptionalscissorRect: Vec4

        The scissor rectangle of the quad, in pixels. Defaults to the viewport rectangle.

      • Optionalname: string

        The render pass name used for GPU profiling and debugging. Defaults to 'RenderPassQuad'.

      Returns void

      // generate a texture once, by drawing a shader into its render target
      device.scope.resolve('uScale').setValue(4);
      drawQuadWithShader(device, renderTarget, shader);