mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 16:49:58 +02:00
Fidling around with aa
This commit is contained in:
parent
1c8332d85d
commit
f3a6729940
3 changed files with 40 additions and 8 deletions
|
@ -211,7 +211,8 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
|||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("colorTexture"), 0));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("historyTexture"), 0));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("colorTexture"), 1));
|
||||
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
||||
|
@ -220,10 +221,7 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
|||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
PrepareStencil::testMask(*state);
|
||||
|
||||
// state->setDepthTest(false, false, gpu::LESS_EQUAL);
|
||||
state->setBlendFunction(true, gpu::State::BlendArg::SRC_ALPHA, gpu::State::BlendOp::BLEND_OP_ADD, gpu::State::BlendArg::INV_SRC_ALPHA );
|
||||
|
||||
|
||||
// Good to go add the brand new pipeline
|
||||
_antialiasingPipeline = gpu::Pipeline::create(program, state);
|
||||
}
|
||||
|
@ -245,6 +243,8 @@ const gpu::PipelinePointer& Antialiasing::getBlendPipeline() {
|
|||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
PrepareStencil::testMask(*state);
|
||||
|
||||
state->setBlendFunction(true, gpu::State::BlendArg::SRC_ALPHA, gpu::State::BlendOp::BLEND_OP_ADD, gpu::State::BlendArg::INV_SRC_ALPHA );
|
||||
|
||||
// Good to go add the brand new pipeline
|
||||
_blendPipeline = gpu::Pipeline::create(program, state);
|
||||
}
|
||||
|
@ -262,13 +262,16 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
|||
batch.setViewportTransform(args->_viewport);
|
||||
|
||||
// TAA step
|
||||
batch.setResourceTexture(0, sourceBuffer->getRenderBuffer(0));
|
||||
getAntialiasingPipeline();
|
||||
batch.setResourceTexture(0, _antialiasingTexture);
|
||||
batch.setResourceTexture(1, sourceBuffer->getRenderBuffer(0));
|
||||
batch.setFramebuffer(_antialiasingBuffer);
|
||||
batch.setPipeline(getAntialiasingPipeline());
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
|
||||
// Blend step
|
||||
batch.setResourceTexture(0, _antialiasingTexture);
|
||||
// batch.setResourceTexture(0, _antialiasingTexture);
|
||||
batch.setResourceTexture(1, nullptr);
|
||||
batch.setFramebuffer(sourceBuffer);
|
||||
batch.setPipeline(getBlendPipeline());
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
|
|
|
@ -23,13 +23,39 @@ precision mediump int;
|
|||
#endif
|
||||
|
||||
uniform sampler2D colorTexture;
|
||||
uniform sampler2D historyTexture;
|
||||
uniform vec2 texcoordOffset;
|
||||
|
||||
in vec2 varTexCoord0;
|
||||
out vec4 outFragColor;
|
||||
|
||||
void main() {
|
||||
outFragColor = vec4(texture(colorTexture, varTexCoord0).xyz, 0.3);
|
||||
// outFragColor = vec4(texture(colorTexture, varTexCoord0).xyz, 0.3);
|
||||
|
||||
// v2
|
||||
float ModulationFactor = 1.0 / 16.0;
|
||||
|
||||
vec3 CurrentSubpixel = textureLod(colorTexture, varTexCoord0, 0.0).rgb;
|
||||
vec3 History = textureLod(historyTexture, varTexCoord0, 0.0).rgb;
|
||||
|
||||
vec3 NearColor0 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(1, 0)).xyz;
|
||||
vec3 NearColor1 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(0, 1)).xyz;
|
||||
vec3 NearColor2 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(-1, 0)).xyz;
|
||||
vec3 NearColor3 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(0, -1)).xyz;
|
||||
|
||||
vec3 BoxMin = min(CurrentSubpixel, min(NearColor0, min(NearColor1, min(NearColor2, NearColor3))));
|
||||
vec3 BoxMax = max(CurrentSubpixel, max(NearColor0, max(NearColor1, max(NearColor2, NearColor3))));;
|
||||
|
||||
History = clamp(History, BoxMin, BoxMax);
|
||||
|
||||
//if (gl_FragCoord.x > 800) {
|
||||
outFragColor.xyz = History;
|
||||
outFragColor.w = ModulationFactor;
|
||||
/* } else {
|
||||
outFragColor.xyz = CurrentSubpixel;
|
||||
outFragColor.w = 1.0;
|
||||
|
||||
}*/
|
||||
/* // filter width limit for dependent "two-tap" texture samples
|
||||
float FXAA_SPAN_MAX = 8.0;
|
||||
|
||||
|
|
|
@ -21,4 +21,7 @@ uniform sampler2D colorTexture;
|
|||
|
||||
void main(void) {
|
||||
outFragColor = texture(colorTexture, varTexCoord0);
|
||||
if (gl_FragCoord.x > 800) {
|
||||
outFragColor.w = 1.0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue