Friday, 27 February 2009
It's funny how some seemingly impossible effects would require a clever yet very easy to code trick. It's funny how sometimes a coder with good ideas and a lousy programming language can overcome an unoptimized demo in assembly. I have been watching the demo Basic Instinct on my 386 and it's surprisingly smooth when also considering that it's written entirely in quickbasic. Most of it's effects were based on hardware scrolling and VGA trickery, yet there are some 3d dot routines and plasma effect that is quite good for Quickbasic AND 386.
This demo was the inspiration for me to try some other ideas in quickbasic. The screenshots are from my tests. I could never imagine that I could code fullscreen and full frame rate (with even several CPU cycles left for additional stuff) static mapping animations in quickbasic on my 386, provided the texture is no bigger than 16*16 (which could be much better looking than the tests in the screenshots).
Ok, the trick is simple, color cycling but I have never thought about it before watching an Acorn Archimedes demo on an emulator and while trying something the emulator and demo malfunctioned and revealed to me the trick on a big sphere mapping with small texture of 256 pixels. 256 pixels aka 256 colors. Precalculate a static 3d mapping screen with a tiled texture of 256 pixels (16*16) where each pixel of the texture has a unique color from 0 to 255. Just change the 256 color palette in such a way that would look like the tiled texture was scrolling and wrapping around itself. Handle the 256 colors as 256 unique pixels of the texture. The texture will scroll over the whole static mapping pattern producing the illusion of a real pixel per pixel mapping effect.
In fact, the same concept but with a 4*4 texture (with 16 unique colors/pixels) was used in the 2nd part of the CPC demo Backtro by Overflow. It's just looks and moves better when you have 256 paletized colors. And don't forget Unreal by Future Crew. I always wondered how could that great looking wormhole be so smooth on my 386. Now I know! Cheap tricks? Nah.. :)
Strange as it might seem to you, I had encountered such a great feeling of happiness when these (and even other funny mappings) ran successfully and smoothly on my 386 IN quickbasic. It might be stupid or a waste of time in the opinion of some but I had some great time with this. One of the rare times. As I explained in this pouet thread about my attention deficiency while democoding there are only very few rare times where I am not just coding trivial stuff but am doing some very curious or interesting experiments with coding where my focus and motivation are really high. And later everything drops down. This one was one of these times where I was really productive and happy with the process and the result.
As with shaders. The first time, they were something new for me. Of course I haven't written any real shader code yet. But after having a first good look into something new, I don't have the inital motivation or energy to continue at the same pace. Ok, I have seen how shaders work, maybe I will finish a lousy boring demo for BP but there are a lot of trivial and boring stuff in the coding process that make me lazy or loosing my focus. Unfortunately very little things really motivate me in democoding.
I remember a CPC coder who had coded some impressive effects as previews and they asked him why he doesn't release them in a demo. Because the most interesting and motivating part is over, to make a good effect work and use as much trickery and cleverness possible to optimize it or fake it. Then the most trivial, boring and time consuming parts is to connect all the effects in an actual demo. I can understand him. It's only the social consceous of the scene that asks you to combine your effort into a demo while you know that releasing the effects standalone would be lame or won't receive much attention. Sometimes I adore the quickbasic/freebasic scene where most people release standalone effects (without even good colors/design of the single effect sometimes) and it's all ok or even gets praise. Of course it's not just about the attention, but myself knows that it would be a pitty to throw away some good effects instead of using them in a good demo. Which although is the part that renders my attention span for coding sorter.
Other than that, there is a little progress with my 4k OpenGL intro. I am not sure if I wrote anything about it before but except from the demo for BP I was also planning a 4k. However, it is going so well and there are so few stuff to be done (although I am afraid about the music and also reaching the limits of 4k too early) so that there is a slight possibility I am releasing it at Numerica demoparty (as a remote entry). My brother is going to write the music. He might use Buzzic for that (no time after all for me to try coding music synthesis as I initially wished). And then I hope I will continue with my BP demo (whose project planning and concept has changed a lot in my mind since then, also because the initial concept would need more work for the limited deadline). No screenshots from the 4k here, just keeping it as a surprise :)
And then I wonder, why do we code? :P