Monday, June 05, 2006

Vertex Shader, HLSL, DXUT

Overview

I did a lot of reading for these few days regarding vertex shader. I have to find out the reason why Hafiz tell me to learn this instead of keep using Fixe function. While i dare to finally write this out, mean i got the answer lah :P What I personally found out is, vertex shader and FF actually doing the same thing, i mean, their main job is to get the vertex transform, color, lighting done and render to the screen, the different is vertex shader allow programmer to do more thing with the vertex.

Both method is very different discipline in programming sense. Coding of vertex shader is far more different concept and style compare to FF. So i guess i pick a very right time and meet the very right people before I actually start my study on Direct X. I downloaded the latest direct x SDK, inside contained Direct X 10 SDK as well, and the fact is, FF is totally eliminated in Dx10, what is the answer now?

Vertex Shader

A very brief introduction of vertex shader. Directly code to GPU to transform, light and texturing the vertex instead using the fix function. From the website I introduce at previuos achieves (Beyond 3D), i went throught all the pages about the comparison of fix function and vertex shader. What surpise me is vertex shader is all about assembler language (at least it look very alike) and i found it is impossible for me to learn that and code it out, that is too abstract and tedius.

In direct X, here come another thing (which i only learn this after I read the documentation of Direct X 9. They help, alot. Pixel Shader is another shader thingy which actually alter each pixel to be render on the screen, to use vertex shader in Dx, Pixel Shader always come next. To find more information about this, please refer to Dx 9 Documentation-> HLSL part. Again, http://www.microsoft.com/directx to grab your direct x SDK (april 2006 the latest).

HLSL

So i did mentioned about HLSL (High Level Shader Language). I thought I putting myself into a nightmare when i found out that vertex shader is actually about assembler language, how i giong to code that insane. Stupid me forget John did tell me something before, yes, the HLSL. I search around direct X documentation and suddenly find this keyword, I click it and...magic! This is what I want, a higher level language to actually help me to code vertex shader! (I thinkthis is really silly and stupid thing, sorry, i am NooB) :P

HLSL is actually used and code in a file with .FX (effect file in direct x term). I not sure is there any compiler or better IDE to code this since what i opened with is a notepad. HLSL is a higher level language to actually help programmer to do the vertex shader coding but it is still not easy to learn and understand. The style and rules to use it is new to me, i never meet this kind of library before. No doubt that HLSL is far more easier to learn and code compare to ASSEMBLY language i guess.

To get away from using Fixed function pipeline, the only alternative is HLSL now. Though it is damn hard, but still need to learn and use it, it is the future now. My plan now is dont bother a thing of Fix Function Pipeline, and just treat that HLSL is the only way to solve the problem since they 2 are very different thing (for me).

DXUT

DXUT is a cool thing that i found out when i start learning how to use HLSL. Actually i knew it at the very first time but i skiped it because I thought it is a Noobie thing. Sorry for my misunderstanding but DXUT did a very great favour for me (especially a guy who is very weak or know nothing about windows programming).

DXUT is a framework provide by Dx to ease the programmer coding in direct X. DXUT handle the task of creating device, creating windows and handling windows message. Programmer just need to type in some calling function and init for the DXUT then save many lines of codes and can focusing on the part which is more important then retype the windows code again and again.

Well, this is really a Noobie thing, but a very good start for beginner like me i guess. I will write my own library next time to handle this thing, but in this mean time, DXUT do the good thing for me :P

Lastly...start getting lazy to post blog leh :P whatever, I will try to learn more of DXUT and HLSL and looking forward to actually code out something from my own finger very soon.

Today Feeling -- Happy Chatting~