]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
new blur Shader motionBlur
authorPeter Schaefer <schaeferpm@gmail.com>
Thu, 23 Jun 2016 22:40:48 +0000 (00:40 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Thu, 23 Jun 2016 22:40:48 +0000 (00:40 +0200)
added MotionBlur (only for TimeRewind)

14 files changed:
CGUE2015_Weave.sln
Weave/Events.cpp
Weave/Graphix/Graphix.cpp
Weave/Graphix/Model/Model.cpp
Weave/Graphix/Shader.cpp
Weave/Graphix/Shader.h
Weave/Graphix/Textures/Texture.cpp
Weave/Graphix/Textures/Texture.h
Weave/Scene/Scene.cpp
Weave/Scene/Scene.h
shader/blurDirectional2_FS.hlsl [new file with mode: 0644]
shader/blurDirectional_FS.hlsl [new file with mode: 0644]
shader/blur_FS.hlsl
shader/filterMotion_FS.hlsl

index 3654fbee1706b39984e0c07aedc8c0ae48c89152..f0c6277aaa6ed188b0bc03086b95a0fe38d1d64d 100644 (file)
@@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shader", "shader", "{75179E
                shader\basicTexture_VS.hlsl = shader\basicTexture_VS.hlsl
                shader\blend_FS.hlsl = shader\blend_FS.hlsl
                shader\blur_FS.hlsl = shader\blur_FS.hlsl
+               shader\blurDirectional2_FS.hlsl = shader\blurDirectional2_FS.hlsl
+               shader\blurDirectional_FS.hlsl = shader\blurDirectional_FS.hlsl
                shader\filterBright_FS.hlsl = shader\filterBright_FS.hlsl
                shader\filterMotion_FS.hlsl = shader\filterMotion_FS.hlsl
                shader\lightingTexture_FS.hlsl = shader\lightingTexture_FS.hlsl
index 121c2c4fa22269f95cdb53475a3a9c197c1e9eeb..949544f6c2ae9c8be9d706df9b720f67c2a4480e 100644 (file)
@@ -165,7 +165,7 @@ void Events::KeyDown(int _key)
                break;
        case SDLK_LSHIFT:
                timeshift = true;
-               Graphix::enableEffects(EF_MOTION_BLUR_ACC);
+               Graphix::enableEffects(EF_MOTION_BLUR);
                break;
        default:
                break;
@@ -178,7 +178,7 @@ void Events::KeyUp(int _key)
        {
        case SDLK_LSHIFT:
                timeshift = false;
-               Graphix::disableEffects(EF_MOTION_BLUR_ACC);
+               Graphix::disableEffects(EF_MOTION_BLUR);
                break;
        default:
                break;
index daf2ec4fab30af9fb18664030594b8a7a65ef76f..9faa62b5b01e9cf03f139b941dcb4d07158f7f9e 100644 (file)
@@ -312,7 +312,7 @@ SDL_Window* Graphix::sdl_window;
 \r
 SDL_GLContext Graphix::sdl_glcontext;\r
 \r
-short Graphix::effects = EF_TRANSPARENCY | EF_BLOOM | EF_FRUSTUM_CULLING | EF_MOTION_BLUR;\r
+short Graphix::effects = EF_TRANSPARENCY | EF_BLOOM | EF_FRUSTUM_CULLING;\r
 \r
 int Graphix::obj = -1;\r
 Fps Graphix::fps(0.3f);\r
index a8e604beefbc6eb649f8747261ccdffa259a0f25..3c7ddc3528df7dbc79c7585d8f95056f7e0b1189 100644 (file)
@@ -293,6 +293,8 @@ Model* Model::getPlaneModel()
                PlaneModel->bindShader(Shader::getShader(SH_BLUR));\r
                PlaneModel->bindShader(Shader::getShader(SH_BLEND));\r
                PlaneModel->bindShader(Shader::getShader(SH_FILTER_BRIGHT));\r
+               PlaneModel->bindShader(Shader::getShader(SH_BLUR_DIRECTIONAL));\r
+\r
        }\r
        return PlaneModel;\r
 }\r
index a0bfe07f5d98662ea402301c12b8bf62613d5f8a..bffc7f5b0a0148fd390dbe32c2f9265800766eb6 100644 (file)
@@ -6,7 +6,7 @@
 
 using namespace std;
 
-#define SHADER_NUM 10
+#define SHADER_NUM 11
 
 Shader::Shader(string _shader1, string _shader2)
 {
@@ -250,6 +250,7 @@ void Shader::init()
                shList[SH_POINTLIGHT] = new Shader("pointlight_VS.hlsl", "pointlight_FS.hlsl");
                shList[SH_FILTER_BRIGHT] = new Shader("basic_VS.hlsl", "filterBright_FS.hlsl");
                shList[SH_FILTER_MOTION] = new Shader("basic_VS.hlsl", "filterMotion_FS.hlsl");
+               shList[SH_BLUR_DIRECTIONAL] = new Shader("basic_VS.hlsl", "blurDirectional2_FS.hlsl");
        }
 
        initShader = true;
index e127c15184efade835b7ce613fe72cad7dacf5f8..93df82292a31674a53d8fe8e96898dda755e26cc 100644 (file)
@@ -19,7 +19,8 @@ enum ShaderTarget {
        SH_SHADOWDIR = 6,
        SH_POINTLIGHT = 7,
        SH_FILTER_BRIGHT = 8,
-       SH_FILTER_MOTION = 9
+       SH_FILTER_MOTION = 9,
+       SH_BLUR_DIRECTIONAL = 10
 }; //Don't forget to resize the shList Array at the begining of shader.cpp!
 
 class Shader
index a5eae56a76400d5cd33720d1ea3809ddc16193f5..8db49054e73e642f38cf6acf02f56e42f0c7eccf 100644 (file)
@@ -9,7 +9,7 @@
 using std::string;
 using std::unordered_map;
 
-string bindTargets[] = {"uColorTexture", "uBlendTexture", "uPointLightXP", "uPointLightXM", "uPointLightYP", "uPointLightYM", "uPointLightZP", "uPointLightZM", "uBlurVec2" };
+string bindTargets[] = {"uColorTexture", "uBlendTexture", "uPointLightXP", "uPointLightXM", "uPointLightYP", "uPointLightYM", "uPointLightZP", "uPointLightZM", "uBlurVec" };
 
 
 Texture::Texture(texTarget _target, unsigned int _type)
index 5de1672312408b841f6ed1e01e25138c68a04ac8..d43cab71695aefc938f3ce2d4b55aac4d65f789f 100644 (file)
@@ -23,7 +23,7 @@ enum bindTarget {
        uPLightYM = 5,
        uPLightZP = 6,
        uPLightZM = 7,
-       uBLURVEC2 = 8
+       uBLURVEC = 8
 }; //Don't forget to assign the correct name in bindTargets at the beginning of Texture.cpp!
 
 class Texture
index 109b635a22686ad2eff8c13479b84f99a9c5d9c2..25c94e3a5bf2a644200bbcd0dc20d55de168fa3c 100644 (file)
@@ -87,7 +87,7 @@ lookat(_lookat)
        bt_dynamics_world->setGravity(btVector3(0, YFALL_SPEED, 0));
 
        /*BUFFERS*/
-       render = new fBufferObject(2);
+       render = new fBufferObject();
        render->bindBuffer(W_WIDTH, W_HEIGHT);
 
        blurPingPong = new fBufferObject*[2];
@@ -100,15 +100,20 @@ lookat(_lookat)
        shadowdir = new dBufferObject();
        shadowdir->bindBuffer(1024, 1024);
 
-       postRender = new fBufferObject(1, false);
-       postRender->bindBuffer(W_WIDTH, W_HEIGHT);
-
-       postRenderSmall = new fBufferObject(1, false);
-       postRenderSmall->bindBuffer(W_WIDTH / SMALL_F, W_HEIGHT / SMALL_F);
+       postRenderPingPong = new fBufferObject*[2];
+       for (int i = 0; i < 2; i++)
+       {
+               postRenderPingPong[i] = new fBufferObject(1, false);
+               postRenderPingPong[i]->bindBuffer(W_WIDTH, W_HEIGHT);
+       }
+       
+       motionVecs = new fBufferObject();
+       motionVecs->bindBuffer(W_WIDTH , W_HEIGHT);
 
        fBufferObject::clearBuffer();
 
        //Graphix::disableEffects(EF_BLOOM);
+       //Graphix::disableEffects(EF_MOTION_BLUR);
 
        for (int s = 0; s < NELEMS(shader); s++)
        {
@@ -146,8 +151,10 @@ Scene::~Scene()
        delete blurPingPong;
 
        delete shadowdir;
-       delete postRender;
-       delete postRenderSmall;
+       for (int i = 0; i < 2; i++)
+               delete postRenderPingPong[i];
+       delete postRenderPingPong;
+       delete motionVecs;
 
 
        //if (viewPort != nullptr)
@@ -270,14 +277,19 @@ void Scene::update(float deltaT)
 
 void Scene::draw() const
 {
+       GLboolean horizontal_blurPP = true, postRenderPP = true;
 
+
+       fBufferObject* lastScreen = nullptr;
+
+       /* Update Camera */
        for (int s = 0; s < NELEMS(shader); s++)
        {
                Shader::getShader(shader[s])->useShader();
                camera.useView();
        }
 
-       /*Draw WireFrame ONLY*/
+       /* Draw WireFrame ONLY */
        if (Events::isKToggleActive(SDLK_F3))
        {
                Shader::getShader(SH_BASICTEXTURE)->useShader();
@@ -288,8 +300,7 @@ void Scene::draw() const
                return;
        }
 
-
-       //Directional Light Shadow
+       /* Prepare Shadows */
        glCullFace(GL_FRONT);
        glEnable(GL_POLYGON_OFFSET_FILL);
        glPolygonOffset(4.f, 0.f);
@@ -307,59 +318,87 @@ void Scene::draw() const
        glDisable(GL_POLYGON_OFFSET_FILL);
        glViewport(0, 0, W_WIDTH, W_HEIGHT);
 
+
        /* Prepare DRAW SCENE */
        camera.useCamera();
-       render->useBuffer();
-       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-       dirLight->updateDirLightView();
-       Shader::getShader(SH_LIGHTING)->useShader();
-       fBufferObject::clearBuffer();
-       shadowdir->getTexture()->useTexture(uPLightXP);
-       
-
-
-       /* DRAW SCENE */
        if (Graphix::testEffect(EF_BLOOM) || Graphix::testEffect(EF_MOTION_BLUR))
        {
                render->useBuffer();
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+               lastScreen = render;
        }
        else
        {
                fBufferObject::clearBuffer();
        }
 
-       /*DRAW SCENE -> SkyBox*/
+       /* DRAW SCENE -> SkyBox */
        Shader::getShader(SH_BASICTEXTURE)->useShader();
        SkyBox.draw();
-       //Shader::getShader(SH_BASICTEXTURE)->useShader();
-       //Shader::getShader(SH_BASICTEXTURE)->setUniformLocation("uFar", false);
-
 
+       /* DRAW SCENE -> Rest */
        Shader::getShader(SH_LIGHTING)->useShader();
+       dirLight->updateDirLightView();
+       shadowdir->getTexture()->useTexture(uPLightXP);
        drawSceneObjects();
 
+       /*DRAW BBOX WIRES*/
+       if (lastScreen != nullptr)
+               lastScreen->useBuffer();
+       else
+               fBufferObject::clearBuffer();
+
+       if (Events::isKToggleActive(SDLK_F6))
+       {
+               Shader::getShader(SH_BASIC)->useShader();
+               drawSceneObjects(DRAW_Coll);
+       }
 
        /* MOTION BLUR */
        if (Graphix::testEffect(EF_MOTION_BLUR))
        {
-               postRender->useBuffer();
+
+               /* calculate Motion */
+               motionVecs->useBuffer();
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
                Shader::getShader(SH_FILTER_MOTION)->useShader();
                camera.useOldProjView();
-               Shader::getShader(SH_ACTIVE)->setUniformLocation("uDelta", Graphix::fps.getCappedDelta());
-               drawSceneObjects(DRAW_ModelMotionBlur);
-       }
-       else
-       {
                
+               drawSceneObjects(DRAW_ModelMotionBlur);
+
+               /* Blur Scene */
+               Shader::getShader(SH_BLUR_DIRECTIONAL)->useShader();
+               Shader::getShader(SH_ACTIVE)->setUniformLocation("uDelta", Graphix::fps.getCappedDelta());
+               motionVecs->getTexture()->useTexture(uBLURVEC);
+
+               bool firstit = true;
+               for (int i = 0; i < 1; i++)
+               {
+
+                       postRenderPingPong[!postRenderPP]->useBuffer();
+                       glClear(GL_COLOR_BUFFER_BIT);
+                       if (firstit)
+                       {
+                               lastScreen->getTexture()->useTexture(uCOLOR);
+                               firstit = false;
+                       }
+                       else
+                               postRenderPingPong[postRenderPP]->getTexture()->useTexture(uCOLOR);
+                       Model::getPlaneModel()->drawModel(mat4(1.f));
+                       postRenderPP = !postRenderPP;
+               }
+
+
+               lastScreen = postRenderPingPong[postRenderPP];
        }
 
+
        //Pointlights & their shadows
        //for (auto i = pointlights.begin(); i != pointlights.end(); ++i)
        //{
-       //      postRender->useBuffer();
+       //      postRenderPingPong->useBuffer();
        //      glClear(GL_COLOR_BUFFER_BIT);
        //      Shader::getShader(SH_POINTLIGHT)->useShader();
        //      render->getTexture()->useTexture();
@@ -372,7 +411,7 @@ void Scene::draw() const
 
        //              drawSceneObjects(DRAW_Model, false);
 
-       //              postRender->useBuffer();
+       //              postRenderPingPong->useBuffer();
        //              Shader::getShader(SH_POINTLIGHT)->useShader();
        //              //shadowdir->getTexture()->useTexture(uPLightXP + j);
        //              switch (j)
@@ -392,84 +431,72 @@ void Scene::draw() const
 
        //      drawSceneObjects();
        //      render->useBuffer();
-       //      //TODO copy the texture from postrender to render
+       //      //TODO copy the texture from postRenderPingPong to render
        //      //render->getTexture()->
        //}
 
-
-       GLboolean horizontal = true, firstit = true;
        if (Graphix::testEffect(EF_BLOOM))
        {
                /* DRAW BRIGHTNESS */
                glViewport(0, 0, W_WIDTH / SMALL_F, W_HEIGHT / SMALL_F);
-               postRenderSmall->useBuffer();
+               blurPingPong[!horizontal_blurPP]->useBuffer();
                glClear(GL_COLOR_BUFFER_BIT);
                //glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
 
-               render->getTexture()->downscale(1);
+               lastScreen->getTexture()->downscale(1);
                
                Shader::getShader(SH_FILTER_BRIGHT)->useShader();
                Shader::getShader(SH_ACTIVE)->setUniformLocation("uFilterThreshold",1.2f);
-               render->getTexture()->useTexture();
+               lastScreen->getTexture()->useTexture();
                Model::getPlaneModel()->drawModel(mat4(1.f));
+               horizontal_blurPP = !horizontal_blurPP;
                
                /* BLUR BRIGHTNESS */
                Shader::getShader(SH_BLUR)->useShader();
 
                for (int i = 0; i < 4; i++)
                {
-                       blurPingPong[horizontal]->useBuffer();
+                       blurPingPong[!horizontal_blurPP]->useBuffer();
                        glClear(GL_COLOR_BUFFER_BIT);
-                       Shader::getShader(SH_ACTIVE)->setUniformLocation("uHorizontal", horizontal);
-                       if (firstit)
-                       {
-                               postRenderSmall->getTexture()->useTexture();
-                               firstit = false;
-                       }
-                       else
-                               blurPingPong[!horizontal]->getTexture()->useTexture();
+
+                       Shader::getShader(SH_ACTIVE)->setUniformLocation("uHorizontal", horizontal_blurPP);
+                       blurPingPong[horizontal_blurPP]->getTexture()->useTexture();
 
                        Model::getPlaneModel()->drawModel(mat4(1.f));
 
-                       horizontal = !horizontal;
+                       horizontal_blurPP = !horizontal_blurPP;
                }
                glViewport(0, 0, W_WIDTH, W_HEIGHT);
        }
 
-
-       /*DRAW BBOX WIRES*/
-       if (Graphix::testEffect(EF_BLOOM))
-               render->useBuffer();
-       if (Events::isKToggleActive(SDLK_F6))
-       {
-               Shader::getShader(SH_BASIC)->useShader();
-               drawSceneObjects(DRAW_Coll);
-       }
-       
-
-       if (Graphix::testEffect(EF_BLOOM))
+       /* FINAL DRAW -> if needed*/
+       if (lastScreen != nullptr)
        {
                fBufferObject::clearBuffer();
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-               /* BLEND BRIGHTNESS TO ORIGINAL*/
-               Shader::getShader(SH_BLEND)->useShader();
-               render->getTexture(0)->useTexture(uCOLOR);
-               blurPingPong[!horizontal]->getTexture()->useTexture(uBLEND);
-
-
-
-               //Shader::getShader(SH_BASICTEXTURE)->useShader();
-               //postRender->getTexture(1)->useTexture(uCOLOR);
-               //SceneObjects.front()->gTexture()->useTexture();
-               //blurPingPong[!horizontal]->getTexture()->useTexture();
-               //postRenderSmall->getTexture()->useTexture();
-
+               if (Graphix::testEffect(EF_BLOOM))
+               {
+                       /* BLEND BRIGHTNESS TO ORIGINAL*/
+                       Shader::getShader(SH_BLEND)->useShader();
+                       blurPingPong[horizontal_blurPP]->getTexture()->useTexture(uBLEND);
+               }
+               else
+               {
+                       Shader::getShader(SH_BASICTEXTURE)->useShader();
+               }
 
+               lastScreen->getTexture()->useTexture(uCOLOR);
                Model::getPlaneModel()->drawModel(mat4(1.f));
        }
 
 
+       //Shader::getShader(SH_BASICTEXTURE)->useShader();
+       //SceneObjects.front()->gTexture()->useTexture();
+       //blurPingPong[horizontal_blurPP]->getTexture()->useTexture();
+       //postRenderPingPong[postRenderPP]->getTexture()->useTexture();
+       //shadowdir->getTexture()->useTexture();
+
 }
 
 void Scene::drawSceneObjects(drawTarget _target, bool _culling) const
@@ -541,10 +568,13 @@ void Scene::setView(unsigned int width, unsigned int height, bool updateProjecti
        }
 
        render->updateSize(width, height);
-       postRender->updateSize(width, height);
-       postRenderSmall->updateSize(width / SMALL_F, height / SMALL_F);
+       motionVecs->updateSize(width, height);
        for (int i = 0; i < 2; i++)
+       {
                blurPingPong[i]->updateSize(width / SMALL_F, height / SMALL_F);
+               postRenderPingPong[i]->updateSize(width, height);
+       }
+
        //shadowdir->updateSize(width, height);
 
 }
index 0f3cc0ab5d5322b67d7b3bcd6d671f0660ec3a5f..4f562079a0ccbc315280bdaa20ae5022f7b7d0ea 100644 (file)
@@ -88,8 +88,8 @@ protected:
        btDiscreteDynamicsWorld* bt_dynamics_world;
 
        fBufferObject* render;
-       fBufferObject* postRender;
-       fBufferObject* postRenderSmall;
+       fBufferObject** postRenderPingPong;
+       fBufferObject* motionVecs;
        fBufferObject** blurPingPong;
        fBufferObject* shadowdir;
 
diff --git a/shader/blurDirectional2_FS.hlsl b/shader/blurDirectional2_FS.hlsl
new file mode 100644 (file)
index 0000000..1fdb8d0
--- /dev/null
@@ -0,0 +1,47 @@
+//Fragment Shader
+#version 330 core
+in vec2 fUVs;
+
+layout(location = 0) out vec4 FragColor;
+
+uniform sampler2D uColorTexture;
+uniform sampler2D uBlurVec;
+
+uniform float uDeltaT = 1.f;
+uniform int uSamples = 5;
+uniform bool uSymetric = true;
+
+void main()
+{
+       
+       vec4 preBlurVec = texture(uBlurVec, fUVs);
+
+       if (preBlurVec.z <= 0.1f)
+       {
+               FragColor = texture(uColorTexture, fUVs);
+               return;
+       }
+
+       vec3 result = texture(uColorTexture, fUVs).rgb;
+       vec2 blurVec = preBlurVec.xy * uDeltaT * preBlurVec.z * preBlurVec.z / 10;
+
+
+       if (uSymetric)
+       {
+               for (int i = 1; i <= uSamples; ++i)
+               {
+                       result += texture(uColorTexture, fUVs + blurVec * (float(i) / uSamples)).rgb + texture(uColorTexture, fUVs - blurVec * (float(i) / uSamples)).rgb;
+               }
+               FragColor = vec4(result / (2 * uSamples + 1), 1.0);
+       }
+       else
+       {
+               for (int i = 1; i <= uSamples; ++i)
+               {
+                       result += texture(uColorTexture, fUVs + blurVec * (float(i) / uSamples)).rgb;
+               }
+               FragColor = vec4(result / (uSamples + 1), 1.0);
+       }
+
+       //FragColor = vec4(vec3(preBlurVec.z), 1.f);
+}
\ No newline at end of file
diff --git a/shader/blurDirectional_FS.hlsl b/shader/blurDirectional_FS.hlsl
new file mode 100644 (file)
index 0000000..ddc9454
--- /dev/null
@@ -0,0 +1,40 @@
+//Fragment Shader
+#version 330 core
+in vec2 fUVs;
+
+layout(location = 0) out vec4 FragColor;
+
+uniform sampler2D uColorTexture;
+uniform sampler2D uBlurVec;
+
+uniform float uDeltaT = 1.f;
+uniform bool uSymetric = true;
+
+uniform float weight[5] = float[](0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162);
+//uniform float weight[5] = float[](0.2222222222, 0.1111111111, 0.1111111111, 0.1111111111, 0.1111111111);
+
+
+void main()
+{
+       vec4 preBlurVec = texture(uBlurVec, fUVs);
+
+       if (preBlurVec.z == 0)
+       {
+               FragColor = texture(uColorTexture, fUVs);
+               return;
+       }
+
+       vec3 result = texture(uColorTexture, fUVs).rgb * weight[0];
+       vec2 blurVec = preBlurVec.xy * uDeltaT * preBlurVec.z * preBlurVec.z / 10;
+
+       for (int i = 1; i <= 4; ++i)
+       {
+               result += texture(uColorTexture, fUVs + blurVec * (i / 4)).rgb *weight[i];
+               if (uSymetric)
+                       result += texture(uColorTexture, fUVs - blurVec * (i / 4)).rgb *weight[i];
+       }
+
+       FragColor = vec4(result, 1.0);
+
+       //FragColor = vec4(vec3(preBlurVec.z), 1.f);
+}
\ No newline at end of file
index df8ce2a2a255daa0ad6c2cfe212c9030c1090987..6103fe0aa2b0bde3bf93e4e05f9493a5ddce8074 100644 (file)
@@ -6,7 +6,6 @@ layout(location = 0) out vec4 FragColor;
 
 uniform sampler2D uColorTexture;
 uniform bool uHorizontal = true;
-//uniform bool uSymetric = true;
 
 uniform float weight[5] = float[](0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162);
 
@@ -20,8 +19,7 @@ void main()
                for (int i = 1; i < 5; ++i)
                {
                        result += texture(uColorTexture, fUVs + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
-                       //if(uSymetric)
-                               result += texture(uColorTexture, fUVs - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
+                       result += texture(uColorTexture, fUVs - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
                }
        }
        else
@@ -29,8 +27,7 @@ void main()
                for (int i = 1; i < 5; ++i)
                {
                        result += texture(uColorTexture, fUVs + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
-                       //if(uSymetric)
-                               result += texture(uColorTexture, fUVs - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
+                       result += texture(uColorTexture, fUVs - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
                }
        }
        FragColor = vec4(result, 1.0);
index ad7712f02476bfb050427c216782c837c85fd849..babcde0217279aef856490f4ff2d1f6ece5be295 100644 (file)
@@ -4,12 +4,14 @@
 in vec4 pixPosition;
 in mat4 new2old;
 
-layout(location = 0) out vec3 MotionVec;
+layout(location = 0) out vec4 MotionVec;
  
 void main()
 {
        vec3 currentPos = pixPosition.xyz / pixPosition.w;
        vec4 oldPos = new2old * vec4(currentPos, 1);
-       MotionVec = oldPos.xyz / oldPos.w - currentPos.xyz;
+       vec3 lastPos = oldPos.xyz / oldPos.w;
+
+       MotionVec = vec4(lastPos.xy - currentPos.xy, (lastPos.z+currentPos.z)/2,1.f);
 
 }