Next: , Previous: , Up: Graphics   [Contents][Index]


5.3.16 Render Settings

5.3.16.1 Blending

Rendering a scene often involves drawing layers of objects that overlap each other. Blending determines how two overlapping pixels are combined in the final image that is rendered to the screen. The (chickadee graphics blend) module provides a data type for blending modes.

Chickadee provides the following blend modes:

Variable: blend:alpha

Blend pixels according to the values of their alpha channels. This is the most commonly used blend mode.

Variable: blend:replace

Overwrite the output pixel color with the color being drawn.

Variable: blend:add

Add all pixel color values together. The more colors blended together, the more white the final color becomes.

Variable: blend:subtract

Subtract all pixel color values. The more colors blended together, the more black the final color becomes.

Variable: blend:multiply
Variable: blend:darken
Variable: blend:lighten
Variable: blend:screen

Custom blend modes can be created using the make-blend-mode procedure:

Procedure: make-blend-mode equation source-function destination-function

Return a new custom blend mode that applies source-function to the source color, destination-function to the destination color, and finally applies equation to the transformed source/destination color values. These arguments are not procedures, but symbolic representations of the functions that OpenGL supports.

Valid values for equation are:

Valid values for source-function are:

Valid values for destination-function are:

5.3.16.2 Polygon Modes and Culling

The (chickadee graphics polygon) module provides access to the g:polygon-mode and g:cull-face-mode render states.

Variable: fill-polygon-mode

Completely fill in the polygon. This is the default mode.

Variable: line-polygon-mode

Render only the edges of the polygon. Produces a wireframe.

Variable: point-polygon-mode

Render only the vertex positions as points.

Procedure: make-polygon-mode front back

Return a new polygon mode that uses the method front for the front face and back for the back face. The valid modes are fill, line, and point.

Procedure: polygon-mode? obj

Return #t if obj is a polygon mode.

Procedure: current-polygon-mode

Return the current polygon mode.

Variable: g:polygon-mode

Render state for polygon modes (see Rendering Engine.)

Variable: no-cull-face-mode

Don’t cull any faces.

Variable: back-cull-face-mode

Cull only back faces.

Variable: front-cull-face-mode

Cull only front faces.

Variable: front-and-back-cull-face-mode

Cull both front and back faces.

Procedure: cull-face-mode? obj

Return #t if obj is a cull face mode.

Procedure: cull-face-mode-front? cull-face-mode

Return #t if cull-face-mode culls front faces.

Procedure: cull-face-mode-back? cull-face-mode

Return #t if cull-face-mode culls back faces.

Procedure: current-cull-face-mode

Return the current cull face mode.

Variable: g:cull-face-mode

Render state for cull face modes (see Rendering Engine.)

5.3.16.3 Depth Testing

The (chickadee graphics depth) module provides access to the g:depth-test render state.

Procedure: make-depth-test [#:write? #t] [#:function 'less-than] [#:near 0.0] [#:far 1.0]

Return a new depth test object. If write is #t, the depth buffer will be written to during a draw call. near and far define the min/max Z values for which depth testing may pass.

function specifies how the depth value of pixel being drawn compares to the depth value that is already in the depth buffer. When this comparison is true, the depth test passes and the pixel is drawn. When it fails, the pixel is discarded.

The possible values of function are:

Procedure: depth-test? obj

Return #t when obj is a depth test object.

Procedure: depth-test-write? depth-test

Return #t when depth-test will write to the depth buffer.

Procedure: depth-test-function depth-test

Return the comparison function of depth-test.

Procedure: depth-test-near depth-test

Return the near Z value of depth-test.

Procedure: depth-test-far depth-test

Return the far Z value of depth-test.

Procedure: current-depth-test

Return the current depth test.

Variable: g:depth-test

Render state for depth tests (see Rendering Engine.)

5.3.16.4 Stencil Testing

The (chickadee graphics stencil) module provides access to the g:stencil-test render state.

Variable: default-stencil-test

A stencil test that always passes.

Procedure: make-stencil-test [#:mask #xFF] [#:function always] [#:function-mask #xFF] [#:reference 0] [#:on-fail keep] [#:on-depth-fail keep] [#:on-pass keep] [#:mask-front mask] [#:mask-back mask] [#:function-mask-front function-mask] [#:function-mask-back function-mask] [#:refrence-front reference] [#:reference-back reference] [#:on-fail-front on-fail] [#:on-fail-back on-fail] [#:on-depth-fail-front on-depth-fail] [#:on-depth-fail-back on-depth-fail] [#:on-pass-front on-pass] [#:on-pass-back on-pass]

Return a new stencil test object. Different configurations can be used for the front and back faces by using the arguments that end in “front” or “back”.

Valid values for on-pass, on-fail, and on-depth-fail are:

Valid values for function are:

Procedure: stencil-test? obj

Return #t when obj is a stencil test object.

Procedure: stencil-test-mask-front stencil-test

Return the front mask of stencil-test.

Procedure: stencil-test-mask-back stencil-test

Return the back mask of stencil-test.

Procedure: stencil-test-function-front stencil-test

Return the front function of stencil-test.

Procedure: stencil-test-function-back stencil-test

Return the back function of stencil-test.

Procedure: stencil-test-function-mask-front stencil-test

Return the front function-mask of stencil-test.

Procedure: stencil-test-function-mask-back stencil-test

Return the back function-mask of stencil-test.

Procedure: stencil-test-reference-front stencil-test

Return the front reference value of stencil-test.

Procedure: stencil-test-reference-back stencil-test

Return the back reference value of stencil-test.

Procedure: stencil-test-on-fail-front stencil-test

Return the front failure action of stencil-test.

Procedure: stencil-test-on-fail-back stencil-test

Return the back failure action of stencil-test.

Procedure: stencil-test-on-depth-fail-front stencil-test

Return the front depth test failure action of stencil-test.

Procedure: stencil-test-on-depth-fail-back stencil-test

Return the back depth test failure action of stencil-test.

Procedure: stencil-test-on-pass-front stencil-test

Return the front pass action of stencil-test.

Procedure: stencil-test-on-pass-back stencil-test

Return the back pass action of stencil-test.

Procedure: current-stencil-test

Return the current stencil test.

Variable: g:stencil-test

Render state for stencil testing (see Rendering Engine.)

5.3.16.5 Multisample Antialiasing

Multisample antialiasing is a feature supported by many, but not all, graphics cards. It is a nice easy way to improve the final frame that the user sees, particularly in 3D scenes. The (chickadee graphics multisample) module provides access to the g:multisample? render state.

Procedure: current-multisample

Return #t if multisampling is enabled.

Variable: g:multisample?

Render state for multisampling (see Rendering Engine.)


Next: , Previous: , Up: Graphics   [Contents][Index]