My RenderMan Study
- Defining a Object in Surface Shader, and Poor Ray Tracing
Fig.1
Fig.1 is the image which I got through this study. A very simple image.
I shall be happy if you follow me.
- Please download *raydemo.rib* and *raydemo.sl*.
- Please don't see the codes of these files, but compile the shader and render the rib, anyway.
- The same image as Fig.1 is rendered, I think. After that, please confirm that there isn't texture map and shadow map.
- Open the rib file and change the view point or the parameter of LightSource or Opacity of Sphere, and render again.
Fig.2-4 are the examples.
- If you have an interest in these results, please open the shader file and see the codes.
NOTE
- Dear MacRenderMan user--
I bet you can't reproduce the above images except for Fig.3. If you would like, please try *raydemo_MacRM.rib* and *raydemo_MacRM.sl*.
Evne if we calculate illuminance() on the point other than P, returned L dosen't change. For example,
- LightSource "pointlight" 1 "from" [0 0 -1] "to" [0 0 0]
- --
- point moveP=point(1,1,1);
- PP=P+moveP; /*the point other than P*/
- illuminance(P,point(0,0,1),PI) {
- LP=L;
- ClP=Cl;
- }
- illuminance(PP,point(0,0,1),PI) {
- LPP=L;
- ClPP=Cl;
- }
- printf("LP = %p,LPP = %p\n",LP,LPP);
- printf("ClP = %c,ClPP = %c\n",ClP,ClPP);
If you try this, you can find that LP is equal to LPP, also ClP is ClPP.
In the case of BMRT and current PRMan, LP is not LPP, also ClP is not ClPP, of cource.
Please be sure to confirm the past logs in cgrr about this problem of old PRMan version.
If LightSource is "distantlight" or "pointlight", moreover only one kind, we can get LPP by using LP and moveP.
- string light_type="point";
- --
- PP=P+moveP
- illuminance(P,point(0,0,1),PI) {
- /*illuminance(PP,N_PP,PI/2) {*/
- LP=L;
- if (light_type=="distant") {
- LPP=LP;
- Cl2=Cl;
- }
- else {
- LPP=LP-moveP;
- Cl2=Cl*pow(length(LP)/length(LPP),2);
- }
- }
As you know, we have to set illuminance angle to PI.
Please take care when calculate the surface color on PP, especially specular reflection.
Needless to say, before calculating it, judging the dot product of two vectors, LPP and the normal of PP, is needed.
Anyway, this solution is no good, or rather,
not using illuminance loop and setting the light vector as a parameter in a shader may be better.
For this study, I had to overcome this weekness.
PP is regarded as a point of intersection, which I call intersectP, in the direction R from P,
also moveP is R*distance(P,intersectP).
- If you would define PRMan's specular model in illuminance loop...
I defined like the following, anyway.
- Nf=faceforward(normalize(N),I);
- specularcs=0;
- illuminance(P,Nf,PI/2) {
- LL=normalize(L);
- H=normalize(normalize(-I)+LL);
- s_intensity=H.Nf;
- s_intensity=clamp(s_intensity,0,1);
- s_intensity=1-acos(s_intensity)/(PI/2);
- /* s_intensity=pow(s_intensity,1.5); */
- s_intensity=pow(s_intensity,1/(roughness));
- specularcs+=Cl*s_intensity;
- }
- If we define objects in surface shader, we can trace the ray between the objects (ray tracing).
Without texture maps and shadow maps, Fig.5 can be rendered with PRMan by using this method.
Although it takes long long long time to render it, please try *rayteapot.rib* and *rayteapot.sl* when you have time.
Fig.6 is rendered with BMRT by using its ray tracing spec(shiny.sl and shadow option).
You can try the above same rib file with BMRT (in this case, you need to change the comments of some lines in the rib file).
Although I'm MacRenderMan user,
because of the above illuminance spec, I thought that I couldn't use MacRenderMan for this study.
(In addtion, too long codes shader like rayteapot.sl can't be compiled with MacRenderMan's shader compiler.)
So, I asked one PRMan user, whose name is Masuo SUZUKI, to compile/render with PRMan instead of me.
He gladly consented to the request, and our e-mail correspondence started.
As a result, the mails total one hundred, the number of test shaders which I sent is sixty, the term extended over one month.
Inspite of continuous errors (compile error, also rendering core dump),
Masuo didn't only patiently keep up with me, but also gave me many many good advice.
I would like to appriciate him. --Many thanks.