---
title: SCNTechnique
framework: scenekit
role: symbol
role_heading: Class
path: scenekit/scntechnique
---

# SCNTechnique

A specification for augmenting or postprocessing SceneKit’s rendering of a scene using additional drawing passes with custom Metal or OpenGL shaders.

## Declaration

```swift
class SCNTechnique
```

## Overview

Overview Examples of multipass rendering techniques include: Postprocessing rendered pixels. To create effects such as color grading and displacement mapping, define techniques that use as input the color buffer rendered by SceneKit and process that buffer with a fragment shader. Deferred shading. To create effects such as motion blur and screen-space ambient occlusion (SSAO), define techniques that capture information about the scene into an intermediary buffer during the main rendering pass and then perform additional drawing passes using that buffer to create the final output image. The figure below illustrates the rendering process for an SSAO technique.

To create an SCNTechnique object, you supply a technique definition that specifies the input and output image buffers, shader programs, shader input variables, and rendering options for each drawing pass in the technique. Defining a technique does not require Metal or OpenGL client code, but you should be familiar with the terminology and conventions of GPU rendering. To use a technique, assign it to the technique property of a view (or other SceneKit renderer object) or a camera. Defining a Technique SceneKit treats rendering techniques—along with shaders, 3D models, and 2D art assets—as resources rather than as part of your application code. Because the effects you create with techniques are highly visual, this approach allows you to separate design efforts from development efforts and quickly iterate on creating the visual content of your app or game. Create a technique object using the init(dictionary:) method, providing a dictionary that defines the technique as a series of drawing passes, each with its own shader program, inputs and outputs, and rendering options. Typically, you obtain this dictionary from a property list file included in your app’s bundle resources. Table 1 and the additional tables and sections that follow specify the format of this dictionary’s contents.  |   |   |   |   |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |  Category Masks When SceneKit performs a rendering pass whose draw option is DRAW_SCENE or DRAW_NODE, you can use category masks to filter the set of nodes drawn during that pass. For each node in the scene (or for DRAW_NODE, in the node subtree), SceneKit compares the node’s categoryBitMask property and the includeCategoryMask and excludeCategoryMask options in the pass definition using bitwise AND operations. If the node’s category mask and the include mask overlap (that is, the bitwise AND results in a nonzero value) and the node’s category mask and the exclude mask do not overlap, SceneKit includes the node in the drawing pass. Otherwise the node is not rendered in the pass. Render Targets, Inputs and Outputs A drawing pass renders pixel data into one or more target image buffer (or framebuffer). In SceneKit’s main drawing pass, the color render target is the screen (or rather, a view or layer for screen display), and a depth render target temporarily stores the information needed to ensure that rendered surfaces appear in the correct depth order. A pass in a custom rendering technique may postprocess the pixel data in SceneKit’s render target, generate its own pixel data for display, or render to an intermediate target to be used as input in a later pass. You specify render targets using the following identifiers in the inputs and outputs dictionaries of a pass definition: Use the COLOR and DEPTH targets as inputs to identify the color and depth buffers rendered to in SceneKit’s main drawing pass. Use the COLOR target as an output to identify the image buffer displayed as the end result of a technique. To create an intermediate target, define your own identifier as a key in the targets dictionary of a technique definition. For the corresponding value, provide a dictionary defining the render target using the keys and values in Table 5. Intermediate targets may be color, depth, or combined depth and stencil buffers. After you define a target, you can use its identifier in the inputs and outputs dictionaries of a pass definition. To use an image as an input texture for a pass, define a symbol of type sampler2D in the technique’s symbols dictionary. To specify a render target or image sampler in the inputs dictionary of a pass definition, you can provide either an identifier string or a dictionary with the format described in Table 6. The options for samplers correspond to similar properties for SceneKit material textures. For more details on each, see SCNMaterialProperty.  |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |  Blending The blendStates key of a pass definition defines color blending options. Blending is disabled by default for faster rendering performance. Including a dictionary for this key enables blending (unless the dictionary’s enable key specifies false). Color blending combines a source color (the color output by the drawing pass’s shader program) with a destination color (the existing contents of the output buffer) using specified modes and operations. Available blend modes (for the colorSrc, colorDst, alphaSrc, and alphaDst keys): zero, one, srcColor, oneMinusSrcColor, srcAlpha, oneMinusSrcAlpha, dstColor, oneMinusDstColor, dstAlpha, oneMinusDstAlpha, constantColor, oneMinusConstantColor, constantAlpha, oneMinusConstantAlpha, and alphaSaturate. Available blend operations (for the colorOp and alphaOp keys): add, subtract, reverseSubtract, min, max. These values correspond to blending options defined by the OpenGL specification. For further details, consult the OpenGL API Registry or OpenGL ES API Registry. Example Technique Definition Listing 1 shows an example definition dictionary for a technique that uses displacement mapping with a noise texture to postprocess a rendered scene. For ease of reading, the dictionary is formatted in JSON syntax. (To load an NSDictionary object from text in this format, use the JSONSerialization class.) Listing 2 and Listing 3 show the GLSL source code for the technique’s vertex and fragment shaders. Listing 1. JSON definition dictionary for a technique {   "passes" : {     "displacement" : {       "outputs" : {         "color" : "COLOR"       },       "inputs" : {         "colorSampler" : "COLOR",         "noiseSampler" : "noiseSymbol",         "a_position" : "a_position-symbol"       },       "program" : "displacement",       "draw" : "DRAW_QUAD"     }   },   "sequence" : [     "displacement"   ],   "symbols" : {     "a_position-symbol" : {       "semantic" : "vertex"     },     "noiseSymbol" : {       "image" : "noise.png",       "type" : "sampler2D"     }   } } Listing 2. GLSL Vertex shader source code for displacement mapping technique attribute vec4 a_position; varying vec2 uv;   void main() {     gl_Position = a_position;     uv = (a_position.xy + 1.0) * 0.5; } Listing 3. GLSL Fragment shader source code for displacement mapping technique uniform sampler2D colorSampler; uniform sampler2D noiseSampler;   varying vec2 uv;   void main() {     vec2 displacement = texture2D(noiseSampler, uv).rg - vec2(0.5, 0.5);     gl_FragColor = texture2D(colorSampler, uv + displacement * vec2(0.1,0.1)); }

