  * Traces a ray through a pixel.
  *
  * @param pixel     Pixel in projection space (x, y) e [-1, 1]
+ * @param rsi       Random seed index offset.
+ *
  * @returns Color.
  */
-vec3 trace_through(const vec2 pixel) {
+vec3 trace_through(const vec2 pixel, inout int rsi) {
 
     // Pixel in camera space
     vec3 p = vec3(camera_projection_matrix_inverse * vec4(pixel, 0, 1));


    if (material.type == MATERIAL_LAMBERT) {

        vec3 albedo = vec3(sample_1d(

            material_lambert_color, material.index, N_MATERIAL_LAMBERT
        ));

        P = brdf_lambert(albedo);
    }

    return P;
}


/**
 * Bounces a ray off a lambertian surface.

/**
 * Traces a ray through the scene.
 *
 * @param rsi   Random seed index offset.
 *
 * @returns Color.
 */
vec3 trace(Ray ray, inout int rsi) {

    vec3 color = vec3(0, 0, 0);
    vec3 weight = vec3(1, 1, 1);

    Collision collision;

    for (int depth = 0; depth >= 0; depth++) {

        if (depth >= MAX_DEPTH) { break; }

        collision = raycast(ray);

        if (!collision.exists) { break; }

        evaluate_material(collision.material);

        vec3 collision_point = ray.origin + ray.direction * collision.t;
        vec3 P = brdf(collision.material, ray.direction, collision.normal);
