2

I am investigating some advanced rendering in Scenekit, and what SCNTechnique and SCNProgram can be used for.

I would like to implement a multi-pass render like so:

  1. First; render the full scene using the in-built PBR shader,
  2. Second; render a single node with a SCNProgram which accesses both the colour and depth output from the first pass.

I know I can do something like the following with a SCNTechnique:

...
    <key>passes</key>
    <dict>
        <key>pass_scene</key>
        <dict>
            <key>draw</key>
            <string>DRAW_SCENE</string>
            <key>excludeCategoryMask</key>
            <string>The bit mask of the node to exclude</string>
            <key>outputs</key>
            <dict>
                <key>color</key>
                <string>COLOR</string>
                <key>depth</key>
                <string>DEPTH</string>
            </dict>
        </dict>
        <key>pass_object</key>
        <dict>
            <key>draw</key>
            <string>DRAW_SCENE</string>
            <key>includeCategoryMask</key>
            <string>The bit mask of the node to exclude</string>
            <key>inputs</key>
            <dict>
                <key>color</key>
                <string>COLOR</string>
                <key>depth</key>
                <string>DEPTH</string>
            </dict>
            <key>outputs</key>
            <dict>
                <key>color</key>
                <string>COLOR</string>
            </dict>
            <key>metalVertexShader</key>
            <string>myCustomVertShader</string>
            <key>metalFragmentShader</key>
            <string> myCustomFragShader </string>
        </dict>
    </dict>
    <key>sequence</key>
    <array>
        <string>pass_scene</string>
        <string>pass_object</string>
    </array>
...

But I would like to use a SCNProgram for the object render, instead of specifying metalVertexShader & metalFragmentShader in the SCNTechnique.

I can't figure out how to pass through the colour and depth buffers from the first pass of the SCNTechnique into the SCNProgram for a second pass.

Does anyone know how to go about this? The documentation is difficult to piece together, and hard to debug issues.

Nick
  • 261
  • 2
  • 8

0 Answers0