procedural texture

各位可在這裡交流有關RenderMan的問題和分享制作經驗

文章ChildPark » 4日 9月 2003年, 21:55

圖檔
加入顏色的典型例子3:
surface texturemap(
float Ka = 1,Kd = 0.4,freq = 4;
color col = color(1,0,0);
string textmap = "";
)
{
normal Nf = faceforward(normalize(N), I);
color Ct;
float ss = mod(s * freq,1);
float tt = mod(t * freq,1);
if(textmap != ""){
Ct = color texture(textmap, ss, tt) * col;
}else{
Ct = Cs;
}

Oi = Os;
Ci = Oi * Ct * (Ka * ambient() + Kd * diffuse(Nf));
}
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

Share On:

Share on Facebook Facebook Share on Twitter Twitter

文章ChildPark » 4日 9月 2003年, 21:56

圖檔
將Ct的顏色掉進Oi內,可令字體有半透感覺,如果要分別區域清楚便需表達式的幫助。

半透明顏色的典型例子4:
surface texturemap(
float Ka = 1,Kd = 0.4,freq = 4;
color col = color(1,0,0);
string textmap = "";
)
{
normal Nf = faceforward(normalize(N), I);
color Ct;
float ss = mod(s * freq,1);
float tt = mod(t * freq,1);
if(textmap != ""){
Ct = color texture(textmap, ss, tt)* col;
}else{
Ct = Cs;
}
Oi = Ct;
Ci = Oi * Ct * (Ka * ambient() + Kd * diffuse(Nf));
}
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 4日 9月 2003年, 21:59

圖檔
freq影響s方向的排列,結果產生2個字體。
圖檔
0.1是震幅的幅度。
圖檔
(t * 30)影響t方向的震幅,結果產生零亂字體。
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 4日 9月 2003年, 22:03

Alpha顏色的典型例子6:
surface Alpha(
float Ka = 1,Kd = 0.4,freq = 2;
color col = color(1,0,0);
string textmap = "";
)
{
normal Nf = faceforward(normalize(N), I);
color Ct;
float ss = mod(s * freq, 1);
float tt = mod(t * freq, 1);

if(textmap != ""){
Ct = color texture(textmap, ss, tt) * col;
}else{
Ct = Cs;
}

Oi = Os;
Ci = Ct * (Ka * ambient() + Kd * diffuse(Nf));
}
圖檔
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 5日 9月 2003年, 22:25

圖檔
圖檔圖檔
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 5日 9月 2003年, 22:27

cellnoise顏色的典型例子7:
surface cellnoise(
float Ka = 1,Kd = 0.4,freq = 4;
color col = color(1,0,0),
Bg = color(0,1,0);
string textmap1 = "";
string textmap2 = "";
)
{
normal Nf = faceforward(normalize(N), I);
color Ct;
float ss = mod(s * freq, 1);
float tt = mod(t * freq, 1);

if(float cellnoise(s*freq, t*freq) > 0.5)
Ct = color texture(textmap1, ss, tt) * col;
else
Ct = color texture(textmap2, ss, tt) * Bg;


Oi = Os;
Ci = Ct * (Ka * ambient() + Kd * diffuse(Nf));
}
圖檔
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 5日 9月 2003年, 22:29

f = float texture(“texturemap.tex”);
lookup詳盡的float浮點值。
float texture的概念是圖片分為4個channel區域。
f = texture (“foo.tex” [1]);
將texture的channel挑選出來可用這方法,surface = texture(texmap [1]) ,選擇texture function,括號內先填寫textname(例如:string textname = “” ),textname是自由定義的,但不要填錯,它是帶出真正的texture的,然後在 []號內填寫channel,標准的數字 0,1,2,3,RenderMan默許的為3,0為紅色,1為綠色,2是藍色,3為alpha
圖檔0
圖檔1
圖檔2
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 5日 9月 2003年, 22:30