## Topics

### Creating a Technique

- [init(dictionary:)](scenekit/scntechnique/init(dictionary:).md)

### Combining Techniques

- [init(bySequencingTechniques:)](scenekit/scntechnique/init(bysequencingtechniques:).md)

### Retrieving a Technique’s Definition

- [dictionaryRepresentation](scenekit/scntechnique/dictionaryrepresentation.md)

### Handling Parameters for a Technique’s Shader Programs

- [handleBinding(ofSymbol:using:)](scenekit/scntechnique/handlebinding(ofsymbol:using:).md)
- [setObject(_:forKeyedSubscript:)](scenekit/scntechnique/setobject(_:forkeyedsubscript:).md)
- [subscript(_:)](scenekit/scntechnique/subscript(_:).md)

### Initializers

- [init(coder:)](scenekit/scntechnique/init(coder:).md)

### Instance Properties

- [library](scenekit/scntechnique/library.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [SCNAnimatable](scenekit/scnanimatable.md)

## See Also

### Renderer Customization

- [SCNShadable](scenekit/scnshadable.md)
- [SCNProgram](scenekit/scnprogram.md)
- [SCNBufferStream](scenekit/scnbufferstream.md)
- [SCNTechniqueSupport](scenekit/scntechniquesupport.md)
- [SCNNodeRendererDelegate](scenekit/scnnoderendererdelegate.md)
- [Postprocessing a Scene With Custom Symbols](scenekit/postprocessing-a-scene-with-custom-symbols.md)
