Friday, February 1, 2013

Graphics Assignment 3

 Download Code

    I found this assignment pretty easy as compared to the previous one. I have added a texture (.png) image on the cube. I used D3DXCreateTextureFromFile command to load the texture onto the device (IDirect3DDevice9 object). Then set the texture using setTexture command. In vertex shader I just set o_texture=i_texture. It didn't need any changes in vertex shader. In fragment shader, I created a sampler2D object and applied it to the o_color. Applying texture just needed a couple of LOC.

Screenshot of PIX:



Getting point light effects needed just getting the world position of the cube. In fragment shader, I normalized both the world position of the box and the point source of light. Taking a dot product and multiplying it with the o_color gave me the those light effects. I used a simple if branch command to clamp the negative value of dot  product. The light position can be changed with I[up],J[left],k[down],L[right].

I have also taken care of the linker errors in release build. Now, the project works fine in release build.

No comments:

Post a Comment