PDA

View Full Version : Shader problem


vigneshwarv
06-11-2010, 01:24 PM
Im stuck,please give me a direction
I use 3Delight for compiling the shaders
I have the error when i compile and it tells that
ERROR:undefined variable `RCurrent`
ERROR:undefined variable `RWorld`



surface plastic(float Ka=1,Kd=0.5,Kr=0.04,Ks=.5,roughness=.1;color specularcolor=1;)
{
vector V;
normal Nf;
Nf=faceforward(normalize(N),I);
V=-normalize(I);
color mytexture;


/* Texture (Advanced Renderman:creating cgi for motion pictures.
By Anthony A. Apodaca, Larry Gritz, Ronen Barzel listing 8.1 page no 187 */

float sstart=0,sscale=1;
float tstart=0,tscale=1;

string texturename="BASKETBALL.tx";

/*simple scaled and offset s-t mapping*/

float ss=(s-sstart)/sscale;
float tt=(t-tstart)/tscale;

/* texture check */

if(texturename!="")
{
mytexture=color texture(texturename);
}
else
{
mytexture=color(1,0,0);
}

//Environment map(Essential Renderman Fast-Ian Stephenson)

vector Rcurrent=normalize(reflect(I,Nf));
vector Rworld=vtransform("world",RCurrent);
color Crefl=color environment("facade.jpg.tx",RWorld);
Oi=Os;
Ci=Oi*(mytexture*(Ka*ambient()+Kd*diffuse(Nf))+specularcolor*(Ks * specular(Nf,V,roughness)+Crefl*Kr));
}

Gravedigger
06-12-2010, 10:58 AM
well....

variable names are case sensitive of course. if you define vector Rworld and use RWorld later on those are two completely separte things. you have to use the exact same spelling

vigneshwarv
06-12-2010, 04:01 PM
Hi chris,
I get a strange error like the following.

"3DL WARNING 2000:object `<unnamed>` <displacement `BasketBalldisplacementSL`,surface `Basketballplastic has no displacement bound but was displaced by ``0.026163 <in eye space>"


here is my displacement file



/*for black grooves*/

normal basicDisp(float bumpheight)
{
float myTexture=texture("bb.tdl");
P+=normalize(N)*myTexture*bumpheight;
N=calculatenormal(P);
}

normal DisplaceTexture(float Km;string texturename;)
{
Km=0;
P -= Km * texture(texturename, s, t) * normalize(N);
return normalize (calculatenormal(P));
}

displacement BasketBalldisplacementSL(float Km=0.016;float bumpheight=0.02;)
{
string texturename="bump.tdl";
N=DisplaceTexture(Km,texturename)+basicDisp(bumpheight);
}


here is my RIB file

Projection "perspective" "fov" [90]
Display "Basketball.tif" "file" "rgba"
Format 1280 720 1
Clipping 0.001 1000
#for camera position
Translate 0 0 4
WorldBegin
AttributeBegin
Displacement "BasketBalldisplacementSL"
Surface "Basketballplastic"
Rotate 45 0 1 0
Sphere 1 -1 1 360
AttributeEnd
AttributeBegin
Translate 0 -1 0
Color 1 1 1
Polygon "P" [-5 0 -5 -5 0 5 5 0 5 5 0 -5]
AttributeEnd
WorldEnd

Gravedigger
06-12-2010, 09:18 PM
you should set a displacement bound when doing displacements. not defining bounds will result in artifacts at the displacements.

Attribute "bound" "displacement" boundVal

CGTalk Moderation
06-12-2010, 09:18 PM
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.