2012/07/29

12/07/29 Normal Mapping and Transparency

After 3 days fighting with the configuration of my classes and optimization of the code I finally have Normal Maps and Transparency per material, I wrote a small switch for the shader selection, now materials will draw with either material color (no texture), Texture (Normal Optimization in Maya) or Normal Mapped, next step: Specular Mapping and Load models by scripting.



Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/27

12/07/27 Super Meat Boy / Limbo

Having spent more than 50 hours on the project this week I decided to take a break from everything and do some things that I have been procrastinating, first of all both my Mac has now Snow Lion and the iMac has its deserved Windows 7 partition, I can finally test my programs here, and what better way to test the windows partition than with some cool games =D

I started playing Super Meat Boy again, though its a cool game, I could just play the first world again without feeling repetitive, I'm not done with it, but at least I was at level 4 on the other machine. This game is great, and the balance between speed and timing is crucial, but still there are times that you need to go sloooow. Great platformer if you have just a couple of minutes.



But the icing of the cake of today was Limbo, that thing is great and reminded my why I'm on the graphics track of my Masters, though the graphics are all high-contrast (black/white) and the whole thing seems to be in 2d graphics only, the environment this game gives is great, there is no music whatsoever (maybe just splashes here and there) and the game is really short, but it is so inviting. If you ask me whats is the story about I would quite honestly couldn't come with a straight answer, it is about being in a limbo maybe? But what makes this game great is not just the beautiful shaders, nor the play type, is the fact that everything you do within the game is meaningful, you do feel that you accomplished something while you solve a puzzle, overall is a great experience and a must in your collection.



Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/25

12/07/25 Instances 3 and Bump Map

Arranged a bunch of code to improve speed and the system hierarchy, also applied BumpMap to the scene but as the general shader needs to be improved. Here is the sample, in the red cube you can see the effect more clearly.



Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/24

12/07/24 Instances 2

It took more effort than that I had in mind but this is working great right now, I might just need to do some advance methods to work easier while swapping the materials and such.

Right now I'm loading the model once, and creating 2 instances, changing the materials of the second one and displaying both.



Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/23

12/07/23 Instances

I restructured the way materials are applied to the model, they are not object dependant now (at least not structurally speaking) and therefore I'm able to just create a new material and apply it to any object within a group, this way I can create instances of the model that use all the buffer information but renders it with a different material (Ken-Ryu style) saving a lot of loading time and best of all, memory. I haven't finish the Instance class, but I've been here since 8 am, I deserve to rest!


Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/20

17/07/20 Maya obj groups naming convention, Materials and improvements.

I had a mayor rethinking on the way I was loading obj files from Maya and coded some basic error detection algorithms.

Maya does not export information regarding groups that doesn't have any faces associated to (empty groups) to an obj file, which is not really a big issue, normally. The problem is that the way Maya names groups do involve empty groups if they exist, and therefore they are used when you make the association of what face goes to what group.

In Maya a group hierarchy like "g father son", means that there are 2 groups a group father and a group son, and the relationship between them (son goes under father), on the other hand a name like this: "g father son empty) means that the hierarchy is like this father->empty->son, an empty group at the end of a branch wouldn't appear in the group name at all because there are no faces after, but if after an empty group there is a group with info like in this hierarchy father->son->empty->sonofson maya would do something like "g father son sonofson empty", the best way to avoid this kind of problems is avoid the use of empty groups whenever possible, but they do have the advantage of giving an extra movement axis for animations, so other possible solution is create a Hierarchy association by hand, will work on the latest solution eventually in MEL, right now the best solution is what I ended up doing:

Right now the code accepts hierarchy named groups from Maya but will skip all empty groups unless the user manually adds them to the file any where like "g group" a problem for detecting the empty groups is that there is no easy way to detect them as they don't really exist so we have to name that empty group as they please but with the identifier "NULL_" before the name. Anyhow if we want those groups in the model for the sake of animation they must be added by hand to the OBJ and the hierarchy file.

The other thing that used my day was adding an extra texture to a material, this texture will be used by the shader to create BumpMaps, so far I only load the texture, no fancy normal yet, this image is from the model rendering with the BumpMap instead of the Texture file.


Next Step: Shaders.

Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/19

12/07/19 Optimization

The modes are loading way faster but most importantly I'm no longer creating buffers every draw call but once at the beginning of the program, and then releasing the unnecessary information, this is coming great, now I have to write a better shader to draw this materials, because they look awful.

