Commit 0034e5c4 authored by Jakob Weiss's avatar Jakob Weiss
Browse files

Local Light Sources, Extended ImageMappingInformation

* Light sources now have an additional camera input. If this is set, the light source position is relative to the camera coordinate system
* ImageMappingInformation and Texture3D now supply an additional pair of matrices: textureToWorldMatrixInvTransp to transform normals between world and texture space
parent 31ba23bf
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ namespace campvis {
        _textureToWorldTransformation = _customTransformation * cgt::mat4::createTranslation(_offset) * cgt::mat4::createScale(_voxelSize * _size);
        if (! _textureToWorldTransformation.invert(_worldToTextureTransformation))
            cgtAssert(false, "Could not invert texture-to-world matrix. That should not happen!");
        _textureToWorldTransformationInvTransp = cgt::transpose(_worldToTextureTransformation);
        _worldToTextureTransformation = cgt::transpose(_textureToWorldTransformation);

        _voxelToWorldTransformation = _customTransformation * cgt::mat4::createTranslation(_offset) * cgt::mat4::createScale(_voxelSize);
        if (! _voxelToWorldTransformation.invert(_worldToVoxelTransformation))
@@ -76,10 +78,20 @@ namespace campvis {
        return _textureToWorldTransformation;
    }

    const cgt::mat4 & ImageMappingInformation::getTextureToWorldMatrixInvTransp() const
    {
        return _textureToWorldTransformationInvTransp;
    }

    const cgt::mat4& ImageMappingInformation::getWorldToTextureMatrix() const {
        return _worldToTextureTransformation;
    }

    const cgt::mat4 & ImageMappingInformation::getWorldToTextureMatrixInvTransp() const
    {
        return _worldToTextureTransformationInvTransp;
    }

    const cgt::mat4& ImageMappingInformation::getVoxelToWorldMatrix() const {
        return _voxelToWorldTransformation;
    }
+17 −0
Original line number Diff line number Diff line
@@ -90,12 +90,26 @@ namespace campvis {
         */
        const cgt::mat4& getTextureToWorldMatrix() const;

        /**
        * Gets the inverse of the transpose of the the transformation matrix
        * from texture to world coordinates.
        * \return  _textureToWorldTransformation
        */
        const cgt::mat4& getTextureToWorldMatrixInvTransp() const;

        /**
         * Gets the transformation matrix from world to texture coordinates.
         * \return  _worldToTextureTransformation
         */
        const cgt::mat4& getWorldToTextureMatrix() const;

        /**
        * Gets the inverse of the transpose of the transformation matrix
        * from world to texture coordinates.
        * \return  _worldToTextureTransformation
        */
        const cgt::mat4& getWorldToTextureMatrixInvTransp() const;

        /**
         * Gets the transformation matrix from voxel to world coordinates.
         * \return  _voxelToWorldTransformation
@@ -134,6 +148,9 @@ namespace campvis {
        cgt::mat4 _textureToWorldTransformation;        ///< Transformation matrix from texture to world coordinates
        cgt::mat4 _worldToTextureTransformation;        ///< Transformation matrix from world to texture coordinates

        cgt::mat4 _textureToWorldTransformationInvTransp;///< Transformation matrix from texture to world coordinates
        cgt::mat4 _worldToTextureTransformationInvTransp;///< Transformation matrix from world to texture coordinates

        cgt::mat4 _voxelToWorldTransformation;        ///< Transformation matrix from voxel to world coordinates
        cgt::mat4 _worldToVoxelTransformation;        ///< Transformation matrix from world to voxel coordinates
    };
+3 −1
Original line number Diff line number Diff line
@@ -169,6 +169,8 @@ namespace campvis {
                shader->setUniform(texParamsUniform + "._voxelSizeRCP", cgt::vec3(1.f) / _parent->getMappingInformation().getVoxelSize());
                shader->setUniform(texParamsUniform + "._textureToWorldMatrix", _parent->getMappingInformation().getTextureToWorldMatrix());
                shader->setUniform(texParamsUniform + "._worldToTextureMatrix", _parent->getMappingInformation().getWorldToTextureMatrix());
                shader->setUniform(texParamsUniform + "._textureToWorldMatrixInvTransp", _parent->getMappingInformation().getTextureToWorldMatrixInvTransp());
                shader->setUniform(texParamsUniform + "._worldToTextureMatrixInvTransp", _parent->getMappingInformation().getWorldToTextureMatrixInvTransp());
                break;

            default:
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ const float positiveInfinity = 1.0 / 0.0;
 * Code adapted from: https://www.marcusbannerman.co.uk/index.php/component/content/article/42-articles/97-vol-render-optimizations.htm
 */
void jitterEntryPoint(inout vec3 position, in vec3 direction, in float stepSize) {
    float random = fract(sin(gl_FragCoord.x * 12.9898 + gl_FragCoord.y * 78.233) * 43758.5453);
    float random = fract(sin(gl_FragCoord.x * 12.9898 + gl_FragCoord.y * 78.233) * 43758.5453) - 0.5;
    position = position + direction * (stepSize * random);
}

+4 −0
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@ struct TextureParameters3D {
    // Transformation matrices
    mat4 _textureToWorldMatrix;
    mat4 _worldToTextureMatrix;

    // inverse of transpose of the respective matrices, used to transform normals
    mat4 _textureToWorldMatrixInvTransp;
    mat4 _worldToTextureMatrixInvTransp;
};

/**
Loading