History

Compute heightfield normals from adjacent values in vertex shader.

Andrzej Kapolka committed 12 years ago

Commit 46968321 parent 96302ca3 files · +17 −2Browse files

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

Unified · Split

interface/src/MetavoxelSystem.cpp+5−0
@@ -388,6 +388,9 @@ void HeightfieldBuffer::render() { · 387 unmodified lines
388388 glActiveTexture(GL_TEXTURE1);
389389 glBindTexture(GL_TEXTURE_2D, _colorTextureID);
390390
391+ DefaultMetavoxelRendererImplementation::getHeightfieldProgram().setUniformValue(
392+ DefaultMetavoxelRendererImplementation::getHeightScaleLocation(), 1.0f / _heightSize);
393+
391394 glDrawRangeElements(GL_QUADS, 0, vertexCount - 1, indexCount, GL_UNSIGNED_INT, 0);
392395
393396 glBindTexture(GL_TEXTURE_2D, 0);
@@ -470,6 +473,7 @@ void DefaultMetavoxelRendererImplementation::init() { · 76 unmodified lines
470473 _heightfieldProgram.bind();
471474 _heightfieldProgram.setUniformValue("heightMap", 0);
472475 _heightfieldProgram.setUniformValue("diffuseMap", 1);
476+ _heightScaleLocation = _heightfieldProgram.uniformLocation("heightScale");
473477 _heightfieldProgram.release();
474478 }
475479 }
@@ -766,6 +770,7 @@ void DefaultMetavoxelRendererImplementation::render(MetavoxelData& data, Metavox · 290 unmodified lines
766770 ProgramObject DefaultMetavoxelRendererImplementation::_pointProgram;
767771 int DefaultMetavoxelRendererImplementation::_pointScaleLocation;
768772 ProgramObject DefaultMetavoxelRendererImplementation::_heightfieldProgram;
773+int DefaultMetavoxelRendererImplementation::_heightScaleLocation;
769774
770775 static void enableClipPlane(GLenum plane, float x, float y, float z, float w) {
771776 GLdouble coefficients[] = { x, y, z, w };