Jump to content

Recommended Posts

Hey,

 

I have time seeking any motion vector pass somewhere in odforce, nothing work as fine for now, so any know the method of get motion vector pass from mantra pbr using all scene animation as alembic, camera moving, etc with houdini 14 ? 

 

thanks in advance

Carlos

 

 

Share this post


Link to post
Share on other sites

It could be that you are not pulling in actual geometry. Dive into the alembic node, all the way to the end; in the 'Geometry' tab: "Load As", and select "Load Houdini Geometry"

Share this post


Link to post
Share on other sites

Hey,

 

I have time seeking any motion vector pass somewhere in odforce, nothing work as fine for now, so any know the method of get motion vector pass from mantra pbr using all scene animation as alembic, camera moving, etc with houdini 14 ? 

 

thanks in advance

Carlos

 

you mean the usual GetBlurP VOP for current and next frame added to the shader ain´t working for you?

Share this post


Link to post
Share on other sites

Yeah, dont works very well as maya, i have tested all hips of forums, nothing for now. the correct motion vector would be correct colors using in nuke just adding vector blur and looking same as the render with motion blur3D actived. there is link with images and alembic if you want test it and correct.

 

https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=40705

 

 

thanks for the words

cheers

Carlos

Share this post


Link to post
Share on other sites

dont't know if it can help but this is the source of pavel ledin motion vector shader for mental ray ...

it could be interesting to see if a direct conversion in VEX is working ?

//  Copyright (c) 2005, Pavel Ledin
//
//  All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//  *       Redistributions of source code must retain the above copyright
//  notice, this list of conditions and the following disclaimer.
//  *       Redistributions in binary form must reproduce the above
//  copyright notice, this list of conditions and the following disclaimer
//  in the documentation and/or other materials provided with the
//  distribution.
//  *       Neither the name of Pavel Ledin nor the names of
//  its other contributors may be used to endorse or promote products derived
//  from this software without specific prior written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
//  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
//  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
//  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
//  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
//  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
//  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
//  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
//  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <math.h>
#include "shader.h"
//#include "p_utils.h"

#ifdef DEBUG
#define miASSERT assert
#else
#define miASSERT(x)
#endif

typedef struct
{
	int mode;
	int normalize;
}p_motion_to_rgb_t;

struct static_param
{
	int mode;
	int normalize;
	int max;
};

