Results 1 to 3 of 3

Thread: user data problems

  1. #1

    Default user data problems

    Hi,

    I have a geometry shader and I want to pass some data from this geoshader to my volume shader.
    I thought I would be a good idea to use a user data block, but I have some problems using it. Maybe someone can give me a little hint.

    I've tried to attach my user data tag to state->options->userdata with:

    miTag NewUserDatatag = mi_api_data_append(udTag, state->options->userdata);

    And I tried to access this userData with:

    Code:
    	miTag    data = state->options->userdata;
    	int count = 0;
    	while( data != miNULLTAG )
    	{
    		miUint label;         
    		mi_query( miQ_DATA_LABEL, NULL, data, (void *)&label );
    		mi_info("ud label %d numud %d", label, count++);
    		if( label == 999 )
    		{
    			mi_info("Found label 999 in User data");
    		}
            if( !mi_query( miQ_DATA_NEXT, NULL, data, (void *)&data ) )
                break;
    	}
    But data is always a nulltag. So something went wrong.


    Then I tried to use my own scope as max suggested some time ago:
    Code:
    char *scope = mi_api_scope_apply(mi_mem_strdup(""));
    mi_api_scope_end();
    
    mi_api_scope_begin(mi_mem_strdup("foo"));   //install custom scope
    miUserdata *ud = mi_api_data_begin(...);
    ...
    mi_api_data_end();
    mi_api_scope_end();
    
    mi_api_scope_apply(mi_mem_strdup(scope));
    But this gives me an unbalanced scope error.

    So if anyone has an idea how I can access my user data from my volume shader, it would be great to hear how this can work.
    Thanks.

  2. #2
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    2,914

    Default Re: user data problems

    Try a simpler approach. Create the user data at top level in your scene. Then, make a user data input to your volume shader. I can't recall off the top of my head, because I'm at home, but you may need to specify the shader input parameter as geometry type, to accept a general scene entity tag.

    If it is a one time kind of thing, with a fixed name, then you probably wouldn't even need the input. But the input gives your shader the flexibility for reuse.

    I assume that you have some kind of density encoded in user data, that you want to attach to a density shader that attaches to a general volume lighting shader. Similar to the book's voxel_density/parameter_volume approach, but using user data for the input. Is that right?

    http://www.writingshaders.com/shader_pa ... olume.html
    http://www.writingshaders.com/shader_pa ... nsity.html

    You saw that Andy's book got published?
    Barton Gawboy
    Training and Special Projects, NVIDIA ARC
    LAmrUG Forum Originator

  3. #3

    Default Re: user data problems

    Thanks bart, thats a good idea. Meanwhile I found a way to do what I want to do.

    BTW: The state->options->userdatas perpose is to attach own user data nodes, right? So any idea why it is defined as constant so that it cannot be changed (at least not intended to be changed by the developers)?

Posting Permissions

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