c = color texture(“texturemap.tex”)
lookup詳盡的color顏色值。
[surface simpletexture(
float Ka = 1,
Kd = 1,
Ks =0.1,
roughness = 0.1;
color specularcolor = 1;
string texturename = “ ”;
float sstart = 0, sscale = 1;
float tstart = 0, tscale = 1
)
{
/* simple scaled and offset s-t mapping */
float ss = (s - sstart) / sscale;
float tt = (t - tstart) / tscale;

/* look up texture if a filename was given, otherwise use the default surface color. */
color Ct ;
if (texturename != “”){
float opac = float texture(texturename[3], ss, tt);
/* 拿取texture內的(3)alpha數值,將texture處0的資料全顯示*/
Ct = color texture(texturename, ss, tt) + (1-opac) * Cs;
/*將1 - texture 0的值再 * Cs,因為0的值 + 1,所以texture內(0)無色的部份,全變成(1) 白色 */
}
else Ct = Cs;

/* simple plastic-like reflection model */
normal Nf = faceforward(normalize(N),I);
vector In= -normalize(I);

Ci = Ct * (Ka * ambient() + Kd * diffuse(Nf)) + Ks * specularcolor * speclar(Nf, In, roughness);
Oi = Os;
Ci * = Oi;
}
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 5日 9月 2003年, 22:33

Filter Width
怎樣用width這function做抗antialiased的用途,renderman默許的值為1,以下我用1和4做分別,width1比較好和適合,它可分開s和t作方向性設定,用s和t的方向微調數值。

texture (filename, s, t, “width”, 2);
texture (filename, s, t, “width”, 0);
texture (filename, s, t, “swidth”, 1, “twidth”, 4);
圖檔1
圖檔4
surface texmap(
float Ka = 1,
Kd = 1,
rounghness = 0;
color specularcol = 1;
string texturemap = "";
float sstart = 0, sscale = 1;
float tstart = 0, tscale = 1
)
{
float ss = (s - sstart) / sscale;
float tt = (t - tstart) / tscale;

color Ct = Cs;
if(texturemap != ""){
float opac = float texture(texturemap[3], ss, tt);
Ct = color texture(texturemap, ss, tt, "width", 1) + (1 - opac ) * Cs;
}
else Ct = Cs;

normal Nf = faceforward(normalize(N),I);
vector In = -normalize(I);

Ci = Ct * (Ka * ambient() + Kd * diffuse(Nf)) + color specularcol * specular(Nf, In, rounghness);
Oi = Os;
Ci *= Oi;
}
書講最理想是0!
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 5日 9月 2003年, 22:36

Filter Blur
surface texmap(
float Ka = 1,
Kd = 1,
rounghness = 0;
color specularcol = 1;
string texturemap = "";
float sstart = 0, sscale = 1;
float tstart = 0, tscale = 1
)
{
float ss = (s - sstart) / sscale;
float tt = (t - tstart) / tscale;

color Ct = Cs;
if(texturemap != ""){
float opac = float texture(texturemap[3], ss, tt);
Ct = color texture(texturemap, ss, tt, "blur", 0.01) + (1 - opac ) * Cs;
}
else Ct = Cs;

normal Nf = faceforward(normalize(N),I);
vector In = -normalize(I);

Ci = Ct * (Ka * ambient() + Kd * diffuse(Nf)) + color specularcol * specular(Nf, In, rounghness);
Oi = Os;
Ci *= Oi;
}
blur的三數不能調太大,效果會不理想,它配合width一起使用得出理想效果,也可分開s和t作方向性設定,用s和t的方向微調數值。
圖檔0.01
圖檔0.1
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 5日 9月 2003年, 22:38

Filter filter
有兩種filter類形:
texture (filename, s, t, “filter” ,“box” );
texture (filename, s, t, “filter”, “gaussian”);

surface texmap(
float Ka = 1,
Kd = 1,
rounghness = 0;
color specularcol = 1;
string texturemap = "";
float sstart = 0, sscale = 1;
float tstart = 0, tscale = 1
)
{
float ss = (s - sstart) / sscale;
float tt = (t - tstart) / tscale;

color Ct = Cs;
if(texturemap != ""){
float opac = float texture(texturemap[3], ss, tt);
Ct = color texture(texturemap, ss, tt, "gaussian") + (1 - opac ) * Cs;
}
else Ct = Cs;

normal Nf = faceforward(normalize(N),I);
vector In = -normalize(I);

Ci = Ct * (Ka * ambient() + Kd * diffuse(Nf)) + color specularcol * specular(Nf, In, rounghness);
Oi = Os;
Ci *= Oi;
}

其實這兩個filter三數houdini都有提供,只要render的時侯選擇它便成,出現的效果很不明顯,因為Renderman的默許值為Box Filter。
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 5日 9月 2003年, 22:39

surface texmap(
float Ka = 1,
Kd = 0.5,
Ks = 0.4,
rounghness = 0.5;
color specularcol = 1,
bgcol = color(1,0.96,0);
string texturemap = "";
)
{
color Ct = Cs;
if(texturemap != ""){
float opac = float texture(texturemap[3], s, t);
color bg = bgcol;
Ct = color texture(texturemap, s, t) + (1-opac) * bg;
}else{
Ct = Cs;
}
normal Nf = faceforward(normalize(N),I );
vector V = -normalize(I);
Ci = Ct * (Ka * ambient() + Kd * diffuse(Nf)) + specularcol * Ks * specular(Nf, V, rounghness);
Oi = Os;
Ci *= Oi;
}
這texture做一個步驟是拿取texture內alpha的0數值,將它放在backgroud的面處,然後相加兩個layer便完成。
兩個layer合成的方程式:
(layer 1 * alpha) + (layer 2 * (1- alpha)) = 合成
圖檔
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

文章ChildPark » 5日 9月 2003年, 22:41

surface transparencymap(
float Ka = 1,
Kd = 0.5,
Ks = 1,
roughness = 0.5;
color hilight = color(1,0,0);
string texmap = ""
)
{
normal Nf, Norm;
vector V;
color ambientcol, diffusecol, speccol;

Norm = normalize(N);
Nf = faceforward(Norm, I);

ambientcol = Ka * ambient();
diffusecol = Kd * diffuse(Nf);
V = normalize(-I);
speccol = Ks * specular(Nf, V, roughness)* hilight ;

if(texmap != "")
Oi = float texture(texmap,u,v) * Os;
else
Oi = Os;

Ci = Oi * Cs * hilight *(ambientcol + diffusecol + speccol);
}

圖檔
ChildPark
CGV討論區會員
CGV討論區會員
 
文章: 316
註冊時間: 2日 6月 2002年, 12:03
來自: Hong Kong

上一頁

回到 Pixar's RenderMan

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 5 位訪客

cron