History

Merge branch 'master' of https://github.com/worklist/hifi into compressed_packets

ZappoMan committed 12 years ago

Commit 70213632 parents 66ebaae 7151d1627 files · +399 −114Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+33−4
@@ -519,6 +519,13 @@ void VoxelSystem::initVoxelMemory() { · 518 unmodified lines
519 _perlinModulateProgram.bind();519 _perlinModulateProgram.bind();
520 _perlinModulateProgram.setUniformValue("permutationNormalTexture", 0);520 _perlinModulateProgram.setUniformValue("permutationNormalTexture", 0);
521 _perlinModulateProgram.release();521 _perlinModulateProgram.release();
522
523 _shadowMapProgram.addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/shadow_map.frag");
524 _shadowMapProgram.link();
525
526 _shadowMapProgram.bind();
527 _shadowMapProgram.setUniformValue("shadowMap", 0);
528 _shadowMapProgram.release();
522 }529 }
523 }530 }
524 531
@@ -1092,6 +1099,7 @@ glm::vec3 VoxelSystem::computeVoxelVertex(const glm::vec3& startVertex, float vo · 567 unmodified lines
1092}1099}
1093 1100
1094ProgramObject VoxelSystem::_perlinModulateProgram;1101ProgramObject VoxelSystem::_perlinModulateProgram;
1102ProgramObject VoxelSystem::_shadowMapProgram;
1095 1103
1096void VoxelSystem::init() {1104void VoxelSystem::init() {
1097 if (_initialized) {1105 if (_initialized) {
@@ -1398,20 +1406,41 @@ void VoxelSystem::render(bool texture) { · 300 unmodified lines
1398}1406}
1399 1407
1400void VoxelSystem::applyScaleAndBindProgram(bool texture) {1408void VoxelSystem::applyScaleAndBindProgram(bool texture) {
1401 glPushMatrix();
1402 glScalef(_treeScale, _treeScale, _treeScale);
1403 1409
1404 if (texture) {1410 if (Menu::getInstance()->isOptionChecked(MenuOption::Shadows)) {
1411 _shadowMapProgram.bind();
1412 glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getShadowDepthTextureID());
1413 glEnable(GL_TEXTURE_GEN_S);
1414 glEnable(GL_TEXTURE_GEN_T);
1415 glEnable(GL_TEXTURE_GEN_R);
1416 glEnable(GL_TEXTURE_2D);
1417
1418 glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&Application::getInstance()->getShadowMatrix()[0]);
1419 glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&Application::getInstance()->getShadowMatrix()[1]);
1420 glTexGenfv(GL_R, GL_EYE_PLANE, (const GLfloat*)&Application::getInstance()->getShadowMatrix()[2]);
1421
1422 } else if (texture) {
1405 _perlinModulateProgram.bind();1423 _perlinModulateProgram.bind();
1406 glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPermutationNormalTextureID());1424 glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPermutationNormalTextureID());
1407 }1425 }
1426
1427 glPushMatrix();
1428 glScalef(_treeScale, _treeScale, _treeScale);
1408}1429}
1409 1430
1410void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {1431void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
1411 // scale back down to 1 so heads aren't massive1432 // scale back down to 1 so heads aren't massive
1412 glPopMatrix();1433 glPopMatrix();
1413 1434
1414 if (texture) {1435 if (Menu::getInstance()->isOptionChecked(MenuOption::Shadows)) {
1436 _shadowMapProgram.release();
1437 glBindTexture(GL_TEXTURE_2D, 0);
1438 glDisable(GL_TEXTURE_GEN_S);
1439 glDisable(GL_TEXTURE_GEN_T);
1440 glDisable(GL_TEXTURE_GEN_R);
1441 glDisable(GL_TEXTURE_2D);
1442
1443 } else if (texture) {
1415 _perlinModulateProgram.release();1444 _perlinModulateProgram.release();
1416 glBindTexture(GL_TEXTURE_2D, 0);1445 glBindTexture(GL_TEXTURE_2D, 0);
1417 }1446 }