From 3baa02a7fe1232410c3fcb1d7bbe65308e3cf80b Mon Sep 17 00:00:00 2001 From: Yili Zhao Date: Tue, 10 Sep 2019 17:28:44 -0700 Subject: [PATCH 1/7] Support ptex mesh - step 5: improve the shader and rendering code -) added gamma, saturation etc.; -) refactored the PTexMeshShader a bit, moving function implementations to .cpp file; -) cached the uniform positions; --- src/esp/assets/PTexMeshData.cpp | 16 ++++++++++ src/esp/assets/PTexMeshData.h | 18 +++++++++-- src/esp/gfx/PTexMeshDrawable.cpp | 9 ++++-- src/esp/gfx/PTexMeshDrawable.h | 2 ++ src/esp/gfx/PTexMeshShader.cpp | 47 +++++++++++++++++++++++++---- src/esp/gfx/PTexMeshShader.h | 46 +++++++++++----------------- src/shaders/ptex-default-gl410.frag | 22 ++++++++++++-- 7 files changed, 117 insertions(+), 43 deletions(-) diff --git a/src/esp/assets/PTexMeshData.cpp b/src/esp/assets/PTexMeshData.cpp index 3e548ca0db..f2e6dedb11 100644 --- a/src/esp/assets/PTexMeshData.cpp +++ b/src/esp/assets/PTexMeshData.cpp @@ -54,6 +54,22 @@ void PTexMeshData::setExposure(const float& val) { exposure_ = val; } +float PTexMeshData::gamma() const { + return gamma_; +} + +void PTexMeshData::setGamma(const float& val) { + gamma_ = val; +} + +float PTexMeshData::saturation() const { + return saturation_; +} + +void PTexMeshData::setSaturation(const float& val) { + saturation_ = val; +} + const std::vector& PTexMeshData::meshes() const { return submeshes_; } diff --git a/src/esp/assets/PTexMeshData.h b/src/esp/assets/PTexMeshData.h index 4a0f46358c..03031f3ef2 100644 --- a/src/esp/assets/PTexMeshData.h +++ b/src/esp/assets/PTexMeshData.h @@ -45,8 +45,6 @@ class PTexMeshData : public BaseMesh { // ==== geometry ==== void load(const std::string& meshFile, const std::string& atlasFolder); - float exposure() const; - void setExposure(const float& val); uint32_t tileSize() const { return tileSize_; } const std::vector& meshes() const; @@ -64,12 +62,26 @@ class PTexMeshData : public BaseMesh { virtual void uploadBuffersToGPU(bool forceReload = false) override; virtual Magnum::GL::Mesh* getMagnumGLMesh(int submeshID) override; + float exposure() const; + void setExposure(const float& val); + + float gamma() const; + void setGamma(const float& val); + + float saturation() const; + void setSaturation(const float& val); + protected: void loadMeshData(const std::string& meshFile); float splitSize_ = 0.0f; uint32_t tileSize_ = 0; - float exposure_ = 1.0f; + + // based on ReplicaSDK + float exposure_ = 0.025f; + float gamma_ = 1.6969f; + float saturation_ = 1.5f; + std::string atlasFolder_; std::vector submeshes_; diff --git a/src/esp/gfx/PTexMeshDrawable.cpp b/src/esp/gfx/PTexMeshDrawable.cpp index a2a5f569e9..eb79aef3e5 100644 --- a/src/esp/gfx/PTexMeshDrawable.cpp +++ b/src/esp/gfx/PTexMeshDrawable.cpp @@ -21,12 +21,17 @@ PTexMeshDrawable::PTexMeshDrawable( adjFacesBufferTexture_( ptexMeshData.getRenderingBuffer(submeshID)->adjFacesBufferTexture), tileSize_(ptexMeshData.tileSize()), - exposure_(ptexMeshData.exposure()) {} + exposure_(ptexMeshData.exposure()), + gamma_(ptexMeshData.gamma()), + saturation_(ptexMeshData.saturation()) {} void PTexMeshDrawable::draw(const Magnum::Matrix4& transformationMatrix, Magnum::SceneGraph::Camera3D& camera) { PTexMeshShader& ptexMeshShader = static_cast(shader_); - ptexMeshShader.setPTexUniforms(atlasTexture_, tileSize_, exposure_) + ptexMeshShader.setExposure(exposure_) + .setGamma(gamma_) + .setSaturation(saturation_) + .setAtlasTextureSize(atlasTexture_, tileSize_) .bindAtlasTexture(atlasTexture_) .bindAdjFacesBufferTexture(adjFacesBufferTexture_) .setMVPMatrix(camera.projectionMatrix() * transformationMatrix); diff --git a/src/esp/gfx/PTexMeshDrawable.h b/src/esp/gfx/PTexMeshDrawable.h index 8ae0ac7d51..6a2d905b46 100644 --- a/src/esp/gfx/PTexMeshDrawable.h +++ b/src/esp/gfx/PTexMeshDrawable.h @@ -32,6 +32,8 @@ class PTexMeshDrawable : public Drawable { Magnum::GL::BufferTexture& adjFacesBufferTexture_; uint32_t tileSize_; float exposure_; + float gamma_; + float saturation_; }; } // namespace gfx diff --git a/src/esp/gfx/PTexMeshShader.cpp b/src/esp/gfx/PTexMeshShader.cpp index a5f27e5f8e..7b5c009018 100644 --- a/src/esp/gfx/PTexMeshShader.cpp +++ b/src/esp/gfx/PTexMeshShader.cpp @@ -2,12 +2,6 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. -#include "PTexMeshShader.h" - -#include -#include -#include - #include #include #include @@ -17,6 +11,7 @@ #include #include +#include "PTexMeshShader.h" #include "esp/assets/PTexMeshData.h" #include "esp/core/esp.h" #include "esp/io/io.h" @@ -70,6 +65,14 @@ PTexMeshShader::PTexMeshShader() { // TODO: disable the "meshAdjFaces" on Mac setUniform(uniformLocation("meshAdjFaces"), TextureBindingPointIndex::adjFaces); + + // cache the uniform locations + MVPMatrixUniform_ = uniformLocation("MVP"); + exposureUniform_ = uniformLocation("exposure"); + gammaUniform_ = uniformLocation("gamma"); + saturationUniform_ = uniformLocation("saturation"); + tileSizeUniform_ = uniformLocation("tileSize"); + widthInTilesUniform_ = uniformLocation("widthInTiles"); } // Note: the texture binding points are explicitly specified above. @@ -87,5 +90,37 @@ PTexMeshShader& PTexMeshShader::bindAdjFacesBufferTexture( return *this; } +PTexMeshShader& PTexMeshShader::setMVPMatrix(const Magnum::Matrix4& matrix) { + setUniform(MVPMatrixUniform_, matrix); + return *this; +} + +PTexMeshShader& PTexMeshShader::setExposure(float exposure) { + setUniform(exposureUniform_, exposure); + return *this; +} +PTexMeshShader& PTexMeshShader::setGamma(float gamma) { + // Careful: we set its inverse, not gamma directly + setUniform(gammaUniform_, 1.0f / gamma); + return *this; +} + +PTexMeshShader& PTexMeshShader::setSaturation(float saturation) { + setUniform(saturationUniform_, saturation); + return *this; +} + +PTexMeshShader& PTexMeshShader::setAtlasTextureSize(Magnum::GL::Texture2D& tex, + uint32_t tileSize) { + setUniform(tileSizeUniform_, (int)tileSize); + + // Image size in given mip level 0 + int mipLevel = 0; + int widthEntry = 0; + const auto width = tex.imageSize(mipLevel)[widthEntry]; + setUniform(widthInTilesUniform_, int(width / tileSize)); + return *this; +} + } // namespace gfx } // namespace esp diff --git a/src/esp/gfx/PTexMeshShader.h b/src/esp/gfx/PTexMeshShader.h index 6889c9b165..914f71ff3d 100644 --- a/src/esp/gfx/PTexMeshShader.h +++ b/src/esp/gfx/PTexMeshShader.h @@ -32,35 +32,23 @@ class PTexMeshShader : public Magnum::GL::AbstractShaderProgram { PTexMeshShader& bindAdjFacesBufferTexture(Magnum::GL::BufferTexture& texture); // ======== set uniforms =========== - PTexMeshShader& setMVPMatrix(const Magnum::Matrix4& matrix) { - setUniform(uniformLocation("MVP"), matrix); - return *this; - } - - PTexMeshShader& setPTexUniforms(assets::PTexMeshData& ptexMeshData, - int submeshID, - uint32_t tileSize, - float exposure) { - setPTexUniforms(ptexMeshData.getRenderingBuffer(submeshID)->atlasTexture, - tileSize, exposure); - return *this; - } - - PTexMeshShader& setPTexUniforms(Magnum::GL::Texture2D& tex, - uint32_t tileSize, - float exposure) { - setUniform(uniformLocation("atlasTex"), 0); - setUniform(uniformLocation("tileSize"), static_cast(tileSize)); - // Image size in given mip level 0 - { - int mipLevel = 0; - int widthEntry = 0; - const auto width = tex.imageSize(mipLevel)[widthEntry]; - setUniform(uniformLocation("widthInTiles"), int(width / tileSize)); - } - setUniform(uniformLocation("exposure"), exposure); - return *this; - } + PTexMeshShader& setMVPMatrix(const Magnum::Matrix4& matrix); + PTexMeshShader& setExposure(float exposure); + PTexMeshShader& setGamma(float gamma); + PTexMeshShader& setSaturation(float saturation); + PTexMeshShader& setAtlasTextureSize(Magnum::GL::Texture2D& texture, + uint32_t tileSize); + + protected: + // it hurts the performance to call glGetUniformLocation() every frame due to + // string operations. + // therefore, cache the locations in the constructor + int MVPMatrixUniform_; + int exposureUniform_; + int gammaUniform_; + int saturationUniform_; + int tileSizeUniform_; + int widthInTilesUniform_; }; } // namespace gfx diff --git a/src/shaders/ptex-default-gl410.frag b/src/shaders/ptex-default-gl410.frag index 132a9d6ae3..ea99c71a95 100644 --- a/src/shaders/ptex-default-gl410.frag +++ b/src/shaders/ptex-default-gl410.frag @@ -155,15 +155,31 @@ vec4 textureAtlas(sampler2D tex, int faceID, vec2 p) { f.y); } +void applySaturation(inout vec4 c, float saturation) { + float Pr = 0.299f; + float Pg = 0.587f; + float Pb = 0.114f; + + float P = sqrt(c.r * c.r * Pr + c.g * c.g * Pg + c.b * c.b * Pb); + + c.r = P + (c.r - P) * saturation; + c.g = P + (c.g - P) * saturation; + c.b = P + (c.b - P) * saturation; +} + layout(location = 0) out vec4 FragColor; uniform sampler2D atlasTex; uniform float exposure; +uniform float gamma; +uniform float saturation; in vec2 uv; void main() { - vec4 c = textureAtlas(atlasTex, gl_PrimitiveID, uv * tileSize) * exposure; - // c = vec4(1.0f, 1.0f, 1.0f, 1.0f); - FragColor = vec4(c.xyz, 1.0f); + vec4 c = textureAtlas(atlasTex, gl_PrimitiveID, uv * tileSize); + c *= exposure; + applySaturation(c, saturation); + c.rgb = pow(c.rgb, vec3(gamma)); + FragColor = vec4(c.rgb, 1.0f); } From d64ae2c7332beb838d38be0e2a090dd4d98f1bff Mon Sep 17 00:00:00 2001 From: Yili Zhao Date: Tue, 10 Sep 2019 17:35:32 -0700 Subject: [PATCH 2/7] minor --- src/shaders/ptex-default-gl410.frag | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/shaders/ptex-default-gl410.frag b/src/shaders/ptex-default-gl410.frag index ea99c71a95..e82eee8d7e 100644 --- a/src/shaders/ptex-default-gl410.frag +++ b/src/shaders/ptex-default-gl410.frag @@ -177,8 +177,7 @@ uniform float saturation; in vec2 uv; void main() { - vec4 c = textureAtlas(atlasTex, gl_PrimitiveID, uv * tileSize); - c *= exposure; + vec4 c = textureAtlas(atlasTex, gl_PrimitiveID, uv * tileSize) * exposure; applySaturation(c, saturation); c.rgb = pow(c.rgb, vec3(gamma)); FragColor = vec4(c.rgb, 1.0f); From 021f73809ced7522477ac39f4c6f1338e87ce299 Mon Sep 17 00:00:00 2001 From: Yili Zhao Date: Tue, 10 Sep 2019 17:38:21 -0700 Subject: [PATCH 3/7] minor --- src/esp/gfx/PTexMeshShader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/esp/gfx/PTexMeshShader.cpp b/src/esp/gfx/PTexMeshShader.cpp index 7b5c009018..56bd18aecc 100644 --- a/src/esp/gfx/PTexMeshShader.cpp +++ b/src/esp/gfx/PTexMeshShader.cpp @@ -110,14 +110,14 @@ PTexMeshShader& PTexMeshShader::setSaturation(float saturation) { return *this; } -PTexMeshShader& PTexMeshShader::setAtlasTextureSize(Magnum::GL::Texture2D& tex, +PTexMeshShader& PTexMeshShader::setAtlasTextureSize(Magnum::GL::Texture2D& texture, uint32_t tileSize) { setUniform(tileSizeUniform_, (int)tileSize); // Image size in given mip level 0 int mipLevel = 0; int widthEntry = 0; - const auto width = tex.imageSize(mipLevel)[widthEntry]; + const auto width = texture.imageSize(mipLevel)[widthEntry]; setUniform(widthInTilesUniform_, int(width / tileSize)); return *this; } From e3c1c475e5f725abe724d0ca631364968b1e7f6c Mon Sep 17 00:00:00 2001 From: Yili Zhao Date: Wed, 11 Sep 2019 14:05:55 -0700 Subject: [PATCH 4/7] resolve Ci error --- src/esp/gfx/PTexMeshShader.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/esp/gfx/PTexMeshShader.cpp b/src/esp/gfx/PTexMeshShader.cpp index 56bd18aecc..e4fa4eb084 100644 --- a/src/esp/gfx/PTexMeshShader.cpp +++ b/src/esp/gfx/PTexMeshShader.cpp @@ -110,8 +110,9 @@ PTexMeshShader& PTexMeshShader::setSaturation(float saturation) { return *this; } -PTexMeshShader& PTexMeshShader::setAtlasTextureSize(Magnum::GL::Texture2D& texture, - uint32_t tileSize) { +PTexMeshShader& PTexMeshShader::setAtlasTextureSize( + Magnum::GL::Texture2D& texture, + uint32_t tileSize) { setUniform(tileSizeUniform_, (int)tileSize); // Image size in given mip level 0 From 08c4018f7d00c1997357f8d1060edd6c07c011f9 Mon Sep 17 00:00:00 2001 From: Yili Zhao Date: Wed, 11 Sep 2019 14:23:59 -0700 Subject: [PATCH 5/7] rename gamma as gammaInverse in the shader --- src/esp/gfx/PTexMeshShader.cpp | 4 ++-- src/esp/gfx/PTexMeshShader.h | 2 +- src/shaders/ptex-default-gl410.frag | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/esp/gfx/PTexMeshShader.cpp b/src/esp/gfx/PTexMeshShader.cpp index e4fa4eb084..9a616e13a5 100644 --- a/src/esp/gfx/PTexMeshShader.cpp +++ b/src/esp/gfx/PTexMeshShader.cpp @@ -69,7 +69,7 @@ PTexMeshShader::PTexMeshShader() { // cache the uniform locations MVPMatrixUniform_ = uniformLocation("MVP"); exposureUniform_ = uniformLocation("exposure"); - gammaUniform_ = uniformLocation("gamma"); + gammaInverseUniform_ = uniformLocation("gammaInverse"); saturationUniform_ = uniformLocation("saturation"); tileSizeUniform_ = uniformLocation("tileSize"); widthInTilesUniform_ = uniformLocation("widthInTiles"); @@ -101,7 +101,7 @@ PTexMeshShader& PTexMeshShader::setExposure(float exposure) { } PTexMeshShader& PTexMeshShader::setGamma(float gamma) { // Careful: we set its inverse, not gamma directly - setUniform(gammaUniform_, 1.0f / gamma); + setUniform(gammaInverseUniform_, 1.0f / gamma); return *this; } diff --git a/src/esp/gfx/PTexMeshShader.h b/src/esp/gfx/PTexMeshShader.h index 914f71ff3d..94f259c099 100644 --- a/src/esp/gfx/PTexMeshShader.h +++ b/src/esp/gfx/PTexMeshShader.h @@ -45,7 +45,7 @@ class PTexMeshShader : public Magnum::GL::AbstractShaderProgram { // therefore, cache the locations in the constructor int MVPMatrixUniform_; int exposureUniform_; - int gammaUniform_; + int gammaInverseUniform_; int saturationUniform_; int tileSizeUniform_; int widthInTilesUniform_; diff --git a/src/shaders/ptex-default-gl410.frag b/src/shaders/ptex-default-gl410.frag index e82eee8d7e..4ce9e6a69c 100644 --- a/src/shaders/ptex-default-gl410.frag +++ b/src/shaders/ptex-default-gl410.frag @@ -171,7 +171,7 @@ layout(location = 0) out vec4 FragColor; uniform sampler2D atlasTex; uniform float exposure; -uniform float gamma; +uniform float gammaInverse; uniform float saturation; in vec2 uv; @@ -179,6 +179,6 @@ in vec2 uv; void main() { vec4 c = textureAtlas(atlasTex, gl_PrimitiveID, uv * tileSize) * exposure; applySaturation(c, saturation); - c.rgb = pow(c.rgb, vec3(gamma)); + c.rgb = pow(c.rgb, vec3(gammaInverse)); FragColor = vec4(c.rgb, 1.0f); } From 69793f58c60cadb06c2f0767c4c569df0c4225aa Mon Sep 17 00:00:00 2001 From: Yili Zhao Date: Thu, 12 Sep 2019 15:37:47 -0700 Subject: [PATCH 6/7] add docstring, get rid of the inverse of gamma everywhere --- src/esp/assets/PTexMeshData.cpp | 6 ++--- src/esp/assets/PTexMeshData.h | 15 ++++++++----- src/esp/gfx/PTexMeshShader.cpp | 10 ++++----- src/esp/gfx/PTexMeshShader.h | 34 ++++++++++++++++++++++++++++- src/shaders/ptex-default-gl410.frag | 4 ++-- 5 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/esp/assets/PTexMeshData.cpp b/src/esp/assets/PTexMeshData.cpp index f2e6dedb11..f97ffc6096 100644 --- a/src/esp/assets/PTexMeshData.cpp +++ b/src/esp/assets/PTexMeshData.cpp @@ -50,7 +50,7 @@ float PTexMeshData::exposure() const { return exposure_; } -void PTexMeshData::setExposure(const float& val) { +void PTexMeshData::setExposure(float val) { exposure_ = val; } @@ -58,7 +58,7 @@ float PTexMeshData::gamma() const { return gamma_; } -void PTexMeshData::setGamma(const float& val) { +void PTexMeshData::setGamma(float val) { gamma_ = val; } @@ -66,7 +66,7 @@ float PTexMeshData::saturation() const { return saturation_; } -void PTexMeshData::setSaturation(const float& val) { +void PTexMeshData::setSaturation(float val) { saturation_ = val; } diff --git a/src/esp/assets/PTexMeshData.h b/src/esp/assets/PTexMeshData.h index 03031f3ef2..59fac7f6fa 100644 --- a/src/esp/assets/PTexMeshData.h +++ b/src/esp/assets/PTexMeshData.h @@ -63,13 +63,13 @@ class PTexMeshData : public BaseMesh { virtual Magnum::GL::Mesh* getMagnumGLMesh(int submeshID) override; float exposure() const; - void setExposure(const float& val); + void setExposure(float val); float gamma() const; - void setGamma(const float& val); + void setGamma(float val); float saturation() const; - void setSaturation(const float& val); + void setSaturation(float val); protected: void loadMeshData(const std::string& meshFile); @@ -77,9 +77,14 @@ class PTexMeshData : public BaseMesh { float splitSize_ = 0.0f; uint32_t tileSize_ = 0; - // based on ReplicaSDK + // initial values are based on ReplicaSDK + //! @brief expsure, the amount of light per unit area reaching the image float exposure_ = 0.025f; - float gamma_ = 1.6969f; + + //! @brief gamma, the exponent applied in the gamma correction + float gamma_ = 1.0f / 1.6969f; + + //! @brief saturation, the intensity of a color float saturation_ = 1.5f; std::string atlasFolder_; diff --git a/src/esp/gfx/PTexMeshShader.cpp b/src/esp/gfx/PTexMeshShader.cpp index 9a616e13a5..3d61739d64 100644 --- a/src/esp/gfx/PTexMeshShader.cpp +++ b/src/esp/gfx/PTexMeshShader.cpp @@ -69,7 +69,7 @@ PTexMeshShader::PTexMeshShader() { // cache the uniform locations MVPMatrixUniform_ = uniformLocation("MVP"); exposureUniform_ = uniformLocation("exposure"); - gammaInverseUniform_ = uniformLocation("gammaInverse"); + gammaUniform_ = uniformLocation("gamma"); saturationUniform_ = uniformLocation("saturation"); tileSizeUniform_ = uniformLocation("tileSize"); widthInTilesUniform_ = uniformLocation("widthInTiles"); @@ -100,8 +100,7 @@ PTexMeshShader& PTexMeshShader::setExposure(float exposure) { return *this; } PTexMeshShader& PTexMeshShader::setGamma(float gamma) { - // Careful: we set its inverse, not gamma directly - setUniform(gammaInverseUniform_, 1.0f / gamma); + setUniform(gammaUniform_, gamma); return *this; } @@ -115,10 +114,9 @@ PTexMeshShader& PTexMeshShader::setAtlasTextureSize( uint32_t tileSize) { setUniform(tileSizeUniform_, (int)tileSize); - // Image size in given mip level 0 + // get image width in given mip level 0 int mipLevel = 0; - int widthEntry = 0; - const auto width = texture.imageSize(mipLevel)[widthEntry]; + const auto width = texture.imageSize(mipLevel).x(); setUniform(widthInTilesUniform_, int(width / tileSize)); return *this; } diff --git a/src/esp/gfx/PTexMeshShader.h b/src/esp/gfx/PTexMeshShader.h index 94f259c099..4a062af88d 100644 --- a/src/esp/gfx/PTexMeshShader.h +++ b/src/esp/gfx/PTexMeshShader.h @@ -23,19 +23,51 @@ namespace gfx { class PTexMeshShader : public Magnum::GL::AbstractShaderProgram { public: + //! @brief vertex positions typedef Magnum::GL::Attribute<0, Magnum::Vector4> Position; + /** + * @brief Constructor + */ explicit PTexMeshShader(); // ======== texture binding ======== + /** + *! @brief Bind the atlas texture + *! @return Reference to self (for method chaining) + */ PTexMeshShader& bindAtlasTexture(Magnum::GL::Texture2D& texture); + /** + *! @brief Bind the buffer texture containing the adjacent faces + *! @return Reference to self (for method chaining) + */ PTexMeshShader& bindAdjFacesBufferTexture(Magnum::GL::BufferTexture& texture); // ======== set uniforms =========== + /** + *! @brief Set modelview and projection matrix to the uniform on GPU + *! @return Reference to self (for method chaining) + */ PTexMeshShader& setMVPMatrix(const Magnum::Matrix4& matrix); + /** + *! @brief Set expsure to the uniform on GPU + *! @return Reference to self (for method chaining) + */ PTexMeshShader& setExposure(float exposure); + /** + *! @brief Set gamma to the uniform on GPU + *! @return Reference to self (for method chaining) + */ PTexMeshShader& setGamma(float gamma); + /** + *! @brief Set saturation to the uniform on GPU + *! @return Reference to self (for method chaining) + */ PTexMeshShader& setSaturation(float saturation); + /** + *! @brief Set the tile size of the atlas texture + *! @return Reference to self (for method chaining) + */ PTexMeshShader& setAtlasTextureSize(Magnum::GL::Texture2D& texture, uint32_t tileSize); @@ -45,7 +77,7 @@ class PTexMeshShader : public Magnum::GL::AbstractShaderProgram { // therefore, cache the locations in the constructor int MVPMatrixUniform_; int exposureUniform_; - int gammaInverseUniform_; + int gammaUniform_; int saturationUniform_; int tileSizeUniform_; int widthInTilesUniform_; diff --git a/src/shaders/ptex-default-gl410.frag b/src/shaders/ptex-default-gl410.frag index 4ce9e6a69c..e82eee8d7e 100644 --- a/src/shaders/ptex-default-gl410.frag +++ b/src/shaders/ptex-default-gl410.frag @@ -171,7 +171,7 @@ layout(location = 0) out vec4 FragColor; uniform sampler2D atlasTex; uniform float exposure; -uniform float gammaInverse; +uniform float gamma; uniform float saturation; in vec2 uv; @@ -179,6 +179,6 @@ in vec2 uv; void main() { vec4 c = textureAtlas(atlasTex, gl_PrimitiveID, uv * tileSize) * exposure; applySaturation(c, saturation); - c.rgb = pow(c.rgb, vec3(gammaInverse)); + c.rgb = pow(c.rgb, vec3(gamma)); FragColor = vec4(c.rgb, 1.0f); } From 4f52d1fcfe7857586ff6d38b1e6d37073113f678 Mon Sep 17 00:00:00 2001 From: Yili Zhao Date: Thu, 12 Sep 2019 15:44:09 -0700 Subject: [PATCH 7/7] minor --- src/esp/assets/PTexMeshData.h | 2 +- src/esp/gfx/PTexMeshShader.h | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/esp/assets/PTexMeshData.h b/src/esp/assets/PTexMeshData.h index 59fac7f6fa..b6d24fe7db 100644 --- a/src/esp/assets/PTexMeshData.h +++ b/src/esp/assets/PTexMeshData.h @@ -78,7 +78,7 @@ class PTexMeshData : public BaseMesh { uint32_t tileSize_ = 0; // initial values are based on ReplicaSDK - //! @brief expsure, the amount of light per unit area reaching the image + //! @brief exposure, the amount of light per unit area reaching the image float exposure_ = 0.025f; //! @brief gamma, the exponent applied in the gamma correction diff --git a/src/esp/gfx/PTexMeshShader.h b/src/esp/gfx/PTexMeshShader.h index 4a062af88d..aab380ad4e 100644 --- a/src/esp/gfx/PTexMeshShader.h +++ b/src/esp/gfx/PTexMeshShader.h @@ -33,40 +33,40 @@ class PTexMeshShader : public Magnum::GL::AbstractShaderProgram { // ======== texture binding ======== /** - *! @brief Bind the atlas texture - *! @return Reference to self (for method chaining) + * @brief Bind the atlas texture + * @return Reference to self (for method chaining) */ PTexMeshShader& bindAtlasTexture(Magnum::GL::Texture2D& texture); /** - *! @brief Bind the buffer texture containing the adjacent faces - *! @return Reference to self (for method chaining) + * @brief Bind the buffer texture containing the adjacent faces + * @return Reference to self (for method chaining) */ PTexMeshShader& bindAdjFacesBufferTexture(Magnum::GL::BufferTexture& texture); // ======== set uniforms =========== /** - *! @brief Set modelview and projection matrix to the uniform on GPU - *! @return Reference to self (for method chaining) + * @brief Set modelview and projection matrix to the uniform on GPU + * @return Reference to self (for method chaining) */ PTexMeshShader& setMVPMatrix(const Magnum::Matrix4& matrix); /** - *! @brief Set expsure to the uniform on GPU - *! @return Reference to self (for method chaining) + * @brief Set expsure to the uniform on GPU + * @return Reference to self (for method chaining) */ PTexMeshShader& setExposure(float exposure); /** - *! @brief Set gamma to the uniform on GPU - *! @return Reference to self (for method chaining) + * @brief Set gamma to the uniform on GPU + * @return Reference to self (for method chaining) */ PTexMeshShader& setGamma(float gamma); /** - *! @brief Set saturation to the uniform on GPU - *! @return Reference to self (for method chaining) + * @brief Set saturation to the uniform on GPU + * @return Reference to self (for method chaining) */ PTexMeshShader& setSaturation(float saturation); /** - *! @brief Set the tile size of the atlas texture - *! @return Reference to self (for method chaining) + * @brief Set the tile size of the atlas texture + * @return Reference to self (for method chaining) */ PTexMeshShader& setAtlasTextureSize(Magnum::GL::Texture2D& texture, uint32_t tileSize);