PDA

View Full Version : .SL to .SLIM conversion


jsells20
01-12-2012, 01:50 PM
Hello, I am a student in Malcolm Kessons class and need a little help. I am trying to convert my .sl code to a slim template but running into multitude of errors.

I am following a format such as....

color a_name (float value,value; color value,value )
{
color result = color(1,1,1);

code goes here

return result;
}

When I right click in cutter and export as slim template I get no errors. It's when I compile it and send to slim and update that I see the errors.

Code:

color js_stPattern (float kd,ka,ks,roughness,kdfront,kdrear,kofront,korear,srepeats,trepeats,colormix,iterate,green,blue; color rimwidth,rimcolor,hilitecolor,ambientcolor,diffusecolor,speccolor,surfcolor )
{
color result = color(1,1,1);

normal n = normalize(n);
normal nf = faceforward(n,I);
Oi = Os;
ambientcolor = ka * ambient();
diffusecolor = kd * diffuse(nf);

vector i = normalize(-I);
diffusecolor = -nf.i + rimcolor + surfcolor;
float dot = 1 - nf.i;

speccolor = ks * specular(nf, i, roughness) * hilitecolor;
float ss= mod(s * srepeats, 1);
float tt= mod(t * trepeats, 1);


if(n == nf) {
surfcolor = colormix;
diffusecolor = diffuse(nf) * kdfront;
Oi = Os * KdFront;
}
else {
surfcolor = color (1.0, .5, 0);
diffusecolor = diffuse(nf) * kdrear;
}

diffusecolor = diffusecolor * Kd;
Oi = Os * KdRear;
Oi = Os;
{
float r = sqrt( (tt -.1)*(tt -.1) + (ss -.1)*(ss -.1));
if (r <= t )
surfcolor = colormix;
}

{
float r = sqrt( (tt -.5)*(tt -.5) + (ss -.5)*(ss -.5) );
float i;
float class1 = srepeats;
float class2 = trepeats;

if ((ss-.5)*(ss-.5) + (tt-.5)*(tt-.5) <.05*korear/kofront)
surfcolor = color (1.0, .5, 0);
else
Oi = color (0, 0, 0);

for(i = 0; i < iterate; i = i + 1) {
if ( r * ( i * noise(i) + sin(10) ) <= class1 -= .01 )
surfcolor = color(red + (i / colormix),
green + (i / colormix * noise(1)),
blue + (i / colormix * noise(1));
}
Ci = Oi * Cs * surfcolor * (ambientcolor + diffusecolor + speccolor);

}
return result;
}

noizFACTORY
01-14-2012, 05:24 AM
Do you want to load up your template as an appearance in slim?

You will need to define the template accordingly and use your shader code in a RSLFunction block. There are examples in the docs on writing one. Or you could check out the factory templates that ship with RMS. They should provide you some guidance as well.

Another recent thread (http://forums.cgsociety.org/showthread.php?f=109&t=1027129)where we were discussing the same. Post #6 by Will Earl illustrates an example.

-Sachin

CGTalk Moderation
01-14-2012, 05:24 AM
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.