mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-24 21:30:18 +02:00
Trying to produce history and current in one pass but it doesn;t work ?
This commit is contained in:
parent
271b4c1946
commit
ff6b9f59f8
2 changed files with 35 additions and 24 deletions
|
@ -188,21 +188,6 @@ Antialiasing::~Antialiasing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
||||||
int width = DependencyManager::get<FramebufferCache>()->getFrameBufferSize().width();
|
|
||||||
int height = DependencyManager::get<FramebufferCache>()->getFrameBufferSize().height();
|
|
||||||
|
|
||||||
if (_antialiasingBuffer && _antialiasingBuffer->getSize() != uvec2(width, height)) {
|
|
||||||
_antialiasingBuffer.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_antialiasingBuffer) {
|
|
||||||
// Link the antialiasing FBO to texture
|
|
||||||
_antialiasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("antialiasing"));
|
|
||||||
auto format = gpu::Element::COLOR_SRGBA_32; // DependencyManager::get<FramebufferCache>()->getLightingTexture()->getTexelFormat();
|
|
||||||
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT);
|
|
||||||
_antialiasingTexture = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, defaultSampler);
|
|
||||||
_antialiasingBuffer->setRenderBuffer(0, _antialiasingTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_antialiasingPipeline) {
|
if (!_antialiasingPipeline) {
|
||||||
|
|
||||||
|
@ -257,6 +242,25 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
||||||
|
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
|
|
||||||
|
int width = sourceBuffer->getWidth();
|
||||||
|
int height = sourceBuffer->getHeight();
|
||||||
|
|
||||||
|
if (_antialiasingBuffer) {
|
||||||
|
if (_antialiasingBuffer->getSize() != uvec2(width, height) || (sourceBuffer && (_antialiasingBuffer->getRenderBuffer(1) != sourceBuffer->getRenderBuffer(0)))) {
|
||||||
|
_antialiasingBuffer.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_antialiasingBuffer) {
|
||||||
|
// Link the antialiasing FBO to texture
|
||||||
|
_antialiasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("antialiasing"));
|
||||||
|
auto format = gpu::Element::COLOR_SRGBA_32; // DependencyManager::get<FramebufferCache>()->getLightingTexture()->getTexelFormat();
|
||||||
|
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT);
|
||||||
|
_antialiasingTexture = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, defaultSampler);
|
||||||
|
_antialiasingBuffer->setRenderBuffer(0, _antialiasingTexture);
|
||||||
|
_antialiasingBuffer->setRenderBuffer(1, sourceBuffer->getRenderBuffer(0));
|
||||||
|
}
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.setViewportTransform(args->_viewport);
|
batch.setViewportTransform(args->_viewport);
|
||||||
|
@ -268,14 +272,15 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
||||||
batch.setFramebuffer(_antialiasingBuffer);
|
batch.setFramebuffer(_antialiasingBuffer);
|
||||||
batch.setPipeline(getAntialiasingPipeline());
|
batch.setPipeline(getAntialiasingPipeline());
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
batch.setFramebuffer(sourceBuffer);
|
||||||
|
|
||||||
// Blend step
|
// Blend step
|
||||||
// batch.setResourceTexture(0, _antialiasingTexture);
|
// batch.setResourceTexture(0, _antialiasingTexture);
|
||||||
batch.setResourceTexture(1, nullptr);
|
/* batch.setResourceTexture(1, nullptr);
|
||||||
batch.setFramebuffer(sourceBuffer);
|
batch.setFramebuffer(sourceBuffer);
|
||||||
batch.setPipeline(getBlendPipeline());
|
batch.setPipeline(getBlendPipeline());
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,17 +27,18 @@ uniform sampler2D historyTexture;
|
||||||
uniform vec2 texcoordOffset;
|
uniform vec2 texcoordOffset;
|
||||||
|
|
||||||
in vec2 varTexCoord0;
|
in vec2 varTexCoord0;
|
||||||
out vec4 outFragColor;
|
layout(location = 0) out vec4 outFragColor;
|
||||||
|
layout(location = 1) out vec4 outFragColor2;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// outFragColor = vec4(texture(colorTexture, varTexCoord0).xyz, 0.3);
|
// outFragColor = vec4(texture(colorTexture, varTexCoord0).xyz, 0.3);
|
||||||
|
|
||||||
// v2
|
// v2
|
||||||
float ModulationFactor = 1.0 / 16.0;
|
float ModulationFactor = 1.0 / 8.0;
|
||||||
|
|
||||||
vec3 CurrentSubpixel = textureLod(colorTexture, varTexCoord0, 0.0).rgb;
|
vec3 CurrentSubpixel = textureLod(colorTexture, varTexCoord0, 0.0).rgb;
|
||||||
vec3 History = textureLod(historyTexture, varTexCoord0, 0.0).rgb;
|
vec3 History = textureLod(historyTexture, varTexCoord0, 0.0).rgb;
|
||||||
|
/*
|
||||||
vec3 NearColor0 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(1, 0)).xyz;
|
vec3 NearColor0 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(1, 0)).xyz;
|
||||||
vec3 NearColor1 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(0, 1)).xyz;
|
vec3 NearColor1 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(0, 1)).xyz;
|
||||||
vec3 NearColor2 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(-1, 0)).xyz;
|
vec3 NearColor2 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(-1, 0)).xyz;
|
||||||
|
@ -46,11 +47,16 @@ void main() {
|
||||||
vec3 BoxMin = min(CurrentSubpixel, min(NearColor0, min(NearColor1, min(NearColor2, NearColor3))));
|
vec3 BoxMin = min(CurrentSubpixel, min(NearColor0, min(NearColor1, min(NearColor2, NearColor3))));
|
||||||
vec3 BoxMax = max(CurrentSubpixel, max(NearColor0, max(NearColor1, max(NearColor2, NearColor3))));;
|
vec3 BoxMax = max(CurrentSubpixel, max(NearColor0, max(NearColor1, max(NearColor2, NearColor3))));;
|
||||||
|
|
||||||
|
if (gl_FragCoord.x > 800) {
|
||||||
History = clamp(History, BoxMin, BoxMax);
|
History = clamp(History, BoxMin, BoxMax);
|
||||||
|
}*/
|
||||||
|
outFragColor2.xyz = mix(CurrentSubpixel, History, ModulationFactor);
|
||||||
|
outFragColor2.w = 1.0;
|
||||||
|
|
||||||
//if (gl_FragCoord.x > 800) {
|
outFragColor.xyz = CurrentSubpixel;
|
||||||
outFragColor.xyz = History;
|
|
||||||
outFragColor.w = ModulationFactor;
|
outFragColor.w = ModulationFactor;
|
||||||
|
|
||||||
|
|
||||||
/* } else {
|
/* } else {
|
||||||
outFragColor.xyz = CurrentSubpixel;
|
outFragColor.xyz = CurrentSubpixel;
|
||||||
outFragColor.w = 1.0;
|
outFragColor.w = 1.0;
|
||||||
|
|
Loading…
Reference in a new issue