extern "C"
{
DLLEXPORT int p_motion_to_rgb_version(void) {return(4);}

DLLEXPORT miBoolean p_motion_to_rgb_init(miState *state, p_motion_to_rgb_t *paras, miBoolean *inst_req)
{
	struct static_param *sp, **spp;
	if (!paras)
	{
		*inst_req = miTRUE;
		return(miTRUE);
	}

	sp = (struct static_param *)
	mi_mem_allocate(sizeof(struct static_param));

	mi_query(miQ_FUNC_USERPTR, state, 0, &spp);
	*spp = sp;

	sp->max = 0;
	sp->mode = *mi_eval_integer(&paras->mode);
	sp->normalize = *mi_eval_integer(&paras->normalize);
	return miTRUE;
}

DLLEXPORT miBoolean p_motion_to_rgb(miColor *result, miState *state, p_motion_to_rgb_t *paras)
{
	    if(state->type == miRAY_SHADOW || state->type == miRAY_DISPLACE)
			return(miFALSE);

		miVector motion;

		float angle;
		miVector start, end;
		miVector delta;

		struct static_param *sp, **spp;
		miASSERT(state->shader);
		mi_query(miQ_FUNC_USERPTR, state, 0, &spp);
		sp = *spp;

		miVector  p_iPnt, p_wPnt, p_rPnt;
		miVector  v_wMV;
		miScalar  v_rMVx, v_rMVy, v_rMVNorm, v_dMVNorm;

		miScalar v_iMVNorm = mi_vector_norm(&state->motion);
		mi_vector_to_camera(state, &motion, &state->motion);


	// -----------------------------------------------------------------------
	//	ANY MOTION ?
	// -----------------------------------------------------------------------
	if( v_iMVNorm > miSCALAR_EPSILON ) 
	{

		// ---[ To World ]----------------------------------------------------
		mi_point_to_world (state, &p_wPnt, &state->point);
		mi_vector_to_world(state, &v_wMV,  &state->motion);

		// ---[ Motion Point ]------------------------------------------------
		p_wPnt.x += v_wMV.x;
		p_wPnt.y += v_wMV.y;
		p_wPnt.z += v_wMV.z;

		// ---[ To Internal ]-------------------------------------------------
		mi_point_from_world(state, &p_iPnt, &p_wPnt);

		// ---[ To Raster ]---------------------------------------------------
		mi_point_to_raster (state, &p_rPnt, &p_iPnt);

		// ---[ 2D Motion Vector ]--------------------------------------------
		v_rMVx = p_rPnt.x - state->raster_x;
		v_rMVy = p_rPnt.y - state->raster_y;

		// ---[ 2D Motion Vector Norm ]---------------------------------------
		v_rMVNorm = (miScalar)sqrt(v_rMVx*v_rMVx + v_rMVy*v_rMVy);

		if(v_rMVNorm <= miSCALAR_EPSILON && (sp->mode == 3 || sp->mode == 4)) 
		{
			result->r = 0.5;
			result->g = 0.5;
			result->b = 0.0;
			result->a = 1.0;
			return(miTRUE);
		}

		// ---[ Record Max Values ]-------------------------------------------
//		pTD->iMax = max( pTD->iMax, (miInteger)v_rMVNorm );
		if(sp->max < (miInteger)v_rMVNorm)
			sp->max = (miInteger)v_rMVNorm;


		switch(sp->mode)
		{
			case 0:				//camera space
				result->r = motion.x;	
				result->g = motion.y;	
				result->b = motion.z;	
				break;		
			case 1:				//raster space
				mi_vector_add(&start, &state->point, &state->motion);
				mi_point_to_raster(state, &end, &start);
				mi_point_to_raster(state, &start, &state->point);
				mi_vector_sub(δ, &end, &start);
				result->r = delta.x;	
				result->g = delta.y;	
				result->b = 0.f;	
				break;
			case 2:				//for krokodove DF 4
				mi_vector_add(&start, &state->point, &state->motion);
				mi_point_to_raster(state, &end, &start);
				mi_point_to_raster(state, &start, &state->point);
				mi_vector_sub(δ, &end, &start);
				motion.x = delta.x;
				motion.y = delta.y;

				motion.x += motion.x > 0.0f ? 0.001f : -0.001f;
		//		motion.z = 0.0f;
				result->g = sqrtf(motion.x * motion.x + motion.y * motion.y);

				angle = atanf(fabsf(motion.y)/fabsf(motion.x))*(float)(180.0f/M_PI);

				if(motion.x < 0.0f && motion.y >= 0.0f)
					angle = 180.0f - angle;
				if(motion.x <= 0.0f && motion.y < 0.0f)
					angle = 180.0f + angle;
				if(motion.x > 0.0f && motion.y <= 0.0f)
					angle = 360.0f - angle;

				result->r = angle/360.0f;
//				result->b = motion.z;
				result->b = 0.f;
				break;
			case 3:				//for SmoothKit
				// ---[ Normalize ]-------------------------------------------
				v_rMVx /= v_rMVNorm;
				v_rMVy /= v_rMVNorm;

				// ---[ Raster Normalize ]------------------------------------
				v_rMVNorm /= (miScalar)(sp->normalize);

				// ---[ Output ]----------------------------------------------
				result->r = (miScalar)(( -v_rMVx + 1.0f )*0.5f);
				result->g = (miScalar)(( -v_rMVy + 1.0f )*0.5f); 
				result->b = v_rMVNorm;
//				result->a = 1.0f;
				break;
			case 4:				//for ReelSmart
				// ---[ Raster Normalize ]------------------------------------
				v_rMVNorm /= (miScalar)(sp->normalize);
				v_dMVNorm  = (miScalar)(sp->normalize);

				// ---[ Output ]----------------------------------------------
				result->r = (miScalar)((-v_rMVx/v_dMVNorm) + 1.0f )*0.5f;
				result->g = (miScalar)((-v_rMVy/v_dMVNorm) + 1.0f )*0.5f; 
				result->b = 0.0f;
	//			result->a = 1.0f;
				break;
			default:			//camera space
				result->r = motion.x;	
				result->g = motion.y;	
				result->b = motion.z;	
				break;			
		}		
	}
	else 
	{
		if(sp->mode <= 2)
		{
			result->r = 0.0f;
			result->g = 0.0f;
			result->b = 0.0f;
		}
		else if (sp->mode <=4)
		{
			result->r = 0.5f;
			result->g = 0.5f;
			result->b = 0.0f;
		}
	}
	result->a = 1.0f;
	return(miTRUE);
}

//	Shader cleanup function
DLLEXPORT miBoolean p_motion_to_rgb_exit(miState *state, p_motion_to_rgb_t *paras)
{
	struct static_param *sp, **spp;

	if (!paras)
	{
	}
	else {
		mi_query(miQ_FUNC_USERPTR, state, 0, &spp);
		sp = *spp;
		mi_info("p_motion_to_rgb: Max Displace -> %i pixels", sp->max);


		mi_mem_release(*spp);
		sp = NULL;
		*spp = NULL;
	}
	return(miTRUE);
}
}

Cheers

 

E

Edited by sebkaine
  • Like 2

Share this post


Link to post
Share on other sites

Attached a project with hip file containing a motion blur aov, your alembic (in abc) and a nuke script (in comp) with a working vector blur setup.

 

(credit to the guys at work for figuring this out)

moblur.zip

Edited by mestela
  • Like 5

Share this post


Link to post
Share on other sites

Attached a project with hip file containing a motion blur aov, your alembic (in abc) and a nuke script (in comp) with a working vector blur setup.

 

(credit to the guys at work for figuring this out)

Havent tested in houdini yet but looking the exr, looks perfect! amazing from you and the guys! congrats! 

 

thank you for that!

cheers

Carlos

Share this post


Link to post
Share on other sites

Hi,

 

I don't know if you guys are still following this thread or not, but I was wondering how that hip file works?  I am pretty new to Houdini and trying to get a motion blur pass out of it, but setting it up like yours does not seem to work.  Does it only for alembic files?  Does this work for particles? OR Is there a way to get a motion pass from a particles render?

 

Thanks,

Dustin

Share this post


Link to post
Share on other sites

Hi everyone,

I am still trying to figure out how to do a motion vector pass in Houdini Mantra and I am having a hard time making it work in nuke.

For starters, 

I don't understand why is used screen space in the setup instead of camera space.

I include herean example.

test_MV.hip

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×