History

Working on texture rendering.

Andrzej Kapolka committed 12 years ago

Commit 416d9ba1 parent 7cf7f1814 files · +473 −104Browse files

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

Unified · Split

interface/src/MetavoxelSystem.cpp+173−87
@@ -602,24 +602,23 @@ const int HeightfieldBuffer::SHARED_EDGE = 1; · 601 unmodified lines
602const int HeightfieldBuffer::HEIGHT_EXTENSION = 2 * HeightfieldBuffer::HEIGHT_BORDER + HeightfieldBuffer::SHARED_EDGE;602const int HeightfieldBuffer::HEIGHT_EXTENSION = 2 * HeightfieldBuffer::HEIGHT_BORDER + HeightfieldBuffer::SHARED_EDGE;
603 603
604HeightfieldBuffer::HeightfieldBuffer(const glm::vec3& translation, float scale,604HeightfieldBuffer::HeightfieldBuffer(const glm::vec3& translation, float scale,
605 const QByteArray& height, const QByteArray& color, const QByteArray& texture) :605 const QByteArray& height, const QByteArray& color, const QByteArray& texture,
606 const QVector<SharedObjectPointer>& textures) :
606 _translation(translation),607 _translation(translation),
607 _scale(scale),608 _scale(scale),
608 _heightBounds(translation, translation + glm::vec3(scale, scale, scale)),609 _heightBounds(translation, translation + glm::vec3(scale, scale, scale)),
609 _colorBounds(_heightBounds),610 _colorBounds(_heightBounds),
610 _textureBounds(_heightBounds),
611 _height(height),611 _height(height),
612 _color(color),612 _color(color),
613 _texture(texture),613 _texture(texture),
614 _textures(textures),
614 _heightTextureID(0),615 _heightTextureID(0),
615 _colorTextureID(0),616 _colorTextureID(0),
616 _textureTextureID(0),617 _textureTextureID(0),
617 _heightSize(glm::sqrt(height.size())),618 _heightSize(glm::sqrt(height.size())),
618 _heightIncrement(scale / (_heightSize - HEIGHT_EXTENSION)),619 _heightIncrement(scale / (_heightSize - HEIGHT_EXTENSION)),
619 _colorSize(glm::sqrt(color.size() / HeightfieldData::COLOR_BYTES)),620 _colorSize(glm::sqrt(color.size() / HeightfieldData::COLOR_BYTES)),
620 _colorIncrement(scale / (_colorSize - SHARED_EDGE)),621 _colorIncrement(scale / (_colorSize - SHARED_EDGE)) {
621 _textureSize(glm::sqrt(texture.size())),
622 _textureIncrement(scale / (_textureSize - SHARED_EDGE)) {
623 622
624 _heightBounds.minimum.x -= _heightIncrement * HEIGHT_BORDER;623 _heightBounds.minimum.x -= _heightIncrement * HEIGHT_BORDER;
625 _heightBounds.minimum.z -= _heightIncrement * HEIGHT_BORDER;624 _heightBounds.minimum.z -= _heightIncrement * HEIGHT_BORDER;
@@ -628,9 +627,6 @@ HeightfieldBuffer::HeightfieldBuffer(const glm::vec3& translation, float scale, · 2 unmodified lines
628 627
629 _colorBounds.maximum.x += _colorIncrement * SHARED_EDGE;628 _colorBounds.maximum.x += _colorIncrement * SHARED_EDGE;
630 _colorBounds.maximum.z += _colorIncrement * SHARED_EDGE;629 _colorBounds.maximum.z += _colorIncrement * SHARED_EDGE;
631
632 _textureBounds.maximum.x += _textureIncrement * SHARED_EDGE;
633 _textureBounds.maximum.z += _textureIncrement * SHARED_EDGE;
634}630}
635 631
636HeightfieldBuffer::~HeightfieldBuffer() {632HeightfieldBuffer::~HeightfieldBuffer() {
@@ -712,6 +708,15 @@ void HeightfieldBuffer::render(bool cursor) { · 75 unmodified lines
712 int textureSize = glm::sqrt(_texture.size()); 708 int textureSize = glm::sqrt(_texture.size());
713 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, textureSize, textureSize, 0,709 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, textureSize, textureSize, 0,
714 GL_LUMINANCE, GL_UNSIGNED_BYTE, _texture.constData());710 GL_LUMINANCE, GL_UNSIGNED_BYTE, _texture.constData());
711
712 _networkTextures.resize(_textures.size());
713 for (int i = 0; i < _textures.size(); i++) {
714 const SharedObjectPointer texture = _textures.at(i);
715 if (texture) {
716 _networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture(
717 static_cast<HeightfieldTexture*>(texture.data())->getURL());
718 }
719 }
715 }720 }
716 }721 }
717 // create the buffer objects lazily722 // create the buffer objects lazily
@@ -780,7 +785,56 @@ void HeightfieldBuffer::render(bool cursor) { · 62 unmodified lines
780 785
781 glBindTexture(GL_TEXTURE_2D, _heightTextureID);786 glBindTexture(GL_TEXTURE_2D, _heightTextureID);
782 787
783 if (!cursor) {788 if (cursor) {
789 glDrawRangeElements(GL_TRIANGLES, 0, vertexCount - 1, indexCount, GL_UNSIGNED_INT, 0);
790
791 } else if (!_textures.isEmpty()) {
792 DefaultMetavoxelRendererImplementation::getBaseHeightfieldProgram().bind();
793 DefaultMetavoxelRendererImplementation::getBaseHeightfieldProgram().setUniformValue(
794 DefaultMetavoxelRendererImplementation::getBaseHeightScaleLocation(), 1.0f / _heightSize);
795 DefaultMetavoxelRendererImplementation::getBaseHeightfieldProgram().setUniformValue(
796 DefaultMetavoxelRendererImplementation::getBaseColorScaleLocation(), (float)_heightSize / innerSize);
797 glActiveTexture(GL_TEXTURE1);
798 glBindTexture(GL_TEXTURE_2D, _colorTextureID);
799
800 glDrawRangeElements(GL_TRIANGLES, 0, vertexCount - 1, indexCount, GL_UNSIGNED_INT, 0);
801
802 glDepthFunc(GL_LEQUAL);
803 glEnable(GL_BLEND);
804 glBlendFunc(GL_DST_COLOR, GL_ZERO);
805 glEnable(GL_POLYGON_OFFSET_FILL);
806 glPolygonOffset(-1.0f, -1.0f);
807
808 glBindTexture(GL_TEXTURE_2D, 0);
809
810 if (Menu::getInstance()->isOptionChecked(MenuOption::SimpleShadows)) {
811 DefaultMetavoxelRendererImplementation::getShadowLightHeightfieldProgram().bind();
812 DefaultMetavoxelRendererImplementation::getShadowLightHeightfieldProgram().setUniformValue(
813 DefaultMetavoxelRendererImplementation::getShadowLightHeightScaleLocation(), 1.0f / _heightSize);
814
815 } else if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) {
816 DefaultMetavoxelRendererImplementation::getCascadedShadowLightHeightfieldProgram().bind();
817 DefaultMetavoxelRendererImplementation::getCascadedShadowLightHeightfieldProgram().setUniformValue(
818 DefaultMetavoxelRendererImplementation::getCascadedShadowLightHeightScaleLocation(), 1.0f / _heightSize);
819
820 } else {
821 DefaultMetavoxelRendererImplementation::getLightHeightfieldProgram().bind();
822 DefaultMetavoxelRendererImplementation::getLightHeightfieldProgram().setUniformValue(
823 DefaultMetavoxelRendererImplementation::getBaseHeightScaleLocation(), 1.0f / _heightSize);
824 }
825
826 glDrawRangeElements(GL_TRIANGLES, 0, vertexCount - 1, indexCount, GL_UNSIGNED_INT, 0);
827
828 DefaultMetavoxelRendererImplementation::getHeightfieldProgram().bind();
829
830 glDisable(GL_POLYGON_OFFSET_FILL);
831 glDisable(GL_BLEND);
832 glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
833 glDepthFunc(GL_LESS);
834
835 glActiveTexture(GL_TEXTURE0);
836
837 } else {
784 int heightScaleLocation = DefaultMetavoxelRendererImplementation::getHeightScaleLocation();838 int heightScaleLocation = DefaultMetavoxelRendererImplementation::getHeightScaleLocation();
785 int colorScaleLocation = DefaultMetavoxelRendererImplementation::getColorScaleLocation();839 int colorScaleLocation = DefaultMetavoxelRendererImplementation::getColorScaleLocation();
786 ProgramObject* program = &DefaultMetavoxelRendererImplementation::getHeightfieldProgram();840 ProgramObject* program = &DefaultMetavoxelRendererImplementation::getHeightfieldProgram();
@@ -798,11 +852,9 @@ void HeightfieldBuffer::render(bool cursor) { · 11 unmodified lines
798 program->setUniformValue(colorScaleLocation, (float)_heightSize / innerSize);852 program->setUniformValue(colorScaleLocation, (float)_heightSize / innerSize);
799 glActiveTexture(GL_TEXTURE1);853 glActiveTexture(GL_TEXTURE1);
800 glBindTexture(GL_TEXTURE_2D, _colorTextureID);854 glBindTexture(GL_TEXTURE_2D, _colorTextureID);
801 }855
802 856 glDrawRangeElements(GL_TRIANGLES, 0, vertexCount - 1, indexCount, GL_UNSIGNED_INT, 0);
803 glDrawRangeElements(GL_TRIANGLES, 0, vertexCount - 1, indexCount, GL_UNSIGNED_INT, 0);857
804
805 if (!cursor) {
806 glBindTexture(GL_TEXTURE_2D, 0);858 glBindTexture(GL_TEXTURE_2D, 0);
807 glActiveTexture(GL_TEXTURE0); 859 glActiveTexture(GL_TEXTURE0);
808 }860 }
@@ -919,6 +971,68 @@ void DefaultMetavoxelRendererImplementation::init() { · 110 unmodified lines
919 _shadowDistancesLocation = _cascadedShadowMapHeightfieldProgram.uniformLocation("shadowDistances");971 _shadowDistancesLocation = _cascadedShadowMapHeightfieldProgram.uniformLocation("shadowDistances");
920 _cascadedShadowMapHeightfieldProgram.release();972 _cascadedShadowMapHeightfieldProgram.release();
921 973
974 _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
975 "shaders/metavoxel_heightfield_base.vert");
976 _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
977 "shaders/metavoxel_heightfield_base.frag");
978 _baseHeightfieldProgram.link();
979
980 _baseHeightfieldProgram.bind();
981 _baseHeightfieldProgram.setUniformValue("heightMap", 0);
982 _baseHeightfieldProgram.setUniformValue("diffuseMap", 1);
983 _baseHeightScaleLocation = _heightfieldProgram.uniformLocation("heightScale");
984 _baseColorScaleLocation = _heightfieldProgram.uniformLocation("colorScale");
985 _baseHeightfieldProgram.release();
986
987 _splatHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
988 "shaders/metavoxel_heightfield_splat.vert");
989 _splatHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
990 "shaders/metavoxel_heightfield_splat.frag");
991 _splatHeightfieldProgram.link();
992
993 _splatHeightfieldProgram.bind();
994 _splatHeightfieldProgram.setUniformValue("heightMap", 0);
995 _splatHeightfieldProgram.setUniformValue("diffuseMap", 1);
996 _splatHeightScaleLocation = _splatHeightfieldProgram.uniformLocation("heightScale");
997 _splatTextureScaleLocation = _splatHeightfieldProgram.uniformLocation("textureScale");
998 _splatHeightfieldProgram.release();
999
1000 _lightHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
1001 "shaders/metavoxel_heightfield_light.vert");
1002 _lightHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
1003 "shaders/metavoxel_heightfield_light.frag");
1004 _lightHeightfieldProgram.link();
1005
1006 _lightHeightfieldProgram.bind();
1007 _lightHeightfieldProgram.setUniformValue("heightMap", 0);
1008 _lightHeightScaleLocation = _lightHeightfieldProgram.uniformLocation("heightScale");
1009 _lightHeightfieldProgram.release();
1010
1011 _shadowLightHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
1012 "shaders/metavoxel_heightfield_light.vert");
1013 _shadowLightHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
1014 "shaders/metavoxel_heightfield_light_shadow_map.frag");
1015 _shadowLightHeightfieldProgram.link();
1016
1017 _shadowLightHeightfieldProgram.bind();
1018 _shadowLightHeightfieldProgram.setUniformValue("heightMap", 0);
1019 _shadowLightHeightfieldProgram.setUniformValue("shadowMap", 2);
1020 _shadowLightHeightScaleLocation = _shadowLightHeightfieldProgram.uniformLocation("heightScale");
1021 _shadowLightHeightfieldProgram.release();
1022
1023 _cascadedShadowLightHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
1024 "shaders/metavoxel_heightfield_light.vert");
1025 _cascadedShadowLightHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
1026 "shaders/metavoxel_heightfield_light_cascaded_shadow_map.frag");
1027 _cascadedShadowLightHeightfieldProgram.link();
1028
1029 _cascadedShadowLightHeightfieldProgram.bind();
1030 _cascadedShadowLightHeightfieldProgram.setUniformValue("heightMap", 0);
1031 _cascadedShadowLightHeightfieldProgram.setUniformValue("shadowMap", 2);
1032 _cascadedShadowLightHeightScaleLocation = _cascadedShadowLightHeightfieldProgram.uniformLocation("heightScale");
1033 _shadowLightDistancesLocation = _cascadedShadowLightHeightfieldProgram.uniformLocation("shadowDistances");
1034 _cascadedShadowLightHeightfieldProgram.release();
1035
922 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +1036 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
923 "shaders/metavoxel_heightfield_cursor.vert");1037 "shaders/metavoxel_heightfield_cursor.vert");
924 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +1038 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
@@ -1019,8 +1133,7 @@ private: · 94 unmodified lines
1019 1133
1020HeightfieldFetchVisitor::HeightfieldFetchVisitor(const MetavoxelLOD& lod, const QVector<Box>& intersections) :1134HeightfieldFetchVisitor::HeightfieldFetchVisitor(const MetavoxelLOD& lod, const QVector<Box>& intersections) :
1021 MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getHeightfieldAttribute() <<1135 MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getHeightfieldAttribute() <<
1022 AttributeRegistry::getInstance()->getHeightfieldColorAttribute() <<1136 AttributeRegistry::getInstance()->getHeightfieldColorAttribute(), QVector<AttributePointer>(), lod),
1023 AttributeRegistry::getInstance()->getHeightfieldTextureAttribute(), QVector<AttributePointer>(), lod),
1024 _intersections(intersections) {1137 _intersections(intersections) {
1025}1138}
1026 1139
@@ -1135,50 +1248,6 @@ int HeightfieldFetchVisitor::visit(MetavoxelInfo& info) { · 108 unmodified lines
1135 }1248 }
1136 }1249 }
1137 }1250 }
1138
1139 int textureSize = _buffer->getTextureSize();
1140 if (textureSize == 0) {
1141 continue;
1142 }
1143 HeightfieldTextureDataPointer texture = info.inputValues.at(2).getInlineValue<HeightfieldTextureDataPointer>();
1144 if (!texture) {
1145 continue;
1146 }
1147 const Box& textureBounds = _buffer->getTextureBounds();
1148 overlap = textureBounds.getIntersection(overlap);
1149 float textureIncrement = _buffer->getTextureIncrement();
1150 destX = (overlap.minimum.x - textureBounds.minimum.x) / textureIncrement;
1151 destY = (overlap.minimum.z - textureBounds.minimum.z) / textureIncrement;
1152 destWidth = glm::ceil((overlap.maximum.x - overlap.minimum.x) / textureIncrement);
1153 destHeight = glm::ceil((overlap.maximum.z - overlap.minimum.z) / textureIncrement);
1154 dest = _buffer->getTexture().data() + destY * textureSize + destX;
1155
1156 const QByteArray& srcTexture = texture->getContents();
1157 srcSize = glm::sqrt(srcTexture.size());
1158 srcIncrement = info.size / srcSize;
1159
1160 if (srcIncrement == textureIncrement) {
1161 // easy case: same resolution
1162 int srcX = (overlap.minimum.x - info.minimum.x) / srcIncrement;
1163 int srcY = (overlap.minimum.z - info.minimum.z) / srcIncrement;
1164
1165 const char* src = srcTexture.constData() + srcY * srcSize + srcX;
1166 for (int y = 0; y < destHeight; y++, src += srcSize, dest += textureSize) {
1167 memcpy(dest, src, destWidth);
1168 }
1169 } else {
1170 // more difficult: different resolutions
1171 float srcX = (overlap.minimum.x - info.minimum.x) / srcIncrement;
1172 float srcY = (overlap.minimum.z - info.minimum.z) / srcIncrement;
1173 float srcAdvance = textureIncrement / srcIncrement;
1174 for (int y = 0; y < destHeight; y++, dest += textureSize, srcY += srcAdvance) {
1175 const char* src = srcTexture.constData() + (int)srcY * srcSize;
1176 float lineSrcX = srcX;
1177 for (char* lineDest = dest, *end = dest + destWidth; lineDest != end; lineDest++, lineSrcX += srcAdvance) {
1178 *lineDest = src[(int)lineSrcX];
1179 }
1180 }
1181 }
1182 }1251 }
1183 return STOP_RECURSION;1252 return STOP_RECURSION;
1184}1253}
@@ -1233,42 +1302,43 @@ int HeightfieldRegionVisitor::visit(MetavoxelInfo& info) { · 48 unmodified lines
1233 }1302 }
1234 1303
1235 HeightfieldTextureDataPointer texture = info.inputValues.at(2).getInlineValue<HeightfieldTextureDataPointer>();1304 HeightfieldTextureDataPointer texture = info.inputValues.at(2).getInlineValue<HeightfieldTextureDataPointer>();
1236 int textureContentsSize = 0;1305 QByteArray textureContents;
1306 QVector<SharedObjectPointer> textures;
1237 if (texture) {1307 if (texture) {
1238 const QByteArray& textureContents = texture->getContents();1308 textureContents = texture->getContents();
1239 int textureSize = glm::sqrt(textureContents.size());1309 textures = texture->getTextures();
1240 int extendedTextureSize = textureSize + HeightfieldBuffer::SHARED_EDGE;
1241 textureContentsSize = extendedTextureSize * extendedTextureSize;
1242 }1310 }
1243 1311
1244 const HeightfieldBuffer* existingBuffer = static_cast<const HeightfieldBuffer*>(1312 const HeightfieldBuffer* existingBuffer = static_cast<const HeightfieldBuffer*>(
1245 info.inputValues.at(3).getInlineValue<BufferDataPointer>().data());1313 info.inputValues.at(3).getInlineValue<BufferDataPointer>().data());
1246 Box bounds = info.getBounds();1314 Box bounds = info.getBounds();
1247 if (existingBuffer && existingBuffer->getHeight().size() == heightContentsSize &&1315 if (existingBuffer && existingBuffer->getHeight().size() == heightContentsSize &&
1248 existingBuffer->getColor().size() == colorContentsSize &&1316 existingBuffer->getColor().size() == colorContentsSize) {
1249 existingBuffer->getTexture().size() == textureContentsSize) {
1250 // we already have a buffer of the correct resolution 1317 // we already have a buffer of the correct resolution
1251 addRegion(bounds, existingBuffer->getHeightBounds());1318 addRegion(bounds, existingBuffer->getHeightBounds());
1252 return STOP_RECURSION;1319 buffer = new HeightfieldBuffer(info.minimum, info.size, existingBuffer->getHeight(),
1320 existingBuffer->getColor(), textureContents, textures);
1321
1322 } else {
1323 // we must create a new buffer and update its borders
1324 buffer = new HeightfieldBuffer(info.minimum, info.size, QByteArray(heightContentsSize, 0),
1325 QByteArray(colorContentsSize, 0), textureContents, textures);
1326 const Box& heightBounds = buffer->getHeightBounds();
1327 addRegion(bounds, heightBounds);
1328
1329 _intersections.clear();
1330 _intersections.append(Box(heightBounds.minimum,
1331 glm::vec3(bounds.maximum.x, heightBounds.maximum.y, bounds.minimum.z)));
1332 _intersections.append(Box(glm::vec3(bounds.maximum.x, heightBounds.minimum.y, heightBounds.minimum.z),
1333 glm::vec3(heightBounds.maximum.x, heightBounds.maximum.y, bounds.maximum.z)));
1334 _intersections.append(Box(glm::vec3(bounds.minimum.x, heightBounds.minimum.y, bounds.maximum.z),
1335 heightBounds.maximum));
1336 _intersections.append(Box(glm::vec3(heightBounds.minimum.x, heightBounds.minimum.y, bounds.minimum.z),
1337 glm::vec3(bounds.minimum.x, heightBounds.maximum.y, heightBounds.maximum.z)));
1338
1339 _fetchVisitor.init(buffer);
1340 _data->guide(_fetchVisitor);
1253 }1341 }
1254 // we must create a new buffer and update its borders
1255 buffer = new HeightfieldBuffer(info.minimum, info.size, QByteArray(heightContentsSize, 0),
1256 QByteArray(colorContentsSize, 0), QByteArray(textureContentsSize, 0));
1257 const Box& heightBounds = buffer->getHeightBounds();
1258 addRegion(bounds, heightBounds);
1259
1260 _intersections.clear();
1261 _intersections.append(Box(heightBounds.minimum,
1262 glm::vec3(bounds.maximum.x, heightBounds.maximum.y, bounds.minimum.z)));
1263 _intersections.append(Box(glm::vec3(bounds.maximum.x, heightBounds.minimum.y, heightBounds.minimum.z),
1264 glm::vec3(heightBounds.maximum.x, heightBounds.maximum.y, bounds.maximum.z)));
1265 _intersections.append(Box(glm::vec3(bounds.minimum.x, heightBounds.minimum.y, bounds.maximum.z),
1266 heightBounds.maximum));
1267 _intersections.append(Box(glm::vec3(heightBounds.minimum.x, heightBounds.minimum.y, bounds.minimum.z),
1268 glm::vec3(bounds.minimum.x, heightBounds.maximum.y, heightBounds.maximum.z)));
1269
1270 _fetchVisitor.init(buffer);
1271 _data->guide(_fetchVisitor);
1272 }1342 }
1273 info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(BufferDataPointer(buffer)));1343 info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(BufferDataPointer(buffer)));
1274 return STOP_RECURSION;1344 return STOP_RECURSION;
@@ -1326,7 +1396,7 @@ int HeightfieldUpdateVisitor::visit(MetavoxelInfo& info) { · 51 unmodified lines
1326 return STOP_RECURSION;1396 return STOP_RECURSION;
1327 }1397 }
1328 HeightfieldBuffer* newBuffer = new HeightfieldBuffer(info.minimum, info.size,1398 HeightfieldBuffer* newBuffer = new HeightfieldBuffer(info.minimum, info.size,
1329 buffer->getHeight(), buffer->getColor(), buffer->getTexture());1399 buffer->getHeight(), buffer->getColor(), buffer->getTexture(), buffer->getTextures());
1330 _fetchVisitor.init(newBuffer);1400 _fetchVisitor.init(newBuffer);
1331 _data->guide(_fetchVisitor);1401 _data->guide(_fetchVisitor);
1332 info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(BufferDataPointer(newBuffer)));1402 info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(BufferDataPointer(newBuffer)));
@@ -1514,6 +1584,9 @@ void DefaultMetavoxelRendererImplementation::render(MetavoxelData& data, Metavox · 181 unmodified lines
1514 ProgramObject* program = &_heightfieldProgram;1584 ProgramObject* program = &_heightfieldProgram;
1515 if (Menu::getInstance()->getShadowsEnabled()) {1585 if (Menu::getInstance()->getShadowsEnabled()) {
1516 if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) {1586 if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) {
1587 _cascadedShadowLightHeightfieldProgram.bind();
1588 _cascadedShadowLightHeightfieldProgram.setUniform(_shadowLightDistancesLocation,
1589 Application::getInstance()->getShadowDistances());
1517 program = &_cascadedShadowMapHeightfieldProgram;1590 program = &_cascadedShadowMapHeightfieldProgram;
1518 program->bind();1591 program->bind();
1519 program->setUniform(_shadowDistancesLocation, Application::getInstance()->getShadowDistances());1592 program->setUniform(_shadowDistancesLocation, Application::getInstance()->getShadowDistances());
@@ -1559,6 +1632,19 @@ ProgramObject DefaultMetavoxelRendererImplementation::_cascadedShadowMapHeightfi · 39 unmodified lines
1559int DefaultMetavoxelRendererImplementation::_cascadedShadowMapHeightScaleLocation;1632int DefaultMetavoxelRendererImplementation::_cascadedShadowMapHeightScaleLocation;
1560int DefaultMetavoxelRendererImplementation::_cascadedShadowMapColorScaleLocation;1633int DefaultMetavoxelRendererImplementation::_cascadedShadowMapColorScaleLocation;
1561int DefaultMetavoxelRendererImplementation::_shadowDistancesLocation;1634int DefaultMetavoxelRendererImplementation::_shadowDistancesLocation;
1635ProgramObject DefaultMetavoxelRendererImplementation::_baseHeightfieldProgram;
1636int DefaultMetavoxelRendererImplementation::_baseHeightScaleLocation;
1637int DefaultMetavoxelRendererImplementation::_baseColorScaleLocation;
1638ProgramObject DefaultMetavoxelRendererImplementation::_splatHeightfieldProgram;
1639int DefaultMetavoxelRendererImplementation::_splatHeightScaleLocation;
1640int DefaultMetavoxelRendererImplementation::_splatTextureScaleLocation;
1641ProgramObject DefaultMetavoxelRendererImplementation::_lightHeightfieldProgram;
1642int DefaultMetavoxelRendererImplementation::_lightHeightScaleLocation;
1643ProgramObject DefaultMetavoxelRendererImplementation::_shadowLightHeightfieldProgram;
1644int DefaultMetavoxelRendererImplementation::_shadowLightHeightScaleLocation;
1645ProgramObject DefaultMetavoxelRendererImplementation::_cascadedShadowLightHeightfieldProgram;
1646int DefaultMetavoxelRendererImplementation::_cascadedShadowLightHeightScaleLocation;
1647int DefaultMetavoxelRendererImplementation::_shadowLightDistancesLocation;
1562ProgramObject DefaultMetavoxelRendererImplementation::_heightfieldCursorProgram;1648ProgramObject DefaultMetavoxelRendererImplementation::_heightfieldCursorProgram;
1563 1649
1564static void enableClipPlane(GLenum plane, float x, float y, float z, float w) {1650static void enableClipPlane(GLenum plane, float x, float y, float z, float w) {