History

More progress on shadows.

Andrzej Kapolka committed 12 years ago

Commit 4bcc6fd1 parent 5cc5d9b4 files · +36 −4Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+23−4
@@ -1386,20 +1386,39 @@ void VoxelSystem::render(bool texture) { · 1385 unmodified lines
13861386 }
13871387
13881388 void VoxelSystem::applyScaleAndBindProgram(bool texture) {
1389− glPushMatrix();
1390− glScalef(_treeScale, _treeScale, _treeScale);
13911389
1392− if (texture) {
1390+ if (Menu::getInstance()->isOptionChecked(MenuOption::Shadows)) {
1391+ glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getShadowDepthTextureID());
1392+ glEnable(GL_TEXTURE_GEN_S);
1393+ glEnable(GL_TEXTURE_GEN_T);
1394+ glEnable(GL_TEXTURE_GEN_R);
1395+ glEnable(GL_TEXTURE_2D);
1396+
1397+ glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&Application::getInstance()->getShadowMatrix()[0]);
1398+ glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&Application::getInstance()->getShadowMatrix()[1]);
1399+ glTexGenfv(GL_R, GL_EYE_PLANE, (const GLfloat*)&Application::getInstance()->getShadowMatrix()[2]);
1400+
1401+ } else if (texture) {
13931402 _perlinModulateProgram.bind();
13941403 glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPermutationNormalTextureID());
13951404 }
1405+
1406+ glPushMatrix();
1407+ glScalef(_treeScale, _treeScale, _treeScale);
13961408 }
13971409
13981410 void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
13991411 // scale back down to 1 so heads aren't massive
14001412 glPopMatrix();
14011413
1402− if (texture) {
1414+ if (Menu::getInstance()->isOptionChecked(MenuOption::Shadows)) {
1415+ glBindTexture(GL_TEXTURE_2D, 0);
1416+ glDisable(GL_TEXTURE_GEN_S);
1417+ glDisable(GL_TEXTURE_GEN_T);
1418+ glDisable(GL_TEXTURE_GEN_R);
1419+ glDisable(GL_TEXTURE_2D);
1420+
1421+ } else if (texture) {
14031422 _perlinModulateProgram.release();
14041423 glBindTexture(GL_TEXTURE_2D, 0);
14051424 }