Displacement Mapping in RenderMan


#1

Hi,

I’m new here, though I’ve been haunting the place for a few weeks. Seems like a great community! Anyway, on to why I started this topic…

At the moment I’m in the process of learning RenderMan, but I’m having a problem with my displacement mapping. For some reason after displacement my normals are coming out all wrong, even though before displacement they are OK. An image of this is here. The left side hasn’t been painted properly, but the right side has.

Here’s my displacement shader:

displacement hansDisp (string texName = "";float dispMult = 0.1)
  {
  	float magnitude;
  	magnitude = dispMult * ( float texture( texName ) * 2 - 1 );
  	P += magnitude * normalize (N);
  	N = calculatenormal (P);
  }

Does anyone know why this might be happening?

Thanks very much :slight_smile:


#2

the reason right off the bat is because you are not using subdivison surfaces. If you are using MTOR theres a MTOR-subdivision plugin you need to load in and then convert your mesh into a subdivided one and you are set…I think you can also use maya’s subdivision mesh. Also it looks like you mesh has way too many triangles in the topology, subdivison works efficient when you have quads since it doesnt add unwanted loops in your mesh…


#3

Ah, brilliant, thank you very much! Converting to subdivision surfaces seemed to do the trick.


#4

You can fix this without using subdivision surfaces. You need to store the shading normal’s offset from the geometric normal, and then re-apply it after you’ve calculated your displaced normal. Like this:


    displacement hansDisp (string texName = "";float dispMult = 0.1)
   {
   	float magnitude;
   	magnitude = dispMult * ( float texture( texName ) * 2 - 1 );
      	
   	normal Nn = normalize(N);
   	vector deltaN = Nn - normalize(Ng);
 	P += magnitude * Nn;
   	N = normalize( calculatenormal (P) );
    
	N = normalize( N + deltaN );
 }
   
  
   
   

I’m never sure quite how many normalizes you want in there. Experiment and see what combination works :slight_smile:


#5

I’ll try that too, as I’d quite like to have support for polygonal surfaces as well as subdivision urfs. I’ll have to wait until I go back in on Monday though, so I’ll let you know if that works.

Thanks guys :slight_smile:


#6

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.