mirror of
https://github.com/lubosz/overte.git
synced 2025-04-15 19:47:38 +02:00
Limited sharpen range
This commit is contained in:
parent
16cd1e3fd5
commit
c04bf095ec
6 changed files with 18 additions and 13 deletions
|
@ -187,7 +187,8 @@ const int AntialiasingPass_DepthMapSlot = 3;
|
|||
const int AntialiasingPass_NextMapSlot = 4;
|
||||
|
||||
|
||||
Antialiasing::Antialiasing() {
|
||||
Antialiasing::Antialiasing(bool isSharpenEnabled) :
|
||||
_isSharpenEnabled{ isSharpenEnabled } {
|
||||
_antialiasingBuffers = std::make_shared<gpu::FramebufferSwapChain>(2U);
|
||||
}
|
||||
|
||||
|
@ -283,6 +284,9 @@ const gpu::PipelinePointer& Antialiasing::getDebugBlendPipeline() {
|
|||
|
||||
void Antialiasing::configure(const Config& config) {
|
||||
_sharpen = config.sharpen;
|
||||
if (!_isSharpenEnabled) {
|
||||
_sharpen = 0.0f;
|
||||
}
|
||||
_params.edit().blend = config.blend * config.blend;
|
||||
_params.edit().covarianceGamma = config.covarianceGamma;
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class AntialiasingConfig : public render::Job::Config {
|
|||
public:
|
||||
AntialiasingConfig() : render::Job::Config(true) {}
|
||||
|
||||
float blend{ 0.05f };
|
||||
float blend{ 0.1f };
|
||||
float sharpen{ 0.15f };
|
||||
|
||||
bool constrainColor{ true };
|
||||
|
@ -178,7 +178,7 @@ public:
|
|||
using Config = AntialiasingConfig;
|
||||
using JobModel = render::Job::ModelI<Antialiasing, Inputs, Config>;
|
||||
|
||||
Antialiasing();
|
||||
Antialiasing(bool isSharpenEnabled = true);
|
||||
~Antialiasing();
|
||||
void configure(const Config& config);
|
||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
||||
|
@ -199,6 +199,7 @@ private:
|
|||
TAAParamsBuffer _params;
|
||||
float _sharpen{ 0.15f };
|
||||
int _sharpenLoc{ -1 };
|
||||
bool _isSharpenEnabled{ true };
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class BloomApplyConfig : public render::Job::Config {
|
|||
|
||||
public:
|
||||
|
||||
float intensity{ 0.15f };
|
||||
float intensity{ 0.2f };
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
|
|
|
@ -51,14 +51,14 @@ TexMapArray getTexMapArray() {
|
|||
<@if withAlbedo@>
|
||||
uniform sampler2D albedoMap;
|
||||
vec4 fetchAlbedoMap(vec2 uv) {
|
||||
return texture(albedoMap, uv);
|
||||
return texture(albedoMap, uv, -1.0);
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
<@if withRoughness@>
|
||||
uniform sampler2D roughnessMap;
|
||||
float fetchRoughnessMap(vec2 uv) {
|
||||
return (texture(roughnessMap, uv).r);
|
||||
return (texture(roughnessMap, uv, -1.0).r);
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
|
@ -66,7 +66,7 @@ float fetchRoughnessMap(vec2 uv) {
|
|||
uniform sampler2D normalMap;
|
||||
vec3 fetchNormalMap(vec2 uv) {
|
||||
// unpack normal, swizzle to get into hifi tangent space with Y axis pointing out
|
||||
vec2 t = 2.0 * (texture(normalMap, uv).rg - vec2(0.5, 0.5));
|
||||
vec2 t = 2.0 * (texture(normalMap, uv, -1.0).rg - vec2(0.5, 0.5));
|
||||
vec2 t2 = t*t;
|
||||
return vec3(t.x, sqrt(1.0 - t2.x - t2.y), t.y);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ vec3 fetchNormalMap(vec2 uv) {
|
|||
<@if withMetallic@>
|
||||
uniform sampler2D metallicMap;
|
||||
float fetchMetallicMap(vec2 uv) {
|
||||
return (texture(metallicMap, uv).r);
|
||||
return (texture(metallicMap, uv, -1.0).r);
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
|
@ -164,8 +164,8 @@ vec3 fetchLightmapMap(vec2 uv) {
|
|||
vec3 normalizedTangent = normalize(<$interpolatedTangent$>.xyz);
|
||||
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
|
||||
// attenuate the normal map divergence from the mesh normal based on distance
|
||||
// THe attenuation range [20,100] meters from the eye is arbitrary for now
|
||||
vec3 localNormal = mix(<$fetchedNormal$>, vec3(0.0, 1.0, 0.0), smoothstep(20.0, 100.0, (-<$fragPos$>).z));
|
||||
// THe attenuation range [100,300] meters from the eye is arbitrary for now
|
||||
vec3 localNormal = mix(<$fetchedNormal$>, vec3(0.0, 1.0, 0.0), smoothstep(100.0, 300.0, (-<$fragPos$>).z));
|
||||
<$normal$> = vec3(normalizedTangent * localNormal.x + normalizedNormal * localNormal.y + normalizedBitangent * localNormal.z);
|
||||
}
|
||||
<@endfunc@>
|
||||
|
|
|
@ -190,7 +190,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
|
|||
|
||||
const auto toneAndPostRangeTimer = task.addJob<BeginGPURangeTimer>("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing");
|
||||
|
||||
// AA job to be revisited
|
||||
// AA job
|
||||
const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, lightingFramebuffer, linearDepthTarget, velocityBuffer).asVarying();
|
||||
task.addJob<Antialiasing>("Antialiasing", antialiasingInputs);
|
||||
|
||||
|
|
|
@ -35,6 +35,6 @@ void main(void) {
|
|||
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);
|
||||
sharpenedPixel = pixels[4]*6.8 - (pixels[1]+pixels[3]+pixels[5]+pixels[7]) - (pixels[0]+pixels[2]+pixels[6]+pixels[8])*0.7;
|
||||
outFragColor = clamp(pixels[4] + sharpenedPixel * sharpenIntensity, pixels[4]/2, pixels[4]*2);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue