简体   繁体   中英

How to get previous position of a mesh

I'm trying to write a shader for doing the motionBlur effect in WebGL using three.js frameworks. I'm trying to adapt this tutorial for WebGL: http://john-chapman-graphics.blogspot.fr/2013/01/per-object-motion-blur.html and getting the velocity value with GPUComputeRenderer.

But i have problem for this line :

Position = uModelViewProjectionMat * gl_Vertex;
vPrevPosition = uPrevModelViewProjectionMat * gl_Vertex;

How can i get or calculate the PrevModelViewProjectionMat ? I know it's projectionMatrice * modelViewMatrix * vec4(position, 1.0) but don't know how to get the previous projMatrix or previous modelViewMatrix. Can someone help?

The previous projection matrix is probably going to be the same unless you modified the camera (near,far,fov).

The previous modelView matrix you need to calculate or save from the previous frame. Then provide it to the shader as a uniform, and do the transformation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM