PDA

View Full Version : Displacement with RenderMan


magost
06-22-2010, 02:34 PM
Hi all, probably this question will be very obvious for many of you but i have no idea of how to solve it.
I have written a RIB file, among other things i have declared the displacement shader and after that the surface shader.
The "problem" i have is with the displacement shader. At the end of the displacement shader i have to recalculate the surface normals:
N = calculatenormal(P);

The "problem" is that this recalculation produces that my geometry lost the subdivision so the geometry looks faceted. Without the displacement shader RenderMan subdivides the geometry but with the displacement shader the subdivision is broken ;(

Any idea of how to fix that?
I'm using aqsis renderer.

Thanks in advance, any help will be welcome.

hulud
06-23-2010, 06:35 AM
Hi,

calculatenormal(P) returns a 'flat' normal if you use it on polygons. (For the details, calculatenormal(P) = dPdu^dPdv, which is constant on polygons)

You can do something like that :

normal nN = normalize (N);
point newP = P + nN * height;
normal newN = normalize (calculatenormal(newP)) + (nN - normalize (calculatenormal(P)));

In a nutshell, you compute the new "flat normal" and you apply the delta between the old normal and the old "flat normal".

Cyril

magost
06-29-2010, 04:24 PM
Thanks for the answer, it helped me a lot ;)

On the code you write what it's supposed to do with the "newN" variable? Assign it to "N"?
And apart from calculating "newP", must you calculate "P"? I thought a new value of P (newP) was necessary only if you want to use bump instead of displacement. I want to use displacement so, is it necessary to calculate newP or should i assign only the new value to P?

I have written this following your advice (i think it works):
P = P + nN * height;
point newP = P + nN * height;
normal newN = normalize (calculatenormal(newP)) + (nN - normalize (calculatenormal(P)));
N = newN;

It's that code ok? It's the same of that one, isn't it?
P = P + nN * height;
N = normalize (calculatenormal(P)) + (nN - normalize (calculatenormal(P)));


Thanks for the help.

noizFACTORY
06-30-2010, 05:28 AM
I thought a new value of P (newP) was necessary only if you want to use bump instead of displacement.

Its the other way around. You need the new position P for displacing the geometry but you only need calculatenormal(newP) for bump where you are not necessarily displacing any geo but only using the new normals to fake the effect through bump.

hulud
06-30-2010, 07:34 AM
And apart from calculating "newP", must you calculate "P"?
Yes, as noizFACTORY said, you have to change P if you want displacement.
Sorry I forgot it in my exemple, it should be something like :

normal nN = normalize (N);
point newP = P + nN * height;
N = normalize (calculatenormal(newP)) + (nN - normalize (calculatenormal(P)));
P = newP;

Cyril

CGTalk Moderation
06-30-2010, 07:34 AM
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.