Esempio n. 1
0
void renderLightVolume(const MVPPipeline &program, const PointLight &light)
{
    Matrix4x4f modelMatrix = Matrix4x4f::identity();
    modelMatrix = modelMatrix.translate(light.position);
    float scale = calcPointLightScale(light);
    modelMatrix = modelMatrix.scale({scale, scale, scale});
    glUniformMatrix4fv(program.modelMatrix, 1, GL_FALSE, modelMatrix.const_value_ptr());

    Matrix4x4f viewMatrix = camera.getMatrix();
    glUniformMatrix4fv(program.viewMatrix, 1, GL_FALSE, viewMatrix.const_value_ptr());

    Matrix4x4f projectionMatrix = Matrix4x4f::perspective(60.0f, WINDOW_WIDTH * 1.0f / WINDOW_HEIGHT, 1.0f, 100.0f);
    glUniformMatrix4fv(program.projectionMatrix, 1, GL_FALSE, projectionMatrix.const_value_ptr());

    pSphereMesh->Render();
}
Esempio n. 2
0
void renderDirectionalLightPass()
{
    glDisable(GL_DEPTH_TEST);
    glDepthMask(GL_FALSE);
    glCullFace(GL_FRONT);
    glUseProgram(directionalLightPass.program);

    Matrix4x4f identity = Matrix4x4f::identity();
    glUniformMatrix4fv(directionalLightPass.modelMatrix, 1, GL_FALSE, identity.const_value_ptr());
    glUniformMatrix4fv(directionalLightPass.viewMatrix, 1, GL_FALSE, identity.const_value_ptr());
    glUniformMatrix4fv(directionalLightPass.projectionMatrix, 1, GL_FALSE, identity.const_value_ptr());

    directionalLightPass.bindUniforms();
    directionalLightPass.directionalLight.setDirectionalLight(directionalLight);

    pQuadMesh->Render();

    glUseProgram(0);
}
Esempio n. 3
0
void renderScene()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glUseProgram(geometryPass.program);

    Matrix4x4f viewMatrix = camera.getMatrix();
    glUniformMatrix4fv(geometryPass.viewMatrix, 1, GL_FALSE, viewMatrix.const_value_ptr());

    Matrix4x4f projectionMatrix = Matrix4x4f::perspective(60.0f, WINDOW_WIDTH * 1.0f / WINDOW_HEIGHT, 1.0f, 100.0f);
    glUniformMatrix4fv(geometryPass.projectionMatrix, 1, GL_FALSE, projectionMatrix.const_value_ptr());

    glUniform1i(geometryPass.textureSampler, 0);
    for (size_t i = 0; i < sizeof(boxPositions) / sizeof(boxPositions[0]); i++) {
        Matrix4x4f modelMatrix = Matrix4x4f::identity().translate(boxPositions[i]).rotatey(m_scale);
        glUniformMatrix4fv(geometryPass.modelMatrix, 1, GL_FALSE, modelMatrix.const_value_ptr());
        pBoxMesh->Render();
    }

    glUseProgram(0);
}