History

Support for scaling splat textures in S and T, use mipmaps for them.

Andrzej Kapolka committed 12 years ago

Commit 2dfabdf1 parent 4f3f0989 files · +71 −11Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 9 files). Show all

Unified · Split

interface/src/MetavoxelSystem.cpp+23−1
@@ -822,22 +822,38 @@ void HeightfieldBuffer::render(bool cursor) { · 821 unmodified lines
822 DefaultMetavoxelRendererImplementation::getSplatHeightScaleLocation(), 1.0f / _heightSize);822 DefaultMetavoxelRendererImplementation::getSplatHeightScaleLocation(), 1.0f / _heightSize);
823 DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(823 DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(
824 DefaultMetavoxelRendererImplementation::getSplatTextureScaleLocation(), (float)_heightSize / innerSize);824 DefaultMetavoxelRendererImplementation::getSplatTextureScaleLocation(), (float)_heightSize / innerSize);
825 DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(
826 DefaultMetavoxelRendererImplementation::getSplatTextureOffsetLocation(),
827 _translation.x / _scale, _translation.z / _scale);
825 828
826 glBindTexture(GL_TEXTURE_2D, _textureTextureID);829 glBindTexture(GL_TEXTURE_2D, _textureTextureID);
827 830
828 const int TEXTURES_PER_SPLAT = 4;831 const int TEXTURES_PER_SPLAT = 4;
829 for (int i = 0; i < _textures.size(); i += TEXTURES_PER_SPLAT) {832 for (int i = 0; i < _textures.size(); i += TEXTURES_PER_SPLAT) {
833 QVector4D scalesS, scalesT;
834
830 for (int j = 0; j < SPLAT_COUNT; j++) {835 for (int j = 0; j < SPLAT_COUNT; j++) {
831 glActiveTexture(GL_TEXTURE0 + SPLAT_TEXTURE_UNITS[j]);836 glActiveTexture(GL_TEXTURE0 + SPLAT_TEXTURE_UNITS[j]);
832 int index = i + j;837 int index = i + j;
833 if (index < _networkTextures.size()) {838 if (index < _networkTextures.size()) {
834 const NetworkTexturePointer& texture = _networkTextures.at(index);839 const NetworkTexturePointer& texture = _networkTextures.at(index);
835 glBindTexture(GL_TEXTURE_2D, texture ? texture->getID() : 0);840 if (texture) {
841 HeightfieldTexture* heightfieldTexture = static_cast<HeightfieldTexture*>(_textures.at(index).data());
842 scalesS[j] = _scale / heightfieldTexture->getScaleS();
843 scalesT[j] = _scale / heightfieldTexture->getScaleT();
844 glBindTexture(GL_TEXTURE_2D, texture->getID());
845 } else {
846 glBindTexture(GL_TEXTURE_2D, 0);
847 }
836 } else {848 } else {
837 glBindTexture(GL_TEXTURE_2D, 0);849 glBindTexture(GL_TEXTURE_2D, 0);
838 }850 }
839 }851 }
840 const float QUARTER_STEP = 0.25f * EIGHT_BIT_MAXIMUM_RECIPROCAL;852 const float QUARTER_STEP = 0.25f * EIGHT_BIT_MAXIMUM_RECIPROCAL;
853 DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(
854 DefaultMetavoxelRendererImplementation::getSplatTextureScalesSLocation(), scalesS);
855 DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(
856 DefaultMetavoxelRendererImplementation::getSplatTextureScalesTLocation(), scalesT);
841 DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(857 DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(
842 DefaultMetavoxelRendererImplementation::getSplatTextureValueMinimaLocation(),858 DefaultMetavoxelRendererImplementation::getSplatTextureValueMinimaLocation(),
843 (i + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, (i + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP,859 (i + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, (i + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP,
@@ -1050,6 +1066,9 @@ void DefaultMetavoxelRendererImplementation::init() { · 206 unmodified lines
1050 _splatHeightfieldProgram.setUniformValueArray("diffuseMaps", SPLAT_TEXTURE_UNITS, SPLAT_COUNT);1066 _splatHeightfieldProgram.setUniformValueArray("diffuseMaps", SPLAT_TEXTURE_UNITS, SPLAT_COUNT);
1051 _splatHeightScaleLocation = _splatHeightfieldProgram.uniformLocation("heightScale");1067 _splatHeightScaleLocation = _splatHeightfieldProgram.uniformLocation("heightScale");
1052 _splatTextureScaleLocation = _splatHeightfieldProgram.uniformLocation("textureScale");1068 _splatTextureScaleLocation = _splatHeightfieldProgram.uniformLocation("textureScale");
1069 _splatTextureOffsetLocation = _splatHeightfieldProgram.uniformLocation("splatTextureOffset");
1070 _splatTextureScalesSLocation = _splatHeightfieldProgram.uniformLocation("splatTextureScalesS");
1071 _splatTextureScalesTLocation = _splatHeightfieldProgram.uniformLocation("splatTextureScalesT");
1053 _splatTextureValueMinimaLocation = _splatHeightfieldProgram.uniformLocation("textureValueMinima");1072 _splatTextureValueMinimaLocation = _splatHeightfieldProgram.uniformLocation("textureValueMinima");
1054 _splatTextureValueMaximaLocation = _splatHeightfieldProgram.uniformLocation("textureValueMaxima");1073 _splatTextureValueMaximaLocation = _splatHeightfieldProgram.uniformLocation("textureValueMaxima");
1055 _splatHeightfieldProgram.release();1074 _splatHeightfieldProgram.release();
@@ -1695,6 +1714,9 @@ int DefaultMetavoxelRendererImplementation::_baseColorScaleLocation; · 639 unmodified lines
1695ProgramObject DefaultMetavoxelRendererImplementation::_splatHeightfieldProgram;1714ProgramObject DefaultMetavoxelRendererImplementation::_splatHeightfieldProgram;
1696int DefaultMetavoxelRendererImplementation::_splatHeightScaleLocation;1715int DefaultMetavoxelRendererImplementation::_splatHeightScaleLocation;
1697int DefaultMetavoxelRendererImplementation::_splatTextureScaleLocation;1716int DefaultMetavoxelRendererImplementation::_splatTextureScaleLocation;
1717int DefaultMetavoxelRendererImplementation::_splatTextureOffsetLocation;
1718int DefaultMetavoxelRendererImplementation::_splatTextureScalesSLocation;
1719int DefaultMetavoxelRendererImplementation::_splatTextureScalesTLocation;
1698int DefaultMetavoxelRendererImplementation::_splatTextureValueMinimaLocation;1720int DefaultMetavoxelRendererImplementation::_splatTextureValueMinimaLocation;
1699int DefaultMetavoxelRendererImplementation::_splatTextureValueMaximaLocation;1721int DefaultMetavoxelRendererImplementation::_splatTextureValueMaximaLocation;
1700ProgramObject DefaultMetavoxelRendererImplementation::_lightHeightfieldProgram;1722ProgramObject DefaultMetavoxelRendererImplementation::_lightHeightfieldProgram;