Motion blur fixes

This commit is contained in:
luboslenco 2019-02-10 18:08:38 +01:00
parent 64edf25dee
commit af0efb7eca
3 changed files with 12 additions and 18 deletions

View file

@ -6,8 +6,6 @@
#include "std/gbuffer.glsl"
uniform sampler2D gbufferD;
uniform sampler2D gbuffer0;
uniform sampler2D tex;
uniform mat4 prevVP;
uniform vec3 eye;
@ -20,6 +18,9 @@ in vec3 viewRay;
out vec4 fragColor;
vec2 getVelocity(vec2 coord, float depth) {
#ifdef HLSL
coord.y = 1.0 - coord.y;
#endif
vec4 currentPos = vec4(coord.xy * 2.0 - 1.0, depth, 1.0);
vec4 worldPos = vec4(getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj), 1.0);
vec4 previousPos = prevVP * worldPos;
@ -31,11 +32,6 @@ vec2 getVelocity(vec2 coord, float depth) {
void main() {
fragColor.rgb = textureLod(tex, texCoord, 0.0).rgb;
// Do not blur masked objects
if (textureLod(gbuffer0, texCoord, 0.0).a == 1.0) {
return;
}
float depth = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
if (depth == 1.0) {
return;
@ -48,10 +44,8 @@ void main() {
int processed = 1;
for(int i = 0; i < 8; ++i) {
offset += velocity;
if (textureLod(gbuffer0, offset, 0.0).a != 1.0) {
fragColor.rgb += textureLod(tex, offset, 0.0).rgb;
processed++;
}
fragColor.rgb += textureLod(tex, offset, 0.0).rgb;
processed++;
}
fragColor.rgb /= processed;
}

View file

@ -4,7 +4,6 @@
#include "compiled.inc"
uniform sampler2D gbuffer0;
uniform sampler2D sveloc;
uniform sampler2D tex;
// uniform vec2 texStep;
@ -18,11 +17,6 @@ void main() {
fragColor.rgb = textureLod(tex, texCoord, 0.0).rgb;
// Do not blur masked objects
if (textureLod(gbuffer0, texCoord, 0.0).a == 1.0) {
return;
}
// float speed = length(velocity / texStep);
// const int MAX_SAMPLES = 8;
// int samples = clamp(int(speed), 1, MAX_SAMPLES);

View file

@ -803,13 +803,19 @@ class RenderPathDeferred {
#if ((rp_motionblur == "Camera") || (rp_motionblur == "Object"))
{
if (armory.data.Config.raw.rp_motionblur != false) {
#if (rp_motionblur == "Camera")
{
path.setDepthFrom("tex", "gbuffer1"); // Unbind depth so we can read it
}
#end
path.setTarget("buf");
path.bindTarget("tex", "tex");
path.bindTarget("gbuffer0", "gbuffer0");
#if (rp_motionblur == "Camera")
{
path.bindTarget("_main", "gbufferD");
path.drawShader("shader_datas/motion_blur_pass/motion_blur_pass");
path.setDepthFrom("tex", "gbuffer0"); // Re-bind depth
}
#else
{