Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Maya Fluid render problem

  1. #1

    Default Maya Fluid render problem

    Hi,

    I'm trying to solve the well known problem with large fluids in maya where the large boxes will get more alpha the bigger they are.

    The only solution seems to be to group the whole scene and scale it down. Well even if this works sometimes, it is no solution for all situations.

    So I thought: If downscaling helps, so why not scale all instances in mentalray with a geometry shader instead in the maya scene. This would need a way to get all instances in the scene database and manipulate them.

    Any idea if this is possible and how to get all instances?

  2. #2

    Default

    Okay, I simply listed all instances from my maya scene. The instances are found, but a transformation seems not to have any effect. Seems that at this time a modification of an existing instance is too late to be considered in rendering.

  3. #3

    Default

    haggi, with a traversal shader put into the options you have access to all the instances before processing.
    more info on the traversal shader can be found in the mental ray documentation.

    gunter

    Quote Originally Posted by haggi View Post
    Okay, I simply listed all instances from my maya scene. The instances are found, but a transformation seems not to have any effect. Seems that at this time a modification of an existing instance is too late to be considered in rendering.

  4. #4

    Default

    Thanks a lot, I'll try it.

  5. #5

    Default

    Gunter, can you explain the procedure a little bit more in detail?

    First I write my c/c++ function based on the prototype.
    Next I create a function declaration of this c function with mi_api_funcdecl_begin/mi_api_funcdecl_end. The mi_api_funcdecl_end gives me the tag which has to be installed into the options block. Is that correct?

    The funcdecl needs to be constructed following the examples in the manual like this one: http://docs.autodesk.com/MENTALRAY/2...ion/node9.html

    And if this is correct, how do I define a function declaration for the pointer parameters like the ones below, I only could find parameter types like miTYPE_INTEGER, boolean etc.:
    (void *data, struct miInstance *parent, struct miInstance *inst, miTag *path, int pathlen)
    Last edited by haggi; May 10th, 2013 at 11:10.

  6. #6

    Default

    I could see that there is an tag defined for the options->inh_funcdecl. Wouldn't my assignment destroy any previous assigned function? Or is this a list where I can attach my own function like it can be done for the options->userData list?

  7. #7

    Default

    haggi, the traversal function cannot be chained.

    sorry, i looked for examples, but haven't found one. did you have success in the meantime, is your function
    called ?

    gunter

    Quote Originally Posted by haggi View Post
    I could see that there is an tag defined for the options->inh_funcdecl. Wouldn't my assignment destroy any previous assigned function? Or is this a list where I can attach my own function like it can be done for the options->userData list?

  8. #8

    Default

    Unfortunatly not. There are too many unknowns here. The first is that I'm not sure how the function is called correctly.
    This is my function:
    Code:
    extern "C" DLLEXPORT miBoolean miTraversal_func(
        void              *data,
        struct miInstance *parent,
        struct miInstance *inst, 
        miTag             *path,
        int               pathlen)
    {
    	
    	mi_info("Data should be 0: %d", data);
    	mi_info("Parent 0==top: %d", parent);
    	mi_info("Pathlen: %d", pathlen);
    	return miTRUE;
    }
    Then I try to define the function and place int in options with:
    Code:
    		miParameter *parm, *plist = NULL;
    		char *fnc_symbol = mi_mem_strdup("miTraversal_func");
    
    		//char *symbol = mi_mem_strdup("data");
    		//parm = mi_api_parameter_decl(miTYPE_STRUCT, symbol, 0);
    		//plist = parm;
    
    		//symbol = mi_mem_strdup("parent");
    		//parm = mi_api_parameter_decl(miTYPE_STRUCT, symbol, 0);
    		//plist  = mi_api_parameter_append(plist, parm);
    
    		//symbol = mi_mem_strdup("inst");
    		//parm = mi_api_parameter_decl(miTYPE_STRUCT, symbol, 0);
    		//plist  = mi_api_parameter_append(plist, parm);
    
    		//symbol = mi_mem_strdup("path");
    		//parm = mi_api_parameter_decl(miTYPE_STRUCT, symbol, 0);
    		//plist  = mi_api_parameter_append(plist, parm);
    
    		//symbol = mi_mem_strdup("pathlen");
    		//parm = mi_api_parameter_decl(miTYPE_INTEGER, symbol, 0);
    		//plist  = mi_api_parameter_append(plist, parm);
    
    		// declare return parameter
    		parm = mi_api_parameter_decl(miTYPE_BOOLEAN, 0, 0);
    
    		miFunction_decl *decl;
    		decl = mi_api_funcdecl_begin(parm, fnc_symbol, plist);
    		if( decl )
    		{
    			decl->version = 1;
    			miTag funcTag = mi_api_funcdecl_end();
    
    			miOptions *options = (miOptions *)state->options;
    			options->inh_funcdecl = funcTag;
    		}
    The parameters are excluded because I'm quite sure that the definition is not correct (and the shader crashes during parameter declaration anyway if I include them). This way it is compiled and I do not get an error, but it is not executed. Any help would be extremly appreciated.

  9. #9

    Default

    Haggi, it is similar to a regular shader. For a first test you could declare a shader without any parameters.
    The shader parameters are passed in "data" to the callback. parent, inst, path etc. do not need to be declared.

    gunter

    Quote Originally Posted by haggi View Post
    Unfortunatly not. There are too many unknowns here. The first is that I'm not sure how the function is called correctly.
    This is my function:
    Code:
    extern "C" DLLEXPORT miBoolean miTraversal_func(
        void              *data,
        struct miInstance *parent,
        struct miInstance *inst, 
        miTag             *path,
        int               pathlen)
    {
    	
    	mi_info("Data should be 0: %d", data);
    	mi_info("Parent 0==top: %d", parent);
    	mi_info("Pathlen: %d", pathlen);
    	return miTRUE;
    }
    Then I try to define the function and place int in options with:
    Code:
    		miParameter *parm, *plist = NULL;
    		char *fnc_symbol = mi_mem_strdup("miTraversal_func");
    
    		//char *symbol = mi_mem_strdup("data");
    		//parm = mi_api_parameter_decl(miTYPE_STRUCT, symbol, 0);
    		//plist = parm;
    
    		//symbol = mi_mem_strdup("parent");
    		//parm = mi_api_parameter_decl(miTYPE_STRUCT, symbol, 0);
    		//plist  = mi_api_parameter_append(plist, parm);
    
    		//symbol = mi_mem_strdup("inst");
    		//parm = mi_api_parameter_decl(miTYPE_STRUCT, symbol, 0);
    		//plist  = mi_api_parameter_append(plist, parm);
    
    		//symbol = mi_mem_strdup("path");
    		//parm = mi_api_parameter_decl(miTYPE_STRUCT, symbol, 0);
    		//plist  = mi_api_parameter_append(plist, parm);
    
    		//symbol = mi_mem_strdup("pathlen");
    		//parm = mi_api_parameter_decl(miTYPE_INTEGER, symbol, 0);
    		//plist  = mi_api_parameter_append(plist, parm);
    
    		// declare return parameter
    		parm = mi_api_parameter_decl(miTYPE_BOOLEAN, 0, 0);
    
    		miFunction_decl *decl;
    		decl = mi_api_funcdecl_begin(parm, fnc_symbol, plist);
    		if( decl )
    		{
    			decl->version = 1;
    			miTag funcTag = mi_api_funcdecl_end();
    
    			miOptions *options = (miOptions *)state->options;
    			options->inh_funcdecl = funcTag;
    		}
    The parameters are excluded because I'm quite sure that the definition is not correct (and the shader crashes during parameter declaration anyway if I include them). This way it is compiled and I do not get an error, but it is not executed. Any help would be extremly appreciated.

  10. #10

    Default

    Okay, now I defined a dummy shader like this:

    Code:
    declare shader
    	geometry "traversal_func" ()
    	version 1
    	apply geometry
    end declare
    Shader definition:
    Code:
    extern "C" DLLEXPORT int traversal_func_version()
    {
    	return(1);
    }
    
    extern "C" DLLEXPORT miBoolean traversal_func(
    	miTag             *result,
    	miState           *state,
    	void  *data)
    {
    	mi_info("This is the traversal func.");
    	return miTRUE;
    }
    And function declaration here:
    Code:
    		miParameter *parm, *plist = NULL;
    		char *fnc_symbol = mi_mem_strdup("traversal_func");
    		parm = mi_api_parameter_decl(miTYPE_BOOLEAN, 0, 0);
    
    		miFunction_decl *decl;
    		decl = mi_api_funcdecl_begin(parm, fnc_symbol, plist);
    		if( decl )
    		{
    			decl->version = 1;
    			miTag funcTag = mi_api_funcdecl_end();
    
    			miOptions *options = (miOptions *)state->options;
    			options->inh_funcdecl = funcTag;
    		}
    Now the mi_api_funcdecl_begin() always returns NULL. Seems that i defined my shader the wrong way.

Posting Permissions

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