Ejemplo n.º 1
0
void RenderableGalaxy::postRender(const RenderData& data) {

    _raycaster->setStepSize(_pointStepSize);

    _pointsProgram->activate();
    setPscUniforms(*_pointsProgram.get(), data.camera, data.position);

    OsEng.ref().renderEngine().preRaycast(*_pointsProgram);

    glm::mat4 modelMatrix = _pointTransform;
    glm::mat4 viewMatrix = data.camera.viewMatrix();
    glm::mat4 projectionMatrix = data.camera.projectionMatrix();

    _pointsProgram->setUniform("model", modelMatrix);
    _pointsProgram->setUniform("view", viewMatrix);
    _pointsProgram->setUniform("projection", projectionMatrix);

    float emittanceFactor = _opacityCoefficient * static_cast<glm::vec3>(_volumeSize).x;
    _pointsProgram->setUniform("emittanceFactor",  emittanceFactor);

    glBindVertexArray(_pointsVao);
    glDisable(GL_DEPTH_TEST);
    glDepthMask(false);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    glDrawArrays(GL_POINTS, 0, _nPoints * _enabledPointsRatio);
    glBindVertexArray(0);
    glDepthMask(true);
    glEnable(GL_DEPTH_TEST);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    OsEng.ref().renderEngine().postRaycast(*_pointsProgram);
}
void RenderablePlaneProjection::render(const RenderData& data) {
	bool active = ImageSequencer2::ref().instrumentActive(_instrument);
	if (!_hasImage || (_moving && !active))
		return;

	glm::mat4 transform = glm::mat4(1.0);

	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
		}
	}

	// Activate shader
	_shader->activate();

	_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
	_shader->setUniform("ModelTransform", transform);
	setPscUniforms(_shader.get(), &data.camera, data.position);

	ghoul::opengl::TextureUnit unit;
	unit.activate();
	_texture->bind();
	_shader->setUniform("texture1", unit);

	glBindVertexArray(_quad);
	glDrawArrays(GL_TRIANGLES, 0, 6);

	_shader->deactivate();

}
void RenderableSphericalGrid::render(const RenderData& data){
    _gridProgram->activate();

    glm::mat4 transform;
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            transform[i][j] = static_cast<float>(_parentMatrix[i][j]);
        }
    }


    using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;

    // setup the data to the shader
    _gridProgram->setIgnoreUniformLocationError(IgnoreError::Yes);
    _gridProgram->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
    _gridProgram->setUniform("ModelTransform", transform);
    setPscUniforms(*_gridProgram, data.camera, data.position);
    _gridProgram->setUniform("gridColor", _gridColor);

    glLineWidth(0.5f);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glEnable(GL_LINE_SMOOTH);

    glBindVertexArray(_vaoID);  // select first VAO
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
    glDrawElements(_mode, _isize, GL_UNSIGNED_INT, 0);
    glBindVertexArray(0);

    _gridProgram->deactivate();
}
Ejemplo n.º 4
0
void RenderableStars::render(const RenderData& data) {
    glDepthMask(false);
    _program->activate();

    // @Check overwriting the scaling from the camera; error as parsec->meter conversion
    // is done twice? ---abock
    glm::vec2 scaling = glm::vec2(1, -19);  

    glm::mat4 modelMatrix = glm::mat4(1.0);
    glm::mat4 viewMatrix       = data.camera.viewMatrix();
    glm::mat4 projectionMatrix = data.camera.projectionMatrix();

    using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
    _program->setIgnoreUniformLocationError(IgnoreError::Yes);
    //_program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
    //_program->setUniform("ModelTransform", glm::mat4(1.f));
    _program->setUniform("model", modelMatrix);
    _program->setUniform("view", viewMatrix);
    _program->setUniform("projection", projectionMatrix);

    _program->setUniform("colorOption", _colorOption);
    _program->setUniform("alphaValue", _alphaValue);
    _program->setUniform("scaleFactor", _scaleFactor);
    _program->setUniform("minBillboardSize", _minBillboardSize);
    
    setPscUniforms(*_program.get(), data.camera, data.position);
    _program->setUniform("scaling", scaling);

    ghoul::opengl::TextureUnit psfUnit;
    psfUnit.activate();
    if (_pointSpreadFunctionTexture)
        _pointSpreadFunctionTexture->bind();
    _program->setUniform("psfTexture", psfUnit);

    ghoul::opengl::TextureUnit colorUnit;
    colorUnit.activate();
    if (_colorTexture)
        _colorTexture->bind();
    _program->setUniform("colorTexture", colorUnit);

    glBindVertexArray(_vao);
    const GLsizei nStars = static_cast<GLsizei>(_fullData.size() / _nValuesPerStar);
    glDrawArrays(GL_POINTS, 0, nStars);

    glBindVertexArray(0);
    using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
    _program->setIgnoreUniformLocationError(IgnoreError::No);
    _program->deactivate();
    
    glDepthMask(true);
}
Ejemplo n.º 5
0
void RenderableDebugPlane::render(const RenderData& data) {
    glm::mat4 transform = glm::mat4(1.0);
    if (_billboard)
        transform = glm::inverse(glm::mat4(data.camera.viewRotationMatrix()));

    // Activate shader
    _shader->activate();

    _shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
    _shader->setUniform("ModelTransform", transform);
    setPscUniforms(*_shader.get(), data.camera, data.position);

    ghoul::opengl::TextureUnit unit;
    unit.activate();
    glBindTexture(GL_TEXTURE_2D, _texture);
    _shader->setUniform("texture1", unit);

    glBindVertexArray(_quad);
    glDrawArrays(GL_TRIANGLES, 0, 6);

    _shader->deactivate();
}
Ejemplo n.º 6
0
void RenderableCrawlingLine::render(const RenderData& data) {
    if (_drawLine) {
        _program->activate();
        _frameCounter++;
        // fetch data
        psc currentPosition = data.position;
        psc campos = data.camera.position();
        glm::mat4 camrot = data.camera.viewRotationMatrix();

        glm::mat4 transform = glm::mat4(1);

        // setup the data to the shader
        _program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
        _program->setUniform("ModelTransform", transform);

        int frame = _frameCounter % 60;
        float fadingFactor = static_cast<float>(sin((frame * pi_c()) / 60));
        float alpha = 0.6f + fadingFactor*0.4f;

        glLineWidth(2.f);

        _program->setUniform("_alpha", alpha);
        _program->setUniform("color", _lineColor);
        setPscUniforms(_program, &data.camera, data.position);

        glBindVertexArray(_vao);
        glBindBuffer(GL_ARRAY_BUFFER, _vbo);
        glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(psc) * 2, _positions);

        glEnableVertexAttribArray(0);
        glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);

        glDrawArrays(GL_LINES, 0, 2);
        glBindVertexArray(0);
    
        _program->deactivate();
    }
}
Ejemplo n.º 7
0
void RenderableFieldlines::render(const RenderData& data) {
    _program->activate();
    _program->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
    _program->setUniform("modelTransform", glm::mat4(1.0));
    _program->setUniform("cameraViewDir", glm::vec3(data.camera.viewDirectionWorldSpace()));
    glDisable(GL_CULL_FACE);
    setPscUniforms(*_program, data.camera, data.position);

    _program->setUniform("classification", _classification);
    if (!_classification)
        _program->setUniform("fieldLineColor", _fieldlineColor);

    glBindVertexArray(_fieldlineVAO);
    glMultiDrawArrays(
        GL_LINE_STRIP_ADJACENCY,
        &_lineStart[0],
        &_lineCount[0],
        static_cast<GLsizei>(_lineStart.size())
    );
    glBindVertexArray(0);
    glEnable(GL_CULL_FACE);
    _program->deactivate();
}