Showing the changes to libraries/render-utils/src/DeferredLightingEffect.cpp (1 of 6 files). Show all
Unified · Split
| @@ -275,7 +275,7 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu · 274 unmodified lines | |||
| 275 | 275 | ||
| 276 | model::LightPointer lp = model::LightPointer(new model::Light()); | 276 | model::LightPointer lp = model::LightPointer(new model::Light()); |
| 277 | lp->setPosition(position); | 277 | lp->setPosition(position); |
| 278 | lp->setAttenuationRadius(radius); | 278 | lp->setMaximumRadius(radius); |
| 279 | lp->setColor(diffuse); | 279 | lp->setColor(diffuse); |
| 280 | lp->setIntensity(1.0f); | 280 | lp->setIntensity(1.0f); |
| 281 | lp->setType(model::Light::POINT); | 281 | lp->setType(model::Light::POINT); |
| @@ -297,7 +297,7 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu · 15 unmodified lines | |||
| 297 | model::LightPointer ls = model::LightPointer(new model::Light()); | 297 | model::LightPointer ls = model::LightPointer(new model::Light()); |
| 298 | ls->setPosition(position); | 298 | ls->setPosition(position); |
| 299 | ls->setDirection(direction); | 299 | ls->setDirection(direction); |
| 300 | ls->setAttenuationRadius(radius); | 300 | ls->setMaximumRadius(radius); |
| 301 | ls->setSpotCone(cutoff); | 301 | ls->setSpotCone(cutoff); |
| 302 | ls->setColor(diffuse); | 302 | ls->setColor(diffuse); |
| 303 | ls->setIntensity(1.0f); | 303 | ls->setIntensity(1.0f); |
| @@ -453,6 +453,8 @@ void DeferredLightingEffect::render() { · 149 unmodified lines | |||
| 453 | 453 | ||
| 454 | const glm::vec3& eyePoint = _viewState->getCurrentViewFrustum()->getPosition(); | 454 | const glm::vec3& eyePoint = _viewState->getCurrentViewFrustum()->getPosition(); |
| 455 | float nearRadius = glm::distance(eyePoint, _viewState->getCurrentViewFrustum()->getNearTopLeft()); | 455 | float nearRadius = glm::distance(eyePoint, _viewState->getCurrentViewFrustum()->getNearTopLeft()); |
| 456 | glm::mat4 invViewMat; | ||
| 457 | _viewState->getViewTransform().getMatrix(invViewMat); | ||
| 456 | 458 | ||
| 457 | auto geometryCache = DependencyManager::get<GeometryCache>(); | 459 | auto geometryCache = DependencyManager::get<GeometryCache>(); |
| 458 | 460 | ||
| @@ -470,7 +472,9 @@ void DeferredLightingEffect::render() { · 11 unmodified lines | |||
| 470 | batch.setUniformBuffer(_pointLightLocations.lightBufferUnit, light->getSchemaBuffer()); | 472 | batch.setUniformBuffer(_pointLightLocations.lightBufferUnit, light->getSchemaBuffer()); |
| 471 | gpu::GLBackend::renderBatch(batch); | 473 | gpu::GLBackend::renderBatch(batch); |
| 472 | } | 474 | } |
| 473 | _spotLight.setUniformValue(_pointLightLocations.radius, light->getAttenuationRadius()); | 475 | glUniformMatrix4fv(_pointLightLocations.invViewMat, 1, false, reinterpret_cast< const GLfloat* >(&invViewMat)); |
| 476 | // _pointLight.setUniformValue(_pointLightLocations.viewMat, reinterpret_cast< const GLfloat* >(&viewMat)); | ||
| 477 | // _spotLight.setUniformValue(_pointLightLocations.radius, light->getAttenuationRadius()); | ||
| 474 | 478 | ||
| 475 | 479 | ||
| 476 | /* | 480 | /* |
| @@ -485,7 +489,7 @@ void DeferredLightingEffect::render() { · 8 unmodified lines | |||
| 485 | */ | 489 | */ |
| 486 | glPushMatrix(); | 490 | glPushMatrix(); |
| 487 | 491 | ||
| 488 | float expandedRadius = light->getAttenuationRadius() * (1.0f + SCALE_EXPANSION); | 492 | float expandedRadius = light->getMaximumRadius() * (1.0f + SCALE_EXPANSION); |
| 489 | if (glm::distance(eyePoint, glm::vec3(light->getPosition())) < expandedRadius + nearRadius) { | 493 | if (glm::distance(eyePoint, glm::vec3(light->getPosition())) < expandedRadius + nearRadius) { |
| 490 | glLoadIdentity(); | 494 | glLoadIdentity(); |
| 491 | glTranslatef(0.0f, 0.0f, -1.0f); | 495 | glTranslatef(0.0f, 0.0f, -1.0f); |
| @@ -525,7 +529,7 @@ void DeferredLightingEffect::render() { · 33 unmodified lines | |||
| 525 | batch.setUniformBuffer(_spotLightLocations.lightBufferUnit, light->getSchemaBuffer()); | 529 | batch.setUniformBuffer(_spotLightLocations.lightBufferUnit, light->getSchemaBuffer()); |
| 526 | gpu::GLBackend::renderBatch(batch); | 530 | gpu::GLBackend::renderBatch(batch); |
| 527 | } | 531 | } |
| 528 | _spotLight.setUniformValue(_spotLightLocations.radius, light->getAttenuationRadius()); | 532 | // _spotLight.setUniformValue(_spotLightLocations.radius, light->getAttenuationRadius()); |
| 529 | 533 | ||
| 530 | /* | 534 | /* |
| 531 | _spotLight.setUniformValue(_spotLightLocations.radius, light.radius); | 535 | _spotLight.setUniformValue(_spotLightLocations.radius, light.radius); |
| @@ -543,7 +547,7 @@ void DeferredLightingEffect::render() { · 11 unmodified lines | |||
| 543 | 547 | ||
| 544 | glPushMatrix(); | 548 | glPushMatrix(); |
| 545 | 549 | ||
| 546 | float expandedRadius = light->getAttenuationRadius() * (1.0f + SCALE_EXPANSION); | 550 | float expandedRadius = light->getMaximumRadius() * (1.0f + SCALE_EXPANSION); |
| 547 | float edgeRadius = expandedRadius / glm::cos(light->getSpotConeAngle()); | 551 | float edgeRadius = expandedRadius / glm::cos(light->getSpotConeAngle()); |
| 548 | if (glm::distance(eyePoint, glm::vec3(light->getPosition())) < edgeRadius + nearRadius) { | 552 | if (glm::distance(eyePoint, glm::vec3(light->getPosition())) < edgeRadius + nearRadius) { |
| 549 | glLoadIdentity(); | 553 | glLoadIdentity(); |
| @@ -563,7 +567,7 @@ void DeferredLightingEffect::render() { · 13 unmodified lines | |||
| 563 | glm::quat spotRotation = rotationBetween(glm::vec3(0.0f, 0.0f, -1.0f), light->getDirection()); | 567 | glm::quat spotRotation = rotationBetween(glm::vec3(0.0f, 0.0f, -1.0f), light->getDirection()); |
| 564 | glm::vec3 axis = glm::axis(spotRotation); | 568 | glm::vec3 axis = glm::axis(spotRotation); |
| 565 | glRotatef(glm::degrees(glm::angle(spotRotation)), axis.x, axis.y, axis.z); | 569 | glRotatef(glm::degrees(glm::angle(spotRotation)), axis.x, axis.y, axis.z); |
| 566 | glTranslatef(0.0f, 0.0f, -light->getAttenuationRadius() * (1.0f + SCALE_EXPANSION * 0.5f)); | 570 | glTranslatef(0.0f, 0.0f, -light->getMaximumRadius() * (1.0f + SCALE_EXPANSION * 0.5f)); |
| 567 | geometryCache->renderCone(expandedRadius * glm::tan(light->getSpotConeAngle()), | 571 | geometryCache->renderCone(expandedRadius * glm::tan(light->getSpotConeAngle()), |
| 568 | expandedRadius, 32, 1); | 572 | expandedRadius, 32, 1); |
| 569 | } | 573 | } |
| @@ -649,6 +653,7 @@ void DeferredLightingEffect::loadLightProgram(const char* fragSource, bool limit · 79 unmodified lines | |||
| 649 | locations.depthTexCoordScale = program.uniformLocation("depthTexCoordScale"); | 653 | locations.depthTexCoordScale = program.uniformLocation("depthTexCoordScale"); |
| 650 | locations.radius = program.uniformLocation("radius"); | 654 | locations.radius = program.uniformLocation("radius"); |
| 651 | locations.ambientSphere = program.uniformLocation("ambientSphere.L00"); | 655 | locations.ambientSphere = program.uniformLocation("ambientSphere.L00"); |
| 656 | locations.invViewMat = program.uniformLocation("invViewMat"); | ||
| 652 | 657 | ||
| 653 | GLint loc = -1; | 658 | GLint loc = -1; |
| 654 | #if defined(Q_OS_MAC) | 659 | #if defined(Q_OS_MAC) |
| @@ -661,8 +666,8 @@ void DeferredLightingEffect::loadLightProgram(const char* fragSource, bool limit · 6 unmodified lines | |||
| 661 | #elif defined(Q_OS_WIN) | 666 | #elif defined(Q_OS_WIN) |
| 662 | loc = glGetUniformBlockIndex(program.programId(), "lightBuffer"); | 667 | loc = glGetUniformBlockIndex(program.programId(), "lightBuffer"); |
| 663 | if (loc >= 0) { | 668 | if (loc >= 0) { |
| 664 | glUniformBlockBinding(program.programId(), loc, 1); | 669 | glUniformBlockBinding(program.programId(), loc, 0); |
| 665 | locations.lightBufferUnit = 1; | 670 | locations.lightBufferUnit = 0; |
| 666 | } else { | 671 | } else { |
| 667 | locations.lightBufferUnit = -1; | 672 | locations.lightBufferUnit = -1; |
| 668 | } | 673 | } |