Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 4 files). Show all
Unified · Split
| @@ -275,6 +275,9 @@ void HeightfieldBuffer::render() { · 274 unmodified lines | |||
| 275 | if (!_heightTexture.isCreated()) { | 275 | if (!_heightTexture.isCreated()) { |
| 276 | int heightSize = glm::sqrt(_height.size()); | 276 | int heightSize = glm::sqrt(_height.size()); |
| 277 | _heightTexture.setSize(heightSize, heightSize); | 277 | _heightTexture.setSize(heightSize, heightSize); |
| 278 | _heightTexture.setAutoMipMapGenerationEnabled(false); | ||
| 279 | _heightTexture.setMinificationFilter(QOpenGLTexture::Linear); | ||
| 280 | _heightTexture.setWrapMode(QOpenGLTexture::ClampToEdge); | ||
| 278 | _heightTexture.setFormat(QOpenGLTexture::LuminanceFormat); | 281 | _heightTexture.setFormat(QOpenGLTexture::LuminanceFormat); |
| 279 | _heightTexture.allocateStorage(); | 282 | _heightTexture.allocateStorage(); |
| 280 | _heightTexture.setData(QOpenGLTexture::Luminance, QOpenGLTexture::UInt8, _height.data()); | 283 | _heightTexture.setData(QOpenGLTexture::Luminance, QOpenGLTexture::UInt8, _height.data()); |
| @@ -284,15 +287,18 @@ void HeightfieldBuffer::render() { · 3 unmodified lines | |||
| 284 | int colorSize = glm::sqrt(_color.size() / 3); | 287 | int colorSize = glm::sqrt(_color.size() / 3); |
| 285 | _colorTexture.setSize(colorSize, colorSize); | 288 | _colorTexture.setSize(colorSize, colorSize); |
| 286 | } | 289 | } |
| 290 | _colorTexture.setAutoMipMapGenerationEnabled(false); | ||
| 291 | _colorTexture.setMinificationFilter(QOpenGLTexture::Linear); | ||
| 292 | _colorTexture.setWrapMode(QOpenGLTexture::ClampToEdge); | ||
| 287 | _colorTexture.setFormat(QOpenGLTexture::RGBFormat); | 293 | _colorTexture.setFormat(QOpenGLTexture::RGBFormat); |
| 288 | _colorTexture.allocateStorage(); | 294 | _colorTexture.allocateStorage(); |
| 289 | if (!_color.isEmpty()) { | 295 | if (!_color.isEmpty()) { |
| 290 | _colorTexture.setData(QOpenGLTexture::BGR, QOpenGLTexture::UInt8, _color.data()); | 296 | _colorTexture.setData(QOpenGLTexture::RGB, QOpenGLTexture::UInt8, _color.data()); |
| 291 | _color.clear(); | 297 | _color.clear(); |
| 292 | 298 | ||
| 293 | } else { | 299 | } else { |
| 294 | const quint8 WHITE_COLOR[] = { 255, 255, 255 }; | 300 | const quint8 WHITE_COLOR[] = { 255, 255, 255 }; |
| 295 | _colorTexture.setData(QOpenGLTexture::BGR, QOpenGLTexture::UInt8, const_cast<quint8*>(WHITE_COLOR)); | 301 | _colorTexture.setData(QOpenGLTexture::RGB, QOpenGLTexture::UInt8, const_cast<quint8*>(WHITE_COLOR)); |
| 296 | } | 302 | } |
| 297 | } | 303 | } |
| 298 | // create the buffer objects lazily | 304 | // create the buffer objects lazily |
| @@ -310,7 +316,7 @@ void HeightfieldBuffer::render() { · 11 unmodified lines | |||
| 310 | float z = -step; | 316 | float z = -step; |
| 311 | for (int i = 0; i < sizeWithSkirt; i++, z += step) { | 317 | for (int i = 0; i < sizeWithSkirt; i++, z += step) { |
| 312 | float x = -step; | 318 | float x = -step; |
| 313 | const float SKIRT_LENGTH = 1.0f; | 319 | const float SKIRT_LENGTH = 0.25f; |
| 314 | float baseY = (i == 0 || i == sizeWithSkirt - 1) ? -SKIRT_LENGTH : 0.0f; | 320 | float baseY = (i == 0 || i == sizeWithSkirt - 1) ? -SKIRT_LENGTH : 0.0f; |
| 315 | for (int j = 0; j < sizeWithSkirt; j++, point++, x += step) { | 321 | for (int j = 0; j < sizeWithSkirt; j++, point++, x += step) { |
| 316 | point->vertex = glm::vec3(x, (j == 0 || j == sizeWithSkirt - 1) ? -SKIRT_LENGTH : baseY, z); | 322 | point->vertex = glm::vec3(x, (j == 0 || j == sizeWithSkirt - 1) ? -SKIRT_LENGTH : baseY, z); |
| @@ -331,8 +337,8 @@ void HeightfieldBuffer::render() { · 14 unmodified lines | |||
| 331 | for (int j = 0; j < rows; j++) { | 337 | for (int j = 0; j < rows; j++) { |
| 332 | *index++ = lineIndex + j; | 338 | *index++ = lineIndex + j; |
| 333 | *index++ = lineIndex + j + 1; | 339 | *index++ = lineIndex + j + 1; |
| 334 | *index++ = nextLineIndex + j; | ||
| 335 | *index++ = nextLineIndex + j + 1; | 340 | *index++ = nextLineIndex + j + 1; |
| 341 | *index++ = nextLineIndex + j; | ||
| 336 | } | 342 | } |
| 337 | } | 343 | } |
| 338 | 344 | ||
| @@ -371,6 +377,8 @@ void HeightfieldBuffer::render() { · 32 unmodified lines | |||
| 371 | QHash<int, HeightfieldBuffer::BufferPair> HeightfieldBuffer::_bufferPairs; | 377 | QHash<int, HeightfieldBuffer::BufferPair> HeightfieldBuffer::_bufferPairs; |
| 372 | 378 | ||
| 373 | void HeightfieldPreview::render(const glm::vec3& translation, float scale) const { | 379 | void HeightfieldPreview::render(const glm::vec3& translation, float scale) const { |
| 380 | glColor4f(1.0f, 1.0f, 1.0f, 0.75f); | ||
| 381 | |||
| 374 | glEnableClientState(GL_VERTEX_ARRAY); | 382 | glEnableClientState(GL_VERTEX_ARRAY); |
| 375 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 383 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
| 376 | 384 | ||
| @@ -422,6 +430,11 @@ void DefaultMetavoxelRendererImplementation::init() { · 45 unmodified lines | |||
| 422 | _heightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + | 430 | _heightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + |
| 423 | "shaders/metavoxel_heightfield.frag"); | 431 | "shaders/metavoxel_heightfield.frag"); |
| 424 | _heightfieldProgram.link(); | 432 | _heightfieldProgram.link(); |
| 433 | |||
| 434 | _heightfieldProgram.bind(); | ||
| 435 | _heightfieldProgram.setUniformValue("heightMap", 0); | ||
| 436 | _heightfieldProgram.setUniformValue("diffuseMap", 1); | ||
| 437 | _heightfieldProgram.release(); | ||
| 425 | } | 438 | } |
| 426 | } | 439 | } |
| 427 | 440 | ||
| @@ -662,6 +675,8 @@ void DefaultMetavoxelRendererImplementation::render(MetavoxelData& data, Metavox · 234 unmodified lines | |||
| 662 | 675 | ||
| 663 | _pointProgram.release(); | 676 | _pointProgram.release(); |
| 664 | 677 | ||
| 678 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | ||
| 679 | |||
| 665 | _heightfieldProgram.bind(); | 680 | _heightfieldProgram.bind(); |
| 666 | 681 | ||
| 667 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 682 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |