Results 1 to 4 of 4

Thread: Whats wrong with my state->derivs[]?

  1. #1

    Default Whats wrong with my state->derivs[]?

    Hi,

    for the creation of a curvature shader, I need the derivs from the surface. But I have no luck at all. This simple code here:

    Code:
    #include <shader.h>
    
    typedef struct
    {
    } printderiv_params;
    
    extern "C" DLLEXPORT int printderiv_version() {	return (1);}
    
    extern "C" DLLEXPORT miBoolean printderiv
    (
    	miColor               *result,
    	miState               *state,
    	printderiv_params     *params
    )
    {
    	mi_info("Deriv vector 0: %f %f %f", state->derivs[0].x, state->derivs[0].y, state->derivs[0].z);    
    	mi_info("Deriv vector 1: %f %f %f", state->derivs[1].x, state->derivs[1].y, state->derivs[1].z);    
    	mi_info("Deriv vector 2: %f %f %f", state->derivs[2].x, state->derivs[2].y, state->derivs[2].z);  
    	result->r = mi_vector_norm(&(state->derivs[0]));
    	result->g = mi_vector_norm(&(state->derivs[1]));
    	result->b = mi_vector_norm(&(state->derivs[2]));
    	return miTRUE;
    }
    Gives me always 0.000. I'm using maya2012 for rendering and used a simple nurbs sphere (with some deformations) for testing. Any ideas whats wrong with my code?

  2. #2

    Default

    Just tried to use a polymesh with a subdiv approximation. And it works if I turn on "export polygon derivatives". Nurbs surfaces result always in 0.0 if the "export nurbs derivatives" is turned on or not.

  3. #3
    Join Date
    Jan 2009
    Location
    Berlin/Germany
    Posts
    668

    Lightbulb NURBS surface derivatives

    haggi,

    for NURBS geometry, mentalray computes true surface derivatives only on demand. You can force this using a dynamic attribute on the NURBS shape node, search Maya docs for "mental ray derivatives" (copy below). Not sure if this workflow is intended in your case, though.

    Hope this helps, Steve.

    mental ray Derivatives

    Create this attribute on the shape node as follows:
    Code:
    addAttr -ln "miDerivatives" -at "enum" -en "none:first:second:both" -dv 0 nurbsSphereShape1;
    Values within the range of 0 to 3 are supported for -miDerivatives.

    0 = no derivatives
    1 = first order derivatives
    2 = second order derivatives
    3 = first and second order derivatives

  4. #4

    Default

    Ahhh... thanks a lot. I thought it would be enough to turn it on in the render globals.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •