lumiere
03-12-2005, 01:09 PM
Hello, I need to convert a shader from RenderMan to MentalRay.
The shader is "Threads", I put here the RenderMan code. Please can anyone help me? I'm not a programmer.
Thanks in advance to all
Enrico
/* Copyrighted Pixar 1989 */
/* From the RenderMan Companion p.367 */
/* Listing 16.24 Displacement shader providing light-bulb threads to cylinder */
/*
* threads(): wrap threads around a cylinder
*/
displacement
threads (
float Km = .1,
frequency = 5.0,
phase = .0,
offset = .0,
dampzone = .05 )
{
float magnitude;
/* Calculate the undamped displacement */
magnitude = (sin( PI*2*(t*frequency + s + phase))+offset) * Km;
/* Damp the displacement to 0 at each end */
if( t > (1-dampzone))
magnitude *= (1.0-t) / dampzone;
else if( t < dampzone )
magnitude *= t / dampzone;
/* Do the displacement */
P += normalize(N) * magnitude;
N = calculatenormal(P);
}
The shader is "Threads", I put here the RenderMan code. Please can anyone help me? I'm not a programmer.
Thanks in advance to all
Enrico
/* Copyrighted Pixar 1989 */
/* From the RenderMan Companion p.367 */
/* Listing 16.24 Displacement shader providing light-bulb threads to cylinder */
/*
* threads(): wrap threads around a cylinder
*/
displacement
threads (
float Km = .1,
frequency = 5.0,
phase = .0,
offset = .0,
dampzone = .05 )
{
float magnitude;
/* Calculate the undamped displacement */
magnitude = (sin( PI*2*(t*frequency + s + phase))+offset) * Km;
/* Damp the displacement to 0 at each end */
if( t > (1-dampzone))
magnitude *= (1.0-t) / dampzone;
else if( t < dampzone )
magnitude *= t / dampzone;
/* Do the displacement */
P += normalize(N) * magnitude;
N = calculatenormal(P);
}
