Skip to content

Instantly share code, notes, and snippets.

@syoyo
Created December 3, 2008 17:26
Show Gist options
  • Save syoyo/31622 to your computer and use it in GitHub Desktop.
Save syoyo/31622 to your computer and use it in GitHub Desktop.
Macintosh-3: $ cat input.sl
surface
matte(float Ka = 1.0; float Kd = 1.1;)
{
normal Nf = faceforward(normalize(N), I);
Oi = Os;
Ci = Os * Cs * (Ka * ambient() + Kd * diffuse(Nf));
}
Macintosh-3: $ ./lslc input.sl
// [AST] = [ShaderFunc Surface "matte" [FormalDecl TyFloat "Ka" (Just (F 1.0)),FormalDecl TyFloat "Kd" (Just (F 1.1))] [Def TyNormal "Nf" (Just (Call TyUndef "faceforward" [Call TyUndef "normalize" [Var TyUndef "N"],Var TyUndef "I"])),Assign TyUndef (Var TyUndef "Oi") (Var TyUndef "Os"),Assign TyUndef (Var TyUndef "Ci") (BinOp TyUndef OpMul [BinOp TyUndef OpMul [Var TyUndef "Os",Var TyUndef "Cs"],BinOp TyUndef OpAdd [BinOp TyUndef OpMul [Var TyUndef "Ka",Call TyUndef "ambient" []],BinOp TyUndef OpMul [Var TyUndef "Kd",Call TyUndef "diffuse" [Var TyUndef "Nf"]]]])]]
surface matte(float Ka, float Kd) {
normal Nf = faceforward(normalize(N), I);
Oi = Os;
Ci = ( ( Os * Cs ) * ( ( Ka * ambient() ) + ( Kd * diffuse(Nf) ) ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment