mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 23:26:25 +02:00
Added adjustable post sharpen filter
This commit is contained in:
parent
d316b6e074
commit
c9a6d6bf14
4 changed files with 36 additions and 4 deletions
|
@ -246,6 +246,8 @@ const gpu::PipelinePointer& Antialiasing::getBlendPipeline() {
|
|||
|
||||
// Good to go add the brand new pipeline
|
||||
_blendPipeline = gpu::Pipeline::create(program, state);
|
||||
_sharpenLoc = program->getUniforms().findLocation("sharpenIntensity");
|
||||
|
||||
}
|
||||
return _blendPipeline;
|
||||
}
|
||||
|
@ -280,6 +282,7 @@ const gpu::PipelinePointer& Antialiasing::getDebugBlendPipeline() {
|
|||
}
|
||||
|
||||
void Antialiasing::configure(const Config& config) {
|
||||
_sharpen = config.sharpen;
|
||||
_params.edit().blend = config.blend;
|
||||
_params.edit().covarianceGamma = config.covarianceGamma;
|
||||
|
||||
|
@ -363,6 +366,7 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
|||
batch.setPipeline(getDebugBlendPipeline());
|
||||
} else {
|
||||
batch.setPipeline(getBlendPipeline());
|
||||
batch._glUniform1f(_sharpenLoc, _sharpen);
|
||||
}
|
||||
batch.setResourceFramebufferSwapChainTexture(AntialiasingPass_NextMapSlot, _antialiasingBuffers, 1);
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
|
|
|
@ -86,6 +86,7 @@ private:
|
|||
class AntialiasingConfig : public render::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float blend MEMBER blend NOTIFY dirty)
|
||||
Q_PROPERTY(float sharpen MEMBER sharpen NOTIFY dirty)
|
||||
Q_PROPERTY(float covarianceGamma MEMBER covarianceGamma NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(bool constrainColor MEMBER constrainColor NOTIFY dirty)
|
||||
|
@ -106,8 +107,8 @@ class AntialiasingConfig : public render::Job::Config {
|
|||
public:
|
||||
AntialiasingConfig() : render::Job::Config(true) {}
|
||||
|
||||
float blend{ 0.075f };
|
||||
|
||||
float blend{ 0.05f };
|
||||
float sharpen{ 0.25f };
|
||||
|
||||
bool constrainColor{ true };
|
||||
bool covarianceClipColor{ true };
|
||||
|
@ -134,7 +135,7 @@ signals:
|
|||
|
||||
struct TAAParams {
|
||||
float nope{ 0.0f };
|
||||
float blend{ 0.1f };
|
||||
float blend{ 0.05f };
|
||||
float covarianceGamma{ 1.0f };
|
||||
float debugShowVelocityThreshold{ 1.0f };
|
||||
|
||||
|
@ -199,6 +200,8 @@ private:
|
|||
gpu::PipelinePointer _debugBlendPipeline;
|
||||
|
||||
TAAParamsBuffer _params;
|
||||
float _sharpen{ 0.25f };
|
||||
int _sharpenLoc{ -1 };
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,23 @@ in vec2 varTexCoord0;
|
|||
out vec4 outFragColor;
|
||||
|
||||
uniform sampler2D colorTexture;
|
||||
uniform float sharpenIntensity;
|
||||
|
||||
void main(void) {
|
||||
outFragColor = texture(colorTexture, varTexCoord0);
|
||||
vec4 pixels[9];
|
||||
vec4 sharpenedPixel;
|
||||
pixels[0] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy)+ivec2(-1,-1), 0);
|
||||
pixels[1] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy)+ivec2(0,-1), 0);
|
||||
pixels[2] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy)+ivec2(1,-1), 0);
|
||||
|
||||
pixels[3] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy)+ivec2(-1,0), 0);
|
||||
pixels[4] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy), 0);
|
||||
pixels[5] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy)+ivec2(1,0), 0);
|
||||
|
||||
pixels[6] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy)+ivec2(-1,1), 0);
|
||||
pixels[7] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy)+ivec2(0,1), 0);
|
||||
pixels[8] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy)+ivec2(1,1), 0);
|
||||
|
||||
sharpenedPixel = pixels[4]*7.8 - (pixels[1]+pixels[3]+pixels[5]+pixels[7]) - (pixels[0]+pixels[2]+pixels[6]+pixels[8])*0.7;
|
||||
outFragColor = mix(pixels[4], sharpenedPixel, sharpenIntensity);
|
||||
}
|
||||
|
|
|
@ -137,6 +137,15 @@ Rectangle {
|
|||
max: 1.0
|
||||
min: 0.0
|
||||
}
|
||||
|
||||
ConfigSlider {
|
||||
label: qsTr("Post sharpen")
|
||||
integral: false
|
||||
config: Render.getConfig("RenderMainView.Antialiasing")
|
||||
property: "sharpen"
|
||||
max: 1.0
|
||||
min: 0.0
|
||||
}
|
||||
|
||||
}
|
||||
Separator {}
|
||||
|
|
Loading…
Reference in a new issue