기존 decal shader 에 alpha, lighting, 그리고 matte 기능을 포
/*point sop 으로 alpha 와 Cd 를 조정해도 됩니다.*/
#pragma label light "Lighting"
#pragma label amb "Ambient"
#pragma label diff "Diffuse"
#pragma label spec "Specular"
#pragma label rough "Roughness"
#pragma label map "Texture Map"
#pragma label uwrap "U Tiling"
#pragma label vwrap "V Tiling"
#pragma label channel "Alpha Output"
#pragma label ascale "Alpha Scale"
#pragma label matte "Matte Object"
#pragma hint amb color
#pragma hint diff color
#pragma hint spec color
#pragma hint map image
#pragma hint Cd hidden
#pragma hint Alpha hidden
#pragma hint uv hidden
#pragma hint matte toggle
#pragma range rough 0.001 1
#pragma choice light "constant" "Constant"
#pragma choice light "lambert" "Lambert"
#pragma choice light "phong" "Phong"
#pragma choice uwrap "repeat" "Repeat"
#pragma choice uwrap "clamp" "Streak"
#pragma choice uwrap "decal" "Decal"
#pragma choice vwrap "repeat" "Repeat"
#pragma choice vwrap "clamp" "Streak"
#pragma choice vwrap "decal" "Decal"
#pragma choice channel "ob" "Object"
#pragma choice channel "ma" "Alpha"
#pragma choice channel "mr" "Red"
#pragma choice channel "mg" "Green"
#pragma choice channel "mb" "Blue"
#pragma choice channel "ml" "Luminence(Smoke)"
#pragma help "feb. 12 2003 Khi"
surface
decal_alpha(
string light = "constant";
vector amb = 1;
vector diff = .8;
vector spec = .8;
float rough = .1;
string map = "";
string uwrap = "decal", vwrap = "decal";
string channel = "ma" ;
float ascale = 1;
int matte = 0;
vector Cd=1;
float Alpha=1;
vector uv=0;
)
{
float ss, tt;
vector dclr;
vector4 mapclr;
vector nn;
vector pointcolor;
float pointalpha;
if (isbound("Cd")) {
pointcolor = Cd ; }
else {
pointcolor = 1; }
if (isbound("Alpha")) {
pointalpha = Alpha; }
else {
pointalpha = 1; }
if (map != "")
{
dclr = diff * pointcolor;
if (isbound("uv"))
{
ss = uv.x;
tt = uv.y;
}
else
{
ss = s;
tt = t;
}
mapclr = texture(map, ss, tt, "uwrap", uwrap, "vwrap", vwrap);
dclr *= (1 - mapclr.a);
if (channel != "ob") {
if (channel == "mr") {
Af = (mapclr.r); }
if (channel == "mg") {
Af = (mapclr.g) ; }
if (channel == "mb") {
Af = (mapclr.b); }
if (channel == "ml") {
Af = luminance(mapclr); }
if (channel == "ma") {
Af = (mapclr.a); }
}
Of = Af * ascale * pointalpha;
if (matte == 1) {
Af = 0;
}
dclr = mapclr * Of * pointcolor;
}
else
{
dclr = diff * pointcolor;
Af = pointalpha;
}
nn = frontface(normalize(N), I);
if (light == "constant") {
Cf = diff * dclr + (ambient()*amb) ;
}
if (light == "lambert") {
Cf = (ambient()*amb) + diff * dclr;
Cf *= diffuse(nn);
}
if (light == "phong") {
Cf = (ambient()*amb) + diff * dclr ;
Cf *= diffuse(nn);
Cf += specular(nn, -normalize(I), rough) * spec * Of;
}
if (channel == "ml") {
Af = Of * Cf * pointalpha;
}
}