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
822822 DefaultMetavoxelRendererImplementation::getSplatHeightScaleLocation(), 1.0f / _heightSize);
823823 DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(
824824 DefaultMetavoxelRendererImplementation::getSplatTextureScaleLocation(), (float)_heightSize / innerSize);
825+ DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(
826+ DefaultMetavoxelRendererImplementation::getSplatTextureOffsetLocation(),
827+ _translation.x / _scale, _translation.z / _scale);
825828
826829 glBindTexture(GL_TEXTURE_2D, _textureTextureID);
827830
828831 const int TEXTURES_PER_SPLAT = 4;
829832 for (int i = 0; i < _textures.size(); i += TEXTURES_PER_SPLAT) {
833+ QVector4D scalesS, scalesT;
834+
830835 for (int j = 0; j < SPLAT_COUNT; j++) {
831836 glActiveTexture(GL_TEXTURE0 + SPLAT_TEXTURE_UNITS[j]);
832837 int index = i + j;
833838 if (index < _networkTextures.size()) {
834839 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+ }
836848 } else {
837849 glBindTexture(GL_TEXTURE_2D, 0);
838850 }
839851 }
840852 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);
841857 DefaultMetavoxelRendererImplementation::getSplatHeightfieldProgram().setUniformValue(
842858 DefaultMetavoxelRendererImplementation::getSplatTextureValueMinimaLocation(),
843859 (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
10501066 _splatHeightfieldProgram.setUniformValueArray("diffuseMaps", SPLAT_TEXTURE_UNITS, SPLAT_COUNT);
10511067 _splatHeightScaleLocation = _splatHeightfieldProgram.uniformLocation("heightScale");
10521068 _splatTextureScaleLocation = _splatHeightfieldProgram.uniformLocation("textureScale");
1069+ _splatTextureOffsetLocation = _splatHeightfieldProgram.uniformLocation("splatTextureOffset");
1070+ _splatTextureScalesSLocation = _splatHeightfieldProgram.uniformLocation("splatTextureScalesS");
1071+ _splatTextureScalesTLocation = _splatHeightfieldProgram.uniformLocation("splatTextureScalesT");
10531072 _splatTextureValueMinimaLocation = _splatHeightfieldProgram.uniformLocation("textureValueMinima");
10541073 _splatTextureValueMaximaLocation = _splatHeightfieldProgram.uniformLocation("textureValueMaxima");
10551074 _splatHeightfieldProgram.release();
@@ -1695,6 +1714,9 @@ int DefaultMetavoxelRendererImplementation::_baseColorScaleLocation; · 639 unmodified lines
16951714 ProgramObject DefaultMetavoxelRendererImplementation::_splatHeightfieldProgram;
16961715 int DefaultMetavoxelRendererImplementation::_splatHeightScaleLocation;
16971716 int DefaultMetavoxelRendererImplementation::_splatTextureScaleLocation;
1717+int DefaultMetavoxelRendererImplementation::_splatTextureOffsetLocation;
1718+int DefaultMetavoxelRendererImplementation::_splatTextureScalesSLocation;
1719+int DefaultMetavoxelRendererImplementation::_splatTextureScalesTLocation;
16981720 int DefaultMetavoxelRendererImplementation::_splatTextureValueMinimaLocation;
16991721 int DefaultMetavoxelRendererImplementation::_splatTextureValueMaximaLocation;
17001722 ProgramObject DefaultMetavoxelRendererImplementation::_lightHeightfieldProgram;