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 | 275 | if (!_heightTexture.isCreated()) { |
| 276 | 276 | int heightSize = glm::sqrt(_height.size()); |
| 277 | 277 | _heightTexture.setSize(heightSize, heightSize); |
| 278 | + _heightTexture.setAutoMipMapGenerationEnabled(false); | |
| 279 | + _heightTexture.setMinificationFilter(QOpenGLTexture::Linear); | |
| 280 | + _heightTexture.setWrapMode(QOpenGLTexture::ClampToEdge); | |
| 278 | 281 | _heightTexture.setFormat(QOpenGLTexture::LuminanceFormat); |
| 279 | 282 | _heightTexture.allocateStorage(); |
| 280 | 283 | _heightTexture.setData(QOpenGLTexture::Luminance, QOpenGLTexture::UInt8, _height.data()); |
| @@ -284,15 +287,18 @@ void HeightfieldBuffer::render() { · 3 unmodified lines | ||
| 284 | 287 | int colorSize = glm::sqrt(_color.size() / 3); |
| 285 | 288 | _colorTexture.setSize(colorSize, colorSize); |
| 286 | 289 | } |
| 290 | + _colorTexture.setAutoMipMapGenerationEnabled(false); | |
| 291 | + _colorTexture.setMinificationFilter(QOpenGLTexture::Linear); | |
| 292 | + _colorTexture.setWrapMode(QOpenGLTexture::ClampToEdge); | |
| 287 | 293 | _colorTexture.setFormat(QOpenGLTexture::RGBFormat); |
| 288 | 294 | _colorTexture.allocateStorage(); |
| 289 | 295 | if (!_color.isEmpty()) { |
| 290 | − _colorTexture.setData(QOpenGLTexture::BGR, QOpenGLTexture::UInt8, _color.data()); | |
| 296 | + _colorTexture.setData(QOpenGLTexture::RGB, QOpenGLTexture::UInt8, _color.data()); | |
| 291 | 297 | _color.clear(); |
| 292 | 298 | |
| 293 | 299 | } else { |
| 294 | 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 | 304 | // create the buffer objects lazily |
| @@ -310,7 +316,7 @@ void HeightfieldBuffer::render() { · 11 unmodified lines | ||
| 310 | 316 | float z = -step; |
| 311 | 317 | for (int i = 0; i < sizeWithSkirt; i++, z += step) { |
| 312 | 318 | float x = -step; |
| 313 | − const float SKIRT_LENGTH = 1.0f; | |
| 319 | + const float SKIRT_LENGTH = 0.25f; | |
| 314 | 320 | float baseY = (i == 0 || i == sizeWithSkirt - 1) ? -SKIRT_LENGTH : 0.0f; |
| 315 | 321 | for (int j = 0; j < sizeWithSkirt; j++, point++, x += step) { |
| 316 | 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 | 337 | for (int j = 0; j < rows; j++) { |
| 332 | 338 | *index++ = lineIndex + j; |
| 333 | 339 | *index++ = lineIndex + j + 1; |
| 334 | − *index++ = nextLineIndex + j; | |
| 335 | 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 | 377 | QHash<int, HeightfieldBuffer::BufferPair> HeightfieldBuffer::_bufferPairs; |
| 372 | 378 | |
| 373 | 379 | void HeightfieldPreview::render(const glm::vec3& translation, float scale) const { |
| 380 | + glColor4f(1.0f, 1.0f, 1.0f, 0.75f); | |
| 381 | + | |
| 374 | 382 | glEnableClientState(GL_VERTEX_ARRAY); |
| 375 | 383 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
| 376 | 384 | |
| @@ -422,6 +430,11 @@ void DefaultMetavoxelRendererImplementation::init() { · 45 unmodified lines | ||
| 422 | 430 | _heightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + |
| 423 | 431 | "shaders/metavoxel_heightfield.frag"); |
| 424 | 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 | 676 | _pointProgram.release(); |
| 664 | 677 | |
| 678 | + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | |
| 679 | + | |
| 665 | 680 | _heightfieldProgram.bind(); |
| 666 | 681 | |
| 667 | 682 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |