example_shading , texture e bump mapping Clicca QUI per vedere il messaggio nel forum |
ButterFlower |
ciao!
ho provato a far andare l'esercizio dell'ultima volta sul mio pc...
quello con la texture lego e il bump...
ovviamente li ho sostituiti con immagini mie e converititi in .tx e cambiato i nomi nel .rib...
insomma tutto a posto, ma quando eseguo il .rib mi dice:
example_shading.rib (46): Unable open texture "ps.tx"
example_shading.rib (46): Unable open texture "tre.tx"
voi ci avete provato?funziona?
grazie ciao!:) |
ButterFlower |
come non detto.....risolto!:D |
Ste.dv |
Poiché evidentemente l'hai trascritto, potresti incollare qui il codice relativo all'uso del bump mapping (basta lo shader)?
È l'unica cosa che non riesco a provare perché Viale non ha ancora messo l'esercizio sul sito.
Grazie. |
ButterFlower |
sul sito c'è!l'ho preso li!
comunque è questo:
RIB
Option "searchpath" "shader" [".:./shaders:&"]
Option "searchpath" "texture" [".:./textures:&"]
Format 640 480 1
Display "teapots.tif" "tiff" "rgba"
Projection "perspective" "fov" [24]
Transform [0.947768 -0.137508 -0.287796 0 -1.38778e-017 0.902297 -0.431115 0 -0.318959 -0.408597 -0.855169 0 -2.04281e-014 -2.24265e-014 17.9935 1]
WorldBegin
LightSource "ambientlight" 0 "intensity" [0.1] "lightcolor" [1 1 1]
LightSource "pointlight" 1 "intensity" [650]"lightcolor" [1 1 1]"from" [12 10 10]
LightSource "pointlight" 2 "intensity" [200]"lightcolor" [1 1 1]"from" [-12 5 15]
AttributeBegin
ConcatTransform [1 0 0 0 0 1 0 0 0 0 1 0 -2 1 0 1]
Surface "myCartoon" "point lightPos" [12 10 10]
Color [0 1 0]
Sphere 1 -1 1 360
AttributeEnd
AttributeBegin
ConcatTransform [1 0 0 0 0 1 0 0 0 0 1 0 0.866674 1 3.93264 1]
Surface "myPhong"
Color [1 0 0]
Sphere 1 -1 1 360
AttributeEnd
AttributeBegin
ConcatTransform [1 0 0 0 0 1 0 0 0 0 1 0 2 1 0 1]
Rotate 90 1 0 0
Surface "myTexture" "string texName" "legologo.tx" "float ss" -4 "float tt" 4 "string texDiffusive" "noise.tx"
Color [1 0 0]
Sphere 1 -1 1 360
AttributeEnd
AttributeBegin
Scale -100 -100 -100
Surface "constant"
Color [0.5 0.5 0.5]
Sphere 1 -1 1 360
AttributeEnd
WorldEnd
SHADER
surface myTexture (string texName = "", texDiffusive = ""; float ss = 1, tt = 1, Kd = 1.0)
{
color myColor;
float myKd;
normal Nf;
Nf = faceforward( normalize(N), I);
if (texDiffusive == "")
myKd = Kd;
else
myKd = float texture (texDiffusive, s * ss, t * tt);
if (texName == "")
myColor = Cs;
else
myColor = texture( texName , s * ss, t * tt);
Ci = myColor * myKd * diffuse(Nf);
} |
ButterFlower |
comunque non penso sia completo lo shader per il bump che ha messo il prof perchè ad esempio manca il calcolo della normale... |
Ste.dv |
Infatti. Questo shader mostra solo l'applicazione delle texture.
L'ultimissimo, fatto mercoledì scorso, manca.
Grazie comunque. |
ButterFlower |
;)
ps: qualcuno ha trovato in giro una guida/tutorial su pixie che non sia il wiki del sito?? |
Supernick |
Per chi interessasse son riuscito a fare il bump mapping
ecco qui il codice per lo shader:
surface myShader (string texName = "", texDiffusive = ""; float ss = 1, tt = 1, Kd = 1.0, Km = 1.0)
{
color myColor;
float myKd, amp;
vector newP;
normal Nf, tempN;
Nf = faceforward( normalize(N), I);
if (texDiffusive == "")
myKd = Kd;
else
amp = Km * float texture (texDiffusive, s, t);
newP = amp * normalize(N) + P;
tempN = calculatenormal(newP);
Nf = faceforward (normalize (tempN), I);
myKd = Kd;
if (texName == "")
myColor = Cs;
else
myColor = texture( texName , s * ss, t * tt);
Ci = myColor * myKd * diffuse(Nf);
}
Praticamente basta mettere in un float le informazione della texture di bump (in questo caso ho lasciato il nome texDiffuse) , e mettere in un vettore newP un vettore che si basa sulle info passategli dalla texture
enjoy! |
|
|
|