Monday, 17 August 2009

Little drafts of coding

I had fallen in the deadliest coding inactivity ever. Since my last demo on Breakpoint (that was April or May I think?). But it was a bit of relief from the obsession of coding demos for a while. Although I wasn't in the mood for coding anything else. Though I was making some applications for university studies and other stuff that occupied my time anyways. Funny thing is that between my hobby activities, job and private java lessons to a student, the last one was surprisingly the best coding activity I had. Yep, my job is 70% about picking up phones and teaching or supporting users of our applications and only 30% about coding. Make that 5% because the rest 25% is spend from my side on slashdot, pouet, youtube and blogs.

I got a little inspiration lately. I opened Shader Designer and made a Plasma. LOL! It's always plasma for a start for me. To stretch my coding muscles and remember what I didn't touch for more than three months :). It's nice that with such programms as shader designer you can play with little shaders for fun and then be inspired to open the compiler and try something more serious.

Well it's still 2D. I am eager though to go on 3D. I have some inspiration to try and see how the old 2D software effects will look like on shaders and what kind of difficulties I will go through. I already tried plasma, polar plasma, radial blur and box filter, fractals, etc (those on my first shader demo).

I retried plasma and here I solved some mysteries I had about something. When I wrote the first shader demo it was very slow even in GeForce7 cards. And then I remember masterpieces like Lifeforce claim to be written on a GeForce5600 and running fine on my Radeon 9600 pro. I was wondering, if I write some plasma with only three sines per pixel added and it gets 30fps on my Radeon (when I did the quantum retrofuture demo I didn't had this old card, I had an HD3650 and so I didn't bump into much optimization issues). Which is ok but thinking about the heavy shaders use on demos like lifeforce I wondered how they could do shader demos on such old cards? I also tried something simple: Will the old techniques (sine precalculations, look up tables, etc) give an improvement here? I only had to generate the precalcs and load them in 1D textures. And they did. I got 300fps for the plasma and I got improvements in polar plasma effects too. Of course when running the same tests in modern hardware I notice that there is no difference there. 700fps for both realtime sine version and precalced sine version. So, I solved this mystery question I had, would lut and stuff from the past help to optimize 2d effect shaders for old accelerators? It was even fun to pass a big precalc lut for angles for the polar effect in one 8bit color channel of the texture and then see it's not enough (256 angles only for a big resolution, ugly angle steps) and then pass it as 16bit in two color channels and combined them in the shader for one angle value. Fun oldschool shader stuff :)

I also tried to do the 2d bump mapping and it works like charm but with things like fire effect (and hopefully soon the water effect) there are some strange errors (it doesn't just burn but the blur moves outwards the screen in perspective like a feedback effect and makes some ugly blurry rectangles) that I am not sure why they are happening just right now.

But after the 2d effects I am curious to final move in more serious shader coding on 3d objects, try the simple stuff first (envmap, phong, bump) and thing of more interesting shaders. Who knows, maybe I am working a new shader demo soon. For a little while I was into serious thoughts of cleaning up the code on my last demo framework, improving some things here and there and start working on a new demo. Even though my demo motivation is not very high right now.

No comments:

Post a Comment