diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index 5e3177c6ea..14fa6574b2 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -87,6 +87,11 @@ public: GLuint _transformCameraSlot = -1; GLuint _transformObjectSlot = -1; +#if (GPU_TRANSFORM_PROFILE == GPU_CORE) +#else + GLuint _transformCamera_viewInverse = -1; +#endif + GLShader(); ~GLShader(); }; @@ -311,6 +316,11 @@ protected: GLuint _program; bool _invalidProgram; +#if (GPU_TRANSFORM_PROFILE == GPU_CORE) +#else + GLuint _program_transformCamera_viewInverse = -1; +#endif + State::Data _stateCache; State::Signature _stateSignatureCache; diff --git a/libraries/gpu/src/gpu/GLBackendPipeline.cpp b/libraries/gpu/src/gpu/GLBackendPipeline.cpp index ec9be957ae..1dd4ea4c2b 100755 --- a/libraries/gpu/src/gpu/GLBackendPipeline.cpp +++ b/libraries/gpu/src/gpu/GLBackendPipeline.cpp @@ -71,6 +71,11 @@ void GLBackend::do_setPipeline(Batch& batch, uint32 paramOffset) { _pipeline._program = 0; _pipeline._invalidProgram = true; +#if (GPU_TRANSFORM_PROFILE == GPU_CORE) +#else + _pipeline._program_transformCamera_viewInverse = -1 +#endif + _pipeline._state = nullptr; _pipeline._invalidState = true; } else { @@ -83,6 +88,11 @@ void GLBackend::do_setPipeline(Batch& batch, uint32 paramOffset) { if (_pipeline._program != pipelineObject->_program->_program) { _pipeline._program = pipelineObject->_program->_program; _pipeline._invalidProgram = true; + +#if (GPU_TRANSFORM_PROFILE == GPU_CORE) +#else + _pipeline._program_transformCamera_viewInverse = pipelineObject->_program->_transformCamera_viewInverse; +#endif } // Now for the state @@ -130,6 +140,15 @@ void GLBackend::updatePipeline() { } _pipeline._invalidState = false; } + +#if (GPU_TRANSFORM_PROFILE == GPU_CORE) +#else + // If shader program needs the inverseView we need to provide it + // YES InverseView in the shade is called View on the Batch interface + if (_pipeline._program_transformCamera_viewInverse >= 0) { + glUniformMatrix4fv(_pipeline._program_transformCamera_viewInverse, 1, false, &_transform._view); + } +#endif } void GLBackend::do_setUniformBuffer(Batch& batch, uint32 paramOffset) { diff --git a/libraries/gpu/src/gpu/GLBackendShader.cpp b/libraries/gpu/src/gpu/GLBackendShader.cpp index 75b3df3e33..e0ea2f2d98 100755 --- a/libraries/gpu/src/gpu/GLBackendShader.cpp +++ b/libraries/gpu/src/gpu/GLBackendShader.cpp @@ -106,6 +106,11 @@ void makeBindings(GLBackend::GLShader* shader) { glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_CAMERA_SLOT); shader->_transformCameraSlot = gpu::TRANSFORM_CAMERA_SLOT; } +#else + loc = glGetUniformLocation(glprogram, "transformCamera_viewInverse"); + if (loc >= 0) { + shader->_transformCamera_viewInverse = loc; + } #endif }