The other thing I need to do is manage the different exceptions an OBJ file could throw at the loader, so far this is limited to normalized obj files (triangulated non-index-negated faces with normal and uv information) I may not try to fix these files as Maya or Blender can easily normalize them and to be honest I don't see the point, but what I do want to try is resolve the way maya send the group information regarding the hierarchy of a group.

This image is of a model that has 9 different materials (with different textures) applied to:



Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/18

12/07/18 Multiple Materials

I now have multiple materials for a single object and that is working great, every face is rendering with its correct material properties, and textures, there is just one small problem, I'm leaking memory like there is no tomorrow.

I'm creating new buffers in the device for every group in the model for every material... every draw call... yes I know...

this is the line:
HRESULT hr = g_pd3dDevice->CreateBuffer( &bd, &InitData, &g_pVertexBuffer );

It would be great just to swap the buffer I need, I just don't know how right now and I need a break, aside from that the program looks great and looks like this:


I think I have an idea but I'll work on it tomorrow.

--------------------------------UPDATE-----------------------------------
I know i said I was leaving about 40 min ago but.... It seems that the only thing I was missing was releasing the buffers with their awesome ->Release() method, I don't leak memory anymore =D

Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/17

12/07/17 Materials

I've successfully manage to create different materials for the faces, each face has its own color component based on the colors of the materials they have applied. Not the problem is that I don't know how to discriminate if a face has a texture applied or not,  right now this renders all faces with the first material's texture, therefore if the face 2 has a different material it will multiply its color to the texture of the first, if it doesn't have a texture all faces will have their correct colors without textures, and so on.

So what is next is to load more than one texture and then discriminate if a face has a texture, and if it does apply its corresponding texture, not only the first material's.

First material have texture applied

First material does not have a texture


Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/16

12-07-16 Materials and Textures

There was an unexpected bug on last backup that was fixed today, the lesson: Remember to  add a +1 to your string buffers for that finish character and the first element of your array is 0 not 1....

Anyway after solving that, Im successfully reading the MTL file from the OBJ so I have an array of materials, all the triangles are being drawn with the first material though, but I'll work on that tomorrow.

So far this thing renders 100% correctly models that are triangulated and that have only one material, and that material is a texture.... Not very impressive, I know, but its doing it in DirectX and that is a super jump for me right now, lol.



Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/13

12-07-13 So... whats new?

Yeah... today was one of those days that I worked nonstop for hours and hours but the results are nowhere to be seen, some of the things I can remember from today's work:

MyString now converts from Unicode to ANSI and the other way; inits for OPENGL and DIRECTX are more clear (for me at least); a new Materials library based on BTO3 for DirectX, Structures reorganization,
more classes definitions and... stuff.

I need to rest, been here from 8am without food, that's no fun =|

Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/12

12-07-12 - Loading Models in DirectX

Finally the program is loading models and displaying them in DirectX, right now the thing is only displaying a single texture per model and only a single model per run, but still I don't have hard-coded models anymore, say good-bye to cubes.

This is only loading normalized obj files so far (triangulated, with uv and normal data, without groups and materials) and no animations whatsoever as I still don't really know how to create a proper buffer for indexes and other stuff,



Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/10

12-07-10 Lights with shaders


Continuing with the work i have from yesterday I've successfully apply lighting from 3 sources to the scene based on the 6th Directx SDK tutorial and Rastertek tutorial # 9 (http://rastertek.com/dx10tut09.html).

In this scene we have Ambient light set as a gray
( 0.1, 0.1, 0.1, 1.0)
a red light rotating arround X
( 0.5, 0.0, 0.0, 1.0)
and a green light rotating arround Y
( 0.0, 0.5, 0.0, 1.0)

These lights affects the triangles that are facing them (calculated by normals) according to its color, the neat stuff is that once both meet they cast a yellow light. as one would expect from real lights :D



Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/09

12-07-09 Getting closer

I'm already late with my schedule (for the day and for the qtr) but I manage to get this working now in directx 10, and I dont have the time right now to make a full entrance, still here is the image



Yo soy Alberto y ese ha sido mi post. Happy Codding!

2012/07/01

12-07-01 Tutorial 7

Its been a slow week, but I'm already on tutorial 7, this is the last tutorial of the basic ones, next stop is the introduction to DXUT, and with that meshes and advanced techniques.

So far I'm able to understand basic lighting and Texture Mapping in DX10.


Yo soy Alberto y ese ha sido mi post. Happy Codding!