From e11d10f5d4bdf8219fe3dde27ba17c13ff31946e Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 8 Feb 2017 16:56:59 -0800 Subject: [PATCH] Reparing broken normals and also fixing the ambient lighting bug --- libraries/gpu-gl/src/gpu/gl/GLBackend.cpp | 4 ++-- .../gpu-gl/src/gpu/gl/GLBackendPipeline.cpp | 2 +- .../gpu-gl/src/gpu/gl/GLBackendState.cpp | 24 +++++++++++++++---- .../gpu-gl/src/gpu/gl/GLTextureTransfer.cpp | 2 +- libraries/model/src/model/TextureMap.cpp | 20 ++++++++-------- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp index dbfe8fe730..c51f468908 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp @@ -328,12 +328,12 @@ void GLBackend::render(const Batch& batch) { void GLBackend::syncCache() { + PROFILE_RANGE(render_gpu_gl_detail, __FUNCTION__); + syncTransformStateCache(); syncPipelineStateCache(); syncInputStateCache(); syncOutputStateCache(); - - glEnable(GL_LINE_SMOOTH); } #ifdef GPU_STEREO_DRAWCALL_DOUBLED diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackendPipeline.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackendPipeline.cpp index 81d38c3339..8aab6abaa9 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackendPipeline.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackendPipeline.cpp @@ -1,4 +1,4 @@ -// +// // GLBackendPipeline.cpp // libraries/gpu/src/gpu // diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackendState.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackendState.cpp index 6f8c229184..a7d4a7ff7c 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackendState.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackendState.cpp @@ -28,11 +28,8 @@ void GLBackend::resetPipelineState(State::Signature nextSignature) { } } } -} - -void GLBackend::syncPipelineStateCache() { - State::Data state; + // force a few states regardless glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); // Point size is always on @@ -43,6 +40,25 @@ void GLBackend::syncPipelineStateCache() { // Default line width accross the board glLineWidth(1.0f); + glEnable(GL_LINE_SMOOTH); + +} + +void GLBackend::syncPipelineStateCache() { + State::Data state; + + // force a few states regardless + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + + // Point size is always on + // FIXME CORE + //glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); + glEnable(GL_PROGRAM_POINT_SIZE_EXT); + glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); + + // Default line width accross the board + glLineWidth(1.0f); + glEnable(GL_LINE_SMOOTH); getCurrentGLState(state); State::Signature signature = State::evalSignature(state); diff --git a/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp b/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp index 14c0a3923a..9dac2986e3 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp @@ -151,7 +151,7 @@ bool GLTextureTransferHelper::process() { #endif return true; } - PROFILE_COUNTER_IF_CHANGED(render_gpu_gl, "transferringTextures", size_t, _transferringTextures.size()) + PROFILE_COUNTER_IF_CHANGED(render_gpu_gl, "transferringTextures", int, (int) _transferringTextures.size()) static auto lastReport = usecTimestampNow(); auto now = usecTimestampNow(); diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp index 839a704e54..db87950e5a 100755 --- a/libraries/model/src/model/TextureMap.cpp +++ b/libraries/model/src/model/TextureMap.cpp @@ -143,7 +143,7 @@ const QImage TextureUsage::process2DImageColor(const QImage& srcImage, bool& val // Force all the color images to be rgba32bits if (image.format() != QImage::Format_ARGB32) { - image = image.convertToFormat(QImage::Format_ARGB32); + image = image.convertToFormat(QImage::Format_ARGB32); } return image; @@ -287,8 +287,8 @@ gpu::Texture* TextureUsage::createNormalTextureFromNormalImage(const QImage& src QImage image = processSourceImage(srcImage, false); // Make sure the normal map source image is RGBA32 - if (image.format() != QImage::Format_ARGB32) { - image = image.convertToFormat(QImage::Format_ARGB32); + if (image.format() != QImage::Format_RGBA8888) { + image = image.convertToFormat(QImage::Format_RGBA8888); } gpu::Texture* theTexture = nullptr; @@ -332,7 +332,7 @@ gpu::Texture* TextureUsage::createNormalTextureFromBumpImage(const QImage& srcIm int width = image.width(); int height = image.height(); // THe end result image for normal map is RGBA32 even though the A is not used - QImage result(width, height, QImage::Format_ARGB32); + QImage result(width, height, QImage::Format_RGBA8888); for (int i = 0; i < width; i++) { const int iNextClamped = clampPixelCoordinate(i + 1, width - 1); @@ -400,8 +400,8 @@ gpu::Texture* TextureUsage::createRoughnessTextureFromImage(const QImage& srcIma image = image.convertToFormat(QImage::Format_RGB888); } } else { - if (image.format() != QImage::Format_ARGB32) { - image = image.convertToFormat(QImage::Format_ARGB32); + if (image.format() != QImage::Format_RGBA8888) { + image = image.convertToFormat(QImage::Format_RGBA8888); } } @@ -435,8 +435,8 @@ gpu::Texture* TextureUsage::createRoughnessTextureFromGlossImage(const QImage& s image = image.convertToFormat(QImage::Format_RGB888); } } else { - if (image.format() != QImage::Format_ARGB32) { - image = image.convertToFormat(QImage::Format_ARGB32); + if (image.format() != QImage::Format_RGBA8888) { + image = image.convertToFormat(QImage::Format_RGBA8888); } } @@ -474,8 +474,8 @@ gpu::Texture* TextureUsage::createMetallicTextureFromImage(const QImage& srcImag image = image.convertToFormat(QImage::Format_RGB888); } } else { - if (image.format() != QImage::Format_ARGB32) { - image = image.convertToFormat(QImage::Format_ARGB32); + if (image.format() != QImage::Format_RGBA8888) { + image = image.convertToFormat(QImage::Format_RGBA8888); } }