Motion Vector pass for Spherical render
6062 10 1- mrWolf
- Member
- 22 posts
- Joined: June 2006
- Offline
In the past I've generally used a simple shader like the one in the pic attached, when it comes to render motion vectors, and it works pretty well with a regular camera.
I tried to use the same shader to generate a motion vector pass for a lat-long (spherical shader) render for a VR project, but it doesn't seem to work as expected. The vectors are there but the Vector Blur in Nuke doesn't produce the correct result. Not only the direction of blur is incorrect, but it doesn't seem to take into account the distance from the camera (far objects move slower than closer object, in camera space).
Is there anything anybody can think of that could help me on this ?
I tried to use the same shader to generate a motion vector pass for a lat-long (spherical shader) render for a VR project, but it doesn't seem to work as expected. The vectors are there but the Vector Blur in Nuke doesn't produce the correct result. Not only the direction of blur is incorrect, but it doesn't seem to take into account the distance from the camera (far objects move slower than closer object, in camera space).
Is there anything anybody can think of that could help me on this ?
Edited by mrWolf - Aug. 8, 2016 23:25:09
Alessandro Pepe
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
- mrWolf
- Member
- 22 posts
- Joined: June 2006
- Offline
I did some more investigation and renders.
A simple hip file illustrating the issue I'm having is attached below.
The issue seems to be happening looking right and left in the lat-long render, which corresponds to the areas with sudden changes of color in the motion_vectors render below (and the consequent streaky artifacts in the vectorBlur generated by Nuke).
It feels like the vectors should be treated with some spherical mapping math. Did anybody run into this before ?
A simple hip file illustrating the issue I'm having is attached below.
The issue seems to be happening looking right and left in the lat-long render, which corresponds to the areas with sudden changes of color in the motion_vectors render below (and the consequent streaky artifacts in the vectorBlur generated by Nuke).
It feels like the vectors should be treated with some spherical mapping math. Did anybody run into this before ?
Alessandro Pepe
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
- blackpixel
- Member
- 182 posts
- Joined: April 2009
- Offline
- jpparkeramnh
- Member
- 178 posts
- Joined: Jan. 2013
- Offline
- mrWolf
- Member
- 22 posts
- Joined: June 2006
- Offline
jpparkeramnh
Hi Alessandro!
Did you ever figure this one out?
-Jon
hey Jon,
no , after a couple of days I gave up.
I wonder if the issue is still there in H16.
Did you find a solution by any chance ?
Alessandro Pepe
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
- jsmack
- Member
- 7814 posts
- Joined: Sept. 2011
- Online
Try transforming your blur space into polar coordinates before computing the delta. The logic is the same as for standard motion vectors, transform shading space to screen space before computing the difference.
#include <math.h>
vector latlong( const vector pos ) {
vector tmp_p = set(pos.x,pos.z,-pos.y);
float r = length(tmp_p);
float phi = atan2(tmp_p.y,tmp_p.x);
float theta = acos(tmp_p.z/r);
return set(phi/M_TWO_PI,theta/M_PI,r);
}
surface
myshader( export vector motion = {0,0,0} )
{
vector p1 = getblurP(0);
vector p2 = getblurP(1);
vector res;
int found = renderstate("image:resolution",res);
if (!found) res = {1,1,1};
res.z = 1.0;
p1 = latlong(p1);
p2 = latlong(p2);
motion = p2 - p1;
motion *= res;
}
- jpparkeramnh
- Member
- 178 posts
- Joined: Jan. 2013
- Offline
- mrWolf
- Member
- 22 posts
- Joined: June 2006
- Offline
jsmack
Try transforming your blur space into polar coordinates before computing the delta. The logic is the same as for standard motion vectors, transform shading space to screen space before computing the difference.#include <math.h>
vector latlong( const vector pos ) {
vector tmp_p = set(pos.x,pos.z,-pos.y);
float r = length(tmp_p);
float phi = atan2(tmp_p.y,tmp_p.x);
float theta = acos(tmp_p.z/r);
return set(phi/M_TWO_PI,theta/M_PI,r);
}
surface
myshader( export vector motion = {0,0,0} )
{
vector p1 = getblurP(0);
vector p2 = getblurP(1);
vector res;
int found = renderstate("image:resolution",res);
if (!found) res = {1,1,1};
res.z = 1.0;
p1 = latlong(p1);
p2 = latlong(p2);
motion = p2 - p1;
motion *= res;
}
Jsmack !
This is exactly the kind of ‘spherical mapping math’ I was imagining, but couldn't really implement it at that time.
I'll try this as soon as I've a hour or so. Thank you !
Alessandro Pepe
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
- jpparkeramnh
- Member
- 178 posts
- Joined: Jan. 2013
- Offline
- jsmack
- Member
- 7814 posts
- Joined: Sept. 2011
- Online
- jpparkeramnh
- Member
- 178 posts
- Joined: Jan. 2013
- Offline
-
- Quick Links