History

Use deferred lighting for voxels as well as metavoxels.

Andrzej Kapolka committed 12 years ago

Commit e6f37541 parent c2b58c916 files · +114 −206Browse files

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

Unified · Split

interface/src/MetavoxelSystem.cpp+9−19
@@ -121,23 +121,13 @@ int RenderVisitor::visit(MetavoxelInfo& info) { · 120 unmodified lines
121121 return STOP_RECURSION;
122122 }
123123
124−const GLenum COLOR_DRAW_BUFFERS[] = { GL_COLOR_ATTACHMENT0 };
125−const GLenum NORMAL_DRAW_BUFFERS[] = { GL_COLOR_ATTACHMENT1 };
126−const GLenum COLOR_NORMAL_DRAW_BUFFERS[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
127−
128124 void MetavoxelSystem::render() {
129125 // update the frustum
130126 ViewFrustum* viewFrustum = Application::getInstance()->getDisplayViewFrustum();
131127 _frustum.set(viewFrustum->getFarTopLeft(), viewFrustum->getFarTopRight(), viewFrustum->getFarBottomLeft(),
132128 viewFrustum->getFarBottomRight(), viewFrustum->getNearTopLeft(), viewFrustum->getNearTopRight(),
133129 viewFrustum->getNearBottomLeft(), viewFrustum->getNearBottomRight());
134−
135− // clear the normal buffer
136− glDrawBuffers(sizeof(NORMAL_DRAW_BUFFERS) / sizeof(NORMAL_DRAW_BUFFERS[0]), NORMAL_DRAW_BUFFERS);
137− glClear(GL_COLOR_BUFFER_BIT);
138−
139− glDrawBuffers(sizeof(COLOR_DRAW_BUFFERS) / sizeof(COLOR_DRAW_BUFFERS[0]), COLOR_DRAW_BUFFERS);
140−
130+
141131 RenderVisitor renderVisitor(getLOD());
142132 guideToAugmented(renderVisitor, true);
143133
@@ -834,7 +824,7 @@ void HeightfieldBuffer::render(bool cursor) { · 690 unmodified lines
834824
835825 glDrawRangeElements(GL_TRIANGLES, 0, vertexCount - 1, indexCount, GL_UNSIGNED_INT, 0);
836826
837− glDrawBuffers(sizeof(COLOR_DRAW_BUFFERS) / sizeof(COLOR_DRAW_BUFFERS[0]), COLOR_DRAW_BUFFERS);
827+ Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
838828
839829 glDepthFunc(GL_LEQUAL);
840830 glDepthMask(false);
@@ -907,7 +897,7 @@ void HeightfieldBuffer::render(bool cursor) { · 66 unmodified lines
907897 glDepthMask(true);
908898 glDepthFunc(GL_LESS);
909899
910− glDrawBuffers(sizeof(COLOR_NORMAL_DRAW_BUFFERS) / sizeof(COLOR_NORMAL_DRAW_BUFFERS[0]), COLOR_NORMAL_DRAW_BUFFERS);
900+ Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
911901
912902 DefaultMetavoxelRendererImplementation::getBaseHeightfieldProgram().bind();
913903
@@ -936,7 +926,7 @@ void HeightfieldBuffer::render(bool cursor) { · 22 unmodified lines
936926 QHash<int, HeightfieldBuffer::BufferPair> HeightfieldBuffer::_bufferPairs;
937927
938928 void HeightfieldPreview::render(const glm::vec3& translation, float scale) const {
939− glDrawBuffers(sizeof(COLOR_NORMAL_DRAW_BUFFERS) / sizeof(COLOR_NORMAL_DRAW_BUFFERS[0]), COLOR_NORMAL_DRAW_BUFFERS);
929+ Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
940930
941931 glDisable(GL_BLEND);
942932 glEnable(GL_CULL_FACE);
@@ -969,7 +959,7 @@ void HeightfieldPreview::render(const glm::vec3& translation, float scale) const · 26 unmodified lines
969959 glDisable(GL_CULL_FACE);
970960 glEnable(GL_BLEND);
971961
972− glDrawBuffers(sizeof(COLOR_DRAW_BUFFERS) / sizeof(COLOR_DRAW_BUFFERS[0]), COLOR_DRAW_BUFFERS);
962+ Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
973963 }
974964
975965 VoxelBuffer::VoxelBuffer(const QVector<VoxelPoint>& vertices, const QVector<int>& indices,
@@ -1017,7 +1007,7 @@ void VoxelBuffer::render(bool cursor) { · 41 unmodified lines
10171007 glDrawRangeElements(GL_QUADS, 0, _vertexCount - 1, _indexCount, GL_UNSIGNED_INT, 0);
10181008
10191009 if (!_materials.isEmpty()) {
1020− glDrawBuffers(sizeof(COLOR_DRAW_BUFFERS) / sizeof(COLOR_DRAW_BUFFERS[0]), COLOR_DRAW_BUFFERS);
1010+ Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
10211011
10221012 glDepthFunc(GL_LEQUAL);
10231013 glDepthMask(false);
@@ -1087,7 +1077,7 @@ void VoxelBuffer::render(bool cursor) { · 63 unmodified lines
10871077 glDepthMask(true);
10881078 glDepthFunc(GL_LESS);
10891079
1090− glDrawBuffers(sizeof(COLOR_NORMAL_DRAW_BUFFERS) / sizeof(COLOR_NORMAL_DRAW_BUFFERS[0]), COLOR_NORMAL_DRAW_BUFFERS);
1080+ Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
10911081
10921082 DefaultMetavoxelRendererImplementation::getSplatVoxelProgram().disableAttributeArray(locations.materials);
10931083 DefaultMetavoxelRendererImplementation::getSplatVoxelProgram().disableAttributeArray(locations.materialWeights);
@@ -2132,7 +2122,7 @@ void DefaultMetavoxelRendererImplementation::render(MetavoxelData& data, Metavox · 1038 unmodified lines
21322122
21332123 _pointProgram.release();
21342124
2135− glDrawBuffers(sizeof(COLOR_NORMAL_DRAW_BUFFERS) / sizeof(COLOR_NORMAL_DRAW_BUFFERS[0]), COLOR_NORMAL_DRAW_BUFFERS);
2125+ Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
21362126
21372127 glEnable(GL_CULL_FACE);
21382128 glEnable(GL_ALPHA_TEST);
@@ -2175,7 +2165,7 @@ void DefaultMetavoxelRendererImplementation::render(MetavoxelData& data, Metavox · 36 unmodified lines
21752165 glDisableClientState(GL_COLOR_ARRAY);
21762166 glDisableClientState(GL_NORMAL_ARRAY);
21772167
2178− glDrawBuffers(sizeof(COLOR_DRAW_BUFFERS) / sizeof(COLOR_DRAW_BUFFERS[0]), COLOR_DRAW_BUFFERS);
2168+ Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
21792169 }
21802170
21812171 void DefaultMetavoxelRendererImplementation::loadSplatProgram(const char* type,