Wednesday, November 26, 2008

1444

1444 is the number of FPS that Tau Ceti made on this system:

- E8500@3.16 GhZ
- 4870x2 Shappire
- 4 Gb RAM
- Vista 64

This executable was compiled with 32 bit version of directx (64 bits gives me some errors..)

---

1444 e' il numero degli FPS che ho ottenuto con Tau Ceti sul seguente sistema:

- E8500@3.16 GhZ
- 4870x2 Shappire
- 4 Gb RAM
- Vista 64

L'eseguibile e' stato compilato con le librerie a 32 bit di directx (Quelle a 64 mi danno alcuni errori...)


Monday, November 24, 2008

Normal Mapping 3


Excuse me, i've forgotten the english part.
To apologize i show you another video :)
I've finished to implement the normal map shader, now the mesh look like more deep, more defined and more metallic.

If you want to ask me some technical details you're welcome


---

...avevo dimenticato la parte in inglese, cosi' ne approfitto per mettere un secondo filmato ed uno screenshot

Normal Mapping 2

Come promesso, eccovi un filmato che ritrae una Luna realizzata con la tecnica del Normal Mapping.
Per chi non lo sapesse il normal mapping e' una tecnica che permette di realizzare oggetti "ruvidi" senza dover aumentare il numero dei poligoni che ne compongono la mesh.
Se vi servono dettagli piu' tecnici fatemi sapere, nel frattempo vi lascio col video.


Friday, November 21, 2008

Normal Mapping


With the pixel shader developing now i'm able to make more complex effect.
For example: normal mapping.
For now a fast screenshot (i'm a little busy), coming soon a video.

---

Studiando i pixel shader sono riuscito a fare effetti un po' piu' complessi.
Ad esempio il normal mapping.
Vi propongo un "veloce" screenshot (sono un po' preso), ma conto di mettere un video al piu' presto

Thursday, November 13, 2008

Gourard Vs Phong











I was missing for a while. For a good reason: i've fight against the pixel shaders, and i've understood a lot of thing.
So, finally, i've implemented a new lighting model using the pixel shaders: the phong lighting.
The previous model was the gouraud lighting: the light is computed for each vertex of the mesh and the color of pixels between three vertexs are interpolated from the color of the three vertex.
With phong shading, every pixel colour is computed using the illumination model. No interpolation, so a more realistic result, as you can see from the screenshots and the video. Gourarud shading has a "segmented" look, the Phong Shading has a more gentile and realistic aspect. (Look at the spotlights on the skull.. the gourard, the first, looks like a sum of triangle, the phong, the second, is better).

--

Sono stato assente per un po'. Per una buona ragione: ho combattuto (duramente) con i pixel sharders, e ho imparato davvero diverse cose.
Cosi', finalmente, sono riuscito ad implementare un nuovo modello di illuminazione, utilizzando i pixel shaders. Precedentemente usavo il classico Gouraud shading, il quale calcolava l'illuminazione solo nei vertici della mesh, mentre per il colore dei pixel compresi tra tre vertici di un triangolo eseguiva una banale interpolazione, veloce ma poco accurata.
Con i pixel shaders invece son riuscito a calcolare correttamente l'illuminazione per ogni singolo pixel della mesh, senza bisogno di ricorrere all'interpolazione. Il risultato lo vedete negli screenshot e nel video: l'illuminazione gouraud appare piatta, spezzettata, mentre quella phong e' molto piu' accurata, gentile, realistica (guardate ad esempio le chiazze di luce sul teschio, nel gouraud shading, il primo, si notano i rettangoli che compongono la mesh, nel secondo teschio invece le macchie di luce sono molto piu' tondeggianti e piacevoli)

Wednesday, November 5, 2008

Tuesday, November 4, 2008

Lord Alucard 2

Two objective for the next steps on developing:

  1. Understand more on shaders under directx. Until now i've used some simplex shaders from the Frank Luna's book. It's time to study, learn, and make more complex effect, understand how pixel shaders works, how to make it time-dependent for animation (i.e.: heat distorsion), and so on.
  2. Implement a new routine thats could write texts on screens using coloured font, aka bitmapped font. It's not easy.. with the previous version of directx there was the directDraw api that manage the 2D world. Now the DirectDraw is no more included on directx so i've to discover the easiest way to display a 2d text on screen using only 3d functions. There's some method that write some string on screen, and i've used to display the name of the planet, and the debug informations, but i need to write multicolored chars, and it seems that it's a hard work.

Anyway here you are my first experiment with pixel shaders.. a shader that give an (ugly) "cartoon style" to the displayed scene.
The behaviour is very simple: it takes the r,g and b components of the pixel, that are float in 0,1 range, multiply by 5, take only the int part, inserting so a "sampling error" due to low resolution of the sampler, then divide the result by 5 to obtain the result.



float4 SkyPS(float3 envTex : TEXCOORD0) : COLOR
{
float4 ret = texCUBE(EnvMapS, envTex);

ret.r = int(ret.r*5.0f)/5.0f;
ret.g = int(ret.g*5.0f)/5.0f;
ret.b = int(ret.b*5.0f)/5.0f;

return ret;
}





---

Ho due obiettivi per gli sviluppi futuri

  1. Capire bene come funzionano gli shader sotto directx. Per ora ho utilizzato alcuni semplici esempi presi dal libro di Frank Luna, ma e' tempo di studiare meglio la materia per cercare di creare qualcosa di piu' complesso, ad esempio come fare in modo che uno shader sia dipendente dal tempo che passa, per creare ad esempio gli effetti di "distorsione da calore".
  2. Implementare una nuova routine per mostrare delle stringhe sullo schermo che preveda l'utilizzo di font colorati e non solo monocromatici. Sembra sia un'impresa tutt'altro che facile: a quanto pare un tempo esisteva l'api DirectDraw che dava strumenti semplici per gestire il 2D (come le scritte) da mostrare. Ora pero' le DirectDraw sono state abbandonate e non sono nemmeno piu' presenti all'interno delle directx, col risultato che se si vuol mostrare qualcosa in 2D, come una stringa, occorre comunque passare attraverso il mondo 3D, e la faccenda sembra tutt'altro che banale. Fino ad oggi ho utilizzato alcune funzioni di sistema per mostrare del testo nello schermo (i nomi dei pianeti, le informazioni di debug..), ma purtroppo a quanto pare tali funzioni non prevedono la possibilita' di usare dei font bitmapped (multicolore per l'appunto), e quindi mi tocchera' far tutto da zero.

Ad ogni modo vi lascio col mio primo esperimento con un pixel shader. Uno che dorebbe dare una (brutta) rappresentazione dell'immagine come se si trattasse di un "cartone animato".
Il procedimento e' semplice: prende le componenti r,g,b di ciascun pixel, che sono numeri float nel range 0,1, le moltiplica per 5, ne prende solo la parte intera, introducendo cosi' una sorta di "errore di campionamento" dovuto a scarsa risoluzione del campionatore, e ridivide quanto ottenuto di nuovo per 5 per ottenere il risultato finale.



float4 SkyPS(float3 envTex : TEXCOORD0) : COLOR
{
float4 ret = texCUBE(EnvMapS, envTex);

ret.r = int(ret.r*5.0f)/5.0f;
ret.g = int(ret.g*5.0f)/5.0f;
ret.b = int(ret.b*5.0f)/5.0f;

return ret;
}