RealityServer Features

Rendering

To pre-render all of the required components for compositing you must use the compositor_render_componets command. This command works in a similar way to regular rendering commands but takes additional parameters to specify what things you want to separate for later tinting. Let's take a simple example.

{"jsonrpc": "2.0", "method": "compositor_render_components", "params": {
    "allow_texturing" : true,
    "elements" : [
        {
            "item" : "test_area_grp_inst",
            "item_is_handle" : false,
            "separate_direct_and_indirect" : true,
            "scattering_events" : [
                {
                    "type" : "reflection",
                    "mode" : "diffuse"
                },
                {
                    "type" : "reflection",
                    "mode" : "specular"
                }
            ]
        },
        {
            "item" : "fixed_area_grp_inst",
            "item_is_handle" : false,
            "separate_direct_and_indirect" : true,
            "scattering_events" : [
                {
                    "type" : "reflection",
                    "mode" : "glossy"
                }
            ]
        }
    ],
    "composite_name" : "ex_composite",
    "scene_name" : "ex_scene"
}, "id": 1}

This command will render the components for our composite and separates contributions from two instances in the scene, test_area_grp_inst and fixed_area_grp_inst. For the first we further pull out two scattering events, one for the diffuse reflection and another for the specular reflection. On the second instance we just get the glossy reflection. We further have specified to separate the direct and indirect contributions. Finally we have also specified that texturing should be allowed which will cause an additional UV map to be created so we can texture our tints later.

With the given options this rendering operation will produce eight images for each of the object events, direct and indirect, the UV map and finally one more image for the residual (everything not captured by the other channels).

The command assumes the scene passed in as the scene_name parameter is setup and ready to render, with all settings and termination conditions you want to use already applied.

The command does not return an image but rather returns a copy of the compositing data that gets stored in RealityServer and more importantly, a template object for use later on in your compositing operations. This template is returned in the operation_template field of the response map and will look something like this:

{
    "camera_attributes": {},
    "lights": {},
    "objects": {
        "fixed_area_grp_inst": {
            "glossy_reflection": {
                "direct": {},
                "indirect": {}
            }
        },
        "test_area_grp_inst": {
            "diffuse_reflection": {
                "direct": {},
                "indirect": {}
            },
            "specular_reflection": {
                "direct": {},
                "indirect": {}
            }
        }
    }
}

This provides the same struture that will later be used in the operations of the compositor_composite_components command. You just need to add tint values to each of the components you want to modify. We'll go into that a bit later.

You can expand further by also specifying lights to separate (you can also specify lights alone if you just want to varying lighting and not materials). Note that for lights you cannot separate the direct and indirect so the resulting tints are made one level higher in the operation when compositing. Here is an example which also lets you tune a light:

{"jsonrpc": "2.0", "method": "compositor_render_components", "params": {
    "allow_texturing" : true,
    "elements" : [
        {
            "item" : "test_area_grp_inst",
            "item_is_handle" : false,
            "separate_direct_and_indirect" : true,
            "scattering_events" : [
                {
                    "type" : "reflection",
                    "mode" : "diffuse"
                },
                {
                    "type" : "reflection",
                    "mode" : "specular"
                }
            ]
        },
        {
            "item" : "fixed_area_grp_inst",
            "item_is_handle" : false,
            "separate_direct_and_indirect" : true,
            "scattering_events" : [
                {
                    "type" : "reflection",
                    "mode" : "glossy"
                }
            ]
        }
    ],
    "lights" : [
        "overhead_light_inst", "bounce_light_1_inst",
        "bounce_light_2_inst", "bounce_light_3_inst", "bounce_light_4_inst"
    ],
    "composite_name" : "ex_composite",
    "scene_name" : "ex_scene"
}, "id": 1}

This adds an array of lights which we also want to manipulate. Note that when combining lights and element lists together the number of buffers required multiplies significantly. You should only specify what you actually know you need to manipulate, not everything you might ever want to control. You can always re-render the composite later if you need to add things.