Jump to content

Porting glow shader from RenderMan Companion


nicholas_yue

Recommended Posts

I am attempting to port the glow shader from RenderMan SL

I am not sure how to handle Cs.

The prman.h header file suggest we pass in the color information via a VEX parameter.

I know how to add a color parameter, my question is, how do we get the color information in the first place.

Cs is defined as the incoming color information.

Here is the glow shader source in RenderMan SL

/*

* glow(): a shader for providing a centered "glow" in a sphere

*

* From _RC_ Listing 16.26 p. 369

* Surface mapping object-space coordinates to colors

*/

surface

s_RCGlow (float attenuation = 2)

{

float falloff = I.N; /* Direct incidence has cosine closer to 1. */

if (falloff < 0) {

/* Normalize falloff by lengths of I and N */

falloff = falloff * falloff / (I.I * N.N);

falloff = pow (falloff, attenuation);

Ci = Cs * falloff;

Oi = falloff;

}

else

Oi = 0;

}

Link to comment
Share on other sites

Once you've created and fed your point attribute ( say Cs or whatever).

In VOP, just add a Parameter VOP, rename it to your point Attribute ( Cs here), and turn on Export Parameter, in the Parameter Page.

The parameter that you defined at specific points will be interpolated on the whole surface.

Hope it answers your question.

Link to comment
Share on other sites

#pragma oplabel "NYVEX Glow"
#pragma opname	NYVEX_Glow
#pragma opicon SHOP_surface

#pragma label  attenuation  "Attenuation"
#pragma label  gcolor  "Color"

#pragma hint	attenuation	float
#pragma hint  gcolor  color

#pragma range attenuation 1 20

surface s_RCGlow (vector gcolor = {1.1, 1.1, 0.9}; float attenuation = 2)
   {
   float falloff = dot(I, N); /* Direct incidence has cosine closer to 1. */

   if (falloff &lt; 0) {
       /* Normalize falloff by lengths of I and N */
       falloff = falloff * falloff / (dot(I,I) * dot(N,N));
       falloff = pow (falloff, attenuation);
       Cf = gcolor*falloff;
       Of = falloff;
       }
   else
      {
      Of = 0;
      }
   }

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...