Results 1 to 3 of 3

Thread: How to tesselate meshes with displacement shader in geometry shader

  1. #1
    Join Date
    Aug 2011
    Posts
    20

    Default How to tesselate meshes with displacement shader in geometry shader

    Hi,

    I would like to make a geometry fur shader.
    To generate hair primitives exactly on a surface, I use mi_geoshader_tesselate to get tesselated primitives.
    It works fine if a surface is a simple mesh or a mesh with subdiv approx, but if a displacement shader (and displace approx.) is applied to the surface, mi_geoshader_tesselate simply returns instance whose boxes are not properly displaced.

    Does anyone know how to get tesselated primitives of meshes with displacement shader?

    My test shader is as follows.

    Code:
    struct testGeoShader {
        miTag       surface;	///< Tag of surface
    };
    
    miBoolean testGeoShader(miTag *result, miState *state, struct testGeoShader *paras) {
    	miTag surfaceTag = *mi_eval_tag(&paras->surface);
    
    	miTag leaves;
    	mi_geoshader_tesselate(state, &leaves, surfaceTag);
    	miTag scan = leaves;
    	while (scan != miNULLTAG) {
    		miInstance* instance = (miInstance *)mi_db_access(scan);
    		if (instance->boxes != miNULLTAG) {
    			miBox* box = (miBox*)mi_db_access(instance->boxes);
    			for (miUint p = 0; p < box->no_prims; ++p) {
    				// Do something
    			}
    			mi_db_unpin(instance->boxes);
    		}
    
    		miTag next = instance->next;
    		mi_db_unpin(scan);
    		scan = next;
    	}
    	mi_geoshader_tesselate_end(leaves);
    	
    	return miTRUE;
    }

  2. #2

    Default

    This should work, mi_geoshader_tessellate definitely supports displacement. Have you set max displace properly ? You can set in in the global options or in the object. Default is 0, so there is no displacement. In this case mental ray generates a warning message ("displacement shader returned values up to ... clipped to max displace 0".
    If you think max displace is set properly in your code we could provide example files.

    Gunter

  3. #3
    Join Date
    Aug 2011
    Posts
    20

    Default

    Hi gunter,

    Thank you for your reply.
    I checked my scene and found that I was simply misusing "surface" tag.
    When I set an object to "surface" tag, displacement shader didn't work.
    But when I set an instance of an object to the tag, displacement shader successfully worked (simply because only instance knows about displacement shader).
    Last edited by ono; September 2nd, 2011 at 17:53.

Posting Permissions

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