Wednesday, February 13, 2013

Killing bugs!


I've been having small pixel errors in the shader while converting colors, and this piece of code fixed it finally, took me a few weeks to find this bug, still not quite sure why my values went over the limits but the commented code didn't do it before.

h += 360 * (-floor(h / 360.0));    // convert to absolute 0 to 360 degrees
//if( h < 0 ) {
//    h += 360;
//}
//if (h > 360) {
//    h -= 360;   
//}


pretty happy that I was able to find the issue and fix it in 10 minutes while testing the shader editor, I didn't see that bug until I used the real time capabilities to get instant feedback, trying to do the same in Visual Studio and XNA directly in HLSL is very complicated since I am not an expert in shaders yet and takes forever to see something on-screen.

Updated development video - shader and palettes editor


Finally I was able to make some time and published a brief short video showing up the shader editor I made during the last weekend to help me fix more shader coding bugs that I had for a few months and was taking a lot of time to debug. Also the color palette manipulation in the framework, color palettes is something that is not available with modern hardware but necessary for 2d games, so this is just an example of a color palette manipulation and how to take advantage of it to reduce the memory footprint by reusing textures and by changing a few paremeters you can change how your character looks in-game. The shading layer can also be manipulated while in game to adjust the shade strenght and I am thinking if I should enable shading coloring at this stage.

Now with the shading layer working and most of the framework working, it is time to redo all the animations of the game using this new platform!

Monday, February 11, 2013

Shaders! let's break the cycle

Shaders do make things come to life in the 3d and 2d, but it is quite challenging to have a Jack of all trades do it all platform that can help write good shaders since shaders are usually tied to game engines. I tried Nvidea and AMD solutions plus a few others without much luck.
So the cycle continues, I've been trying to improve and fix my shader for the past month, and still I haven't been able to properly finish it, it works but the quality I am looking for is still not there, it takes quite a lot of time to write a good pixel shader, especially when it takes some time to think and write code without knowing fully the syntax, try to compile it and get some syntax/coding errors, fix them and then again compile the shader, then compile the game editor or game viewer to test the result, if it doesn't works I have to go back and modify the shader, every single test takes from 3 to 5 minutes with a few more minutes of waiting for the compiler to finish plus review the outputs so it takes around 10 minutes for each test. I think I wasted too much time waiting, so what do you do when you can't find something that you need? well... I usually do something for myselft when something like that happens, and I wrote one for myself, and spent this weekend doing it, just a day and a half and I just made a realtime shader editor/compiler so no more wait! no more trying to find a tool that can handle my needs of mixing textures and many other things that I was looking for, now the sky is the limit! and here I go!.

I will post some videos of the real time shader editor with the new code for palette color handling soon! I am quite excited by the results of this week and looking forward to fix the last ones at the shader level.

Saturday, February 2, 2013

Speed! Speed! I need to be faster...

This was a very difficult week, I was able to finally integrate and run the Mystic framework in XBOX360, finally!, and I was expecting to spend most of this week trying to improve performance of the framework, but after so many tries, it seems that XBOX doesn't have enough horse power to deliver all real time calculations I have in the framework as fast as I was expecting, sometimes I had constant framerates and sometimes from no where dropped quite a lot even in Windows.

I got stuck for about 2 days just optimizing the code as fast as I could and still enjoying the real-time calculations, but finally found a road block and couldn't find a way to improve it more, so now step 2 is to start caching values and make sure that the animations run perfectly. Luckily, I came up with many last minute optimizations and a few more are still in my mind, but I am getting now solid 60 FPS in-game even in XBOX, and this is without using multi-threading in the animation modules, when I added the multi-threading support I started getting even lower framerates from time to time, due to the local variables created per thread, so sometimes caching and re-using the same variables can really help improve the speed of the calculations but makes it impossible for some threaded blocks of code, specially for vertex calculations since I am not using the GPU at this moment for that due to the physics calculations per vertex. I will publish a video of the framework running in-game pretty soon, and it is working very nicely.



Just a quick screnshot, the character in the middle is being rendered using the Mystic Framework, the others using the old skeleton model, I will post a video of the small details achieved with the Mystic Framework animation tool.

Still need to investigate why in XBOX the color replacement technique is not working in the same way as in Windows, but in this case the color of the character in the middle was dynamically changed to green/blue for testing.