owl-project / NVISII

Apache License 2.0
328 stars 28 forks source link

Feature request: background motion vectors #41

Closed natevm closed 4 years ago

natevm commented 4 years ago

This would be how we might compute those.

               AffineSpace3fa mtxT0 = m_background->getProbeToWorldT0();
                AffineSpace3fa mtxT1Inv = m_background->getTransformT1();
                const float envDist = 10000.0f; // large value
                // Point far away
                Vec3fa pfar = ray.org + ray.dir * envDist;
                // Apply transform
                Vec3fa pT0 = xfmPoint(mtxT1Inv, xfmPoint(mtxT0, pfar));
                Vec3fa pT1 = pfar; 
                // World to camera space
                Vec3fa p0c = xfmPoint(world2local, pT0);
                Vec3fa p1c = xfmPoint(world2local, pT1);
                // Project to screen space
                float aspect = (float)m_width / (float)m_height;
                float x0s = m_fovscale / aspect * p0c.x / p0c.z; 
                float y0s = m_fovscale * p0c.y / p0c.z;          
                float x1s = m_fovscale / aspect * p1c.x / p1c.z; 
                float y1s = m_fovscale * p1c.y / p1c.z;          
                float CoC = m_render_param.apertureSize / m_render_param.focusDepth;
                MV = Vec3ff(0.5f * (x0s - x1s), 0.5f * (y1s - y0s), CoC, 1.0f); // Screen space MV
natevm commented 4 years ago

Should be in alpha 8