Exemplo n.º 1
0
int main()
{
    FastStack<int> stack;

    cout << "Size: " << stack.size() << endl;
    cout << "Max: "  << stack.max () << endl;
    cout << "Min: "  << stack.min () << endl;

    int vals[] = {1, 100, 11, -1, 1115};

    for (int i = 0; i < sizeof(vals)/sizeof(int); ++i)
    {
        stack.push(*(vals + i));
        cout << "Size: " << stack.size() << endl;
        cout << "Max: "  << stack.max () << endl;
        cout << "Min: "  << stack.min () << endl;
    }

    return 0;
}
Exemplo n.º 2
0
glm::vec4 BRDF::sampleColor(FastStack<Ray> & rays, const Ray ray, const Intersection & result, Scene * scene) {
    glm::vec4 position = result.surface->worldTransform * result.surface->samplePosition(result.index, result.coord);
    glm::vec4 normal = glm::normalize(
            result.surface->worldTransformIT * result.surface->sampleNormal(result.index, result.coord));

    float p = SampleUniform();
    glm::vec4 totalColor(0.f, 0.f, 0.f, 0.f);

    if (p < emissiveProbability) {
        totalColor = emissiveIntensity * emissiveColor / emissiveProbability;
    }
    else if (ray.depth < maxDepth) {
        glm::vec4 strength = ray.strength * diffuseColor;
        glm::vec4 outgoing = SampleHemi(normal);
        Ray reflected(ray.depth + 1, position, outgoing, strength, PAC_EPSILON);
        rays.push(reflected);
    }
    else {
        totalColor.a = 1.f;
    }

    return totalColor * ray.strength;
}