Renderman shader AOV


#1

Hi , All

I am learning shaderwriting . I have write a shader for PRMan and i am rendering it in maya . I wanted to add output channel shadow, unshadowed , specular, normal . I have tried shadow channel using lightsource function but some how it is not working . so anyone please help me to add these perticular channels (AOV) . here is sl code

surface plastic_texture(

float ka=0.8,
kd = 0.8,
ks=0.6,
roughness = 0.4;
color specularcolor = (1,1,1);
color diffcolor = (1,1,1);
color opac =(1,1,1);
string ColorMap = “”;

)

{
normal nf = faceforward(normalize(N),I);
vector V = -normalize(I);
color speccolor = 1;

Oi = opac;

if(ColorMap!="")
{

Ci = Oi * texture(ColorMap,s,t) * (kaambient()+kd diffuse(nf)) +specularcolorksspecular(nf,V,roughness);

}
else
{

Ci = Oi diffcolor * (kaambient()+kd diffuse(nf)) +specularcolorks*specular(nf,V,roughness);

}

}


#2

Hey

Output Variables got to be declared as “output <type> name” in the sahder’s parameters block .
Then in Maya,navigate to the Default RiOptions field,and enter:

RiDisplayChannels “<type> name”

The last thing is to add your variable to the output,you can do this as you would normally do with any custom output.So navigate to the output->Create Ouput->Custom…->“name”

shader’s and DisplayChannels’ type and name got to be equal.

So it will look like this:

surface shaderName(…,output varying color myColor=(1,1,1):wink:
{

myColor=…

}
Then in the default RiOptions: RiDisplayChannels “color myColor”

And in the Create Ouput->Custom… the name will be “myColor”

Render to “IT”,now your output has to appear under your primary pass.


#3

Hey Thanks Alex
The info you have given is very useful . I have tried to extract shadow channel
i have declare Output varying color __shadow = 0; in parameters block . For Air Renderer There is a function for extracting shadow channel ie. Diffuse (“shadow”,__shadow) with this you get shadow channel separately But i can’t find any such function for PRman i have also tried with lightsource function but it is also not working for me .
so can you please tell me if there is any function like this or any another way to extract shadow and unshadowed channel.


#4

hi!

in prman the standard workflow is to create an illuminance loop.inside the loop you can do things like:


lightsource("__nondiffuse", nondiffuse);
 lightsource("__nonspecular", nonspec);
lightsource("_cl_noshadow", clnoshadow);
lightsource("_shadow", inshadow);

this seperates the lights contribution as needed and you can for example:


color cldiff = clnoshadow-Cl;
color diff = DiffuseColor*Nn.Ln;
OcclusionDirect = max(OcclusionDirect, inshadow);
DiffuseDirect += diff*clnoshadow;
DiffuseDirectShadow += diff*cldiff;

same for speculars. OcclusionDirect, DiffuseDirect and DiffuseDirectShadow are standard AOVs for renderman studio so when using this your shaders integrate nicely into maya

grs
Patrik


#5

Yep,you don’t have to write anything in this case.Explore embedded output’s,everything is already done.


#6

What light shader are you using? The light shader needs to have corresponding parameters which are filled by the light shader. eg.


light shadowed_light(color light_color = 1;
                            uniform float intensity = 1;
                            string shdmap = "":
                            output color __shadow;
) {

    __shadow = 0;

    if (shdmap != "")
        __shadow = shadow(Ps, shdmap);

    illuminate(Ps) {
        Cl = intensity * (light_color * (1 - __shadow));
    }

}

Note that the __shadow output is output only so that you can write to it in the light shader - you can query any instance variable using lightsource(). You probably want it to be a colour so you can use coloured deep/raytraced shadows.

Simon


#7

Hello
Thanks to all for reply


#8

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.