8/8/08

New 4k coming, Nvidia Zero

Real life has kept me from programming for a long time. Fortunately things are sorting themselves out so I have a new 4k coming up (in conjunction with s!p this time). This one is heavy on the shaders and Pohar has challenged me to get 20 shader pairs into a single 4k. So be it Pohar - 20 shader pairs it is ;-).

However, blogs with no useful stuff in them suck so here goes.

Mentor recently pointed out on Pouet that he used the "noise" function for his brilliant Himalaya 1k. Only noise does not work on graphics cards at hardware speeds. He used it in software! This started me to thinking that it would be possible to pre-render cool textures using shaders in SOFTWARE during the pre-calc of a 4k/64k. The idea was simple, write shaders as normal but use the powerful functions that drop back to software (noise, dfdx etc), have them render to a back buffer slowly during the "loading" section of hte product, capture the texture, and then use the textures in real time shaders later.

A simple example:

const char *vsh="void main(){gl_Position=ftransform();}";
const char *fsh="
void main(){
gl_FragColor= vec4(
sin(30.0*length(noise2(gl_FragCoord.xy*0.01)))
);\
}";


Results in:


Great - finally a way to do interesting textures at 4k in very few bytes (assuming you are using shaders anyway).

Only. No. This is OpenGL, not directx texture rendering. Nothing works the way it should. In this case the correct results (as per the GLSL specification) are achieved on ATi. On Nvidia, the rules break and Noise - the key to these textures - returns a big fat zero. This renders (you see what I did there :-) the whole idea useless.

ATi 1 - Nvidia 0.

So, noise on Nvidia cards returns 0 in GLSL. Sigh.

7/16/08

Iss3 - another 4k, while I slept


Real life has prevented me coding for a long time now. But something as simple as not coding shouldn't prevent you making releases. Pohar of Hardread had some of my shader code lying around and, in deadline desperation I suspect, threw it into his new intro and gave me some credits. Inno from Conspiracy did the music and the synth is Pohars too. The 4k came second at SceneCon08 in Hungary.

Get iss3 here.
Requires ps2.0



The video really doesnt do the shaders justice, I recommend trying the original.

Hungarian Television also did a piece about SceneCon demoparty in which the intro in shown. Its 40 minutes of mainly Hungarian but I know quite a few visitors to this page are from Hungary so there it is.

4/24/08

The end of an era: no more 1ks

Well its time to confess. The Riverwash 1k invitro will be my last 1k. I've been doing 1ks for over 2 years now and its time to move on. Thanks to everyone who voted for it and thanks to Riverwash organisers for asking me. Although I said I wouldn't publish code anymore, I can't think of a better way to bow out of 1k coding than to publish the last one so you can download the code here.

I hope in the last 2 years, my efforts at 1k and my publishing code have encouraged and enabled a few people to get going with 1ks.

4/16/08

Chip Magazine



Today Chip Magazine was released so I can finally put an image here from the magazine. It basically says that the 1k intro collection by auld (me) is on the DVD together with some coding frameworks.

If you find your way here from reading Chip and are completely confused about the demoscene or how 1k intros are developed, I have set up an email address to contact me:

auld67 .at. gmail.com

You should also know that the framework included is old and non-optimal as there are license issues distributing the new one which includes a special compressor called "crinkler". So if you get into size coding, contact me and I'll explain how to get set up with crinkler.

4/9/08

Riverwash 1k invitro


I've just finished a tiny (1k) invitro for the Riverwash party as an experiment. It was a real challenge to squeeze in all the usual text for an invitro (name, date, place, compos, website) into a 1k and present it in an interesting way. Its no work of art but it does the job quite nicely. I don't know any other invitros of this size so I think its the smallest one ever done.

The concept is very simple: an infinite zoom on text. At Evoke 2006,'Die Ewigkeit schmerzt' by neuro won the demo compo using a version of this technique. Neuro and Farbrausch then won Breakpoint 2008 demo competition with a very advanced and beautiful version.

Getting it into 1k would have been impossible without the '+' sign. The technique relies on one item being displayed inside another as you zoom. So things have to be carefully placed. However, by using the plus sign, I was able to guarantee a character in an area of the screen that would always be placed correctly for the next text. Its not always necessary (capital P, R and so on do not need it as they have horizontal bars in the right place), but it often is. This simple trick meant I did not need to store text co-ordinates or interpolate as I zoom from one place to another.

Download it here.


Incase you are wondering, the extreme colours are because Riverwash takes place in Poland.

Chip Magazine

Polish Chip Magazine will be publishing all my 1 kilobyte intros in next months edition (available from 16th April). The good ones and the bad ones!

3/30/08

Raytraced spheres (again)


The image here shows a snapshot of an animation through a cloud of 40,000 raytraced spheres. I was able to get 2.6million raytraced spheres per second from an x1900, 2.2 Ghz core duo PC at 1024x768 resolution. In fact, the rate was limited by the host PC. The method used was to render a quad billboard for each sphere and send a single spheres details (centre, radius) to the raytracing shaders using a glColor4f call. Sounds odd, but it saved on extensions code. The billboarding is calculated by hand, as it were, on the host and each quad uses four glVertex calls. Switching to submitting a vertex buffer and calculating the billboarding in a vertex shader would probably speed things up but as my graphics card is already melting, I gave it a break.

There are no shadows or reflections so technically this is raycasting only. Nontheless seeing 40,000 perfectly shaped spheres (even close up) drifting by, is quite a joy. I also went to the trouble of uploading camera co-ordinates to the shader and created a free roaming camera - all my raytracing so far has been from a fixed point of view.

One last point, look at the picture and you can see spheres intersect. This is because the z value output in the shader is not the z-value of the billboard but the real z-value of the sphere. This shows that the image isnt constructed from a simple point sprite system or a particle system using texture mapping but uses real raycasting on each sphere.

The spheres are per-pixel lit and bump-mapped. Click on the image for a larger version.

3/16/08

Shader Programming is Bad for your Health

Well OK, the health of your PC graphics card. Here is an error message I got from one of my 1ks today:



Click on it to see a bigger version. The fans are fine, there is no blockage. Think I better buy a backup card...

3/14/08

Very small logos for 4k?

There was a topic on Pouet recently of doing logos in 256bytes. I didn't even know this was possible so I gave it a go. The logo below is 183 bytes.


I learnt a few things. Firstly, PNG tends to be smaller than JPEG at this level of compression so PNG is best. Second, I used Paint Shop Pro (can't afford photoshop) and switched on all its optimising and the image was well over 300 bytes. However I then downloaded irfanView and the available plugins for it. One of the plugins is called PNGOUT and its great at compressing.

One thing, make sure you set save chunks to NONE. Heres another example, much larger, and only 227 bytes. Obviously the black helps...



So it would be possible to make a logo for a 4k intro for 150-200 bytes. PNG loading is easy too, simply load the image using d3dx - very few bytes. It can be read into an array and passed to OpenGL textureing if required...at least I hope so - the logo is 1 bit per pixel, I'm not sure how it will appear in memory when loaded. One way to find out...

In more tests, I did 16x16 images to see if texturing would be possible this way. Once you have the code to load a PNG it makes sense to use it as many times as possible. However the file over head is such that even the simplest of 16x16 images is around 100 bytes. So there is no significant advantage in going very small and really any PNG image looks like it is going to be 100-200 bytes as a minimum. At this size it makes more sense to encode the 1-bit bitmaps into the code itself and use GL_BITMAP type for the texture (16x16x1 = 32 bytes).

A couple more tries, close to 256bytes each.

3/12/08

Traditionally Sceners Dont Publish Code

I read that in a scene magazine recently. Since I started I've been publishing code and trying to help people newer than myself to improve. I was naive and thought that was just the right thing to do. Dumb or clever, I shared my code. Some of it useful, most not so much, but I shared it. However, lately its been more trouble than its worth. Actually no, right from the start. I published code then removed it only to receive nasty emails about the removal, as if people had a right to my code. I've had my code ripped with no credits. I've had people contact me very late at night to fix their code and been angry that I don't want to help at midnight. I've helped people as much as I could and then not received any credit. People have been angry at me that I size optimised their code: one guy even seems not to want to share code anymore.

Real-life is enough hassle without all this. So, after a lot of thought, I've decided to restrict this blog to the usual boring stuff like what I am working on and so forth. No more code here: I'll do it the traditional way from now on.

Now Ill just wait for someone to be angry at me because I stopped sharing code...

3/11/08

The Best (sur)Prize!


Well, lifes a bit rough now and then (more sort of now than then) but sometimes you get really cheered up. This package arrived today from Pohar of Rebels. So opening it, I found s cool Rebels t-shirt. I did a couple of 4ks for rebels with Pohar last year, so this is my prize and I have to say - its a good one. Heres a piccie especially for my mates over at Rebels - in my opinion, the group improving most all the time in the demoscene.

Go Rebels!

3/7/08

All my 1ks (1024byte) intros

Again, I published a lot of these under different names but incase there is any confusion, all these tiny intros are my own work. Its clear to see from these that I got better and better: well as a general trend anyway. Its good to see such a progression over the last two years. I'd advise anyone entering the scene, no matter how much experience you have that it will take a few years to get good. I still haven't made a 4k I'm happy with but I do like my latest 1k chocolux. This one turned out well and for once I'm happy. Anyway to the list. They are in (roughly) reverse order, so the most recent one is first.

Chocolux (PS3.0 required)
Comment: Recursive raytracing of spheres.
Personal Rating: 9/10. Colours right! At last 9/10 - one I like.

Labyrinth1k (FAST PS3.0 required)
Comment: Raymarching.
Personal Rating: 7/10. Colours wrong! Camera path and animation synched in 1k isnt bad though. I feel this one is underrated. I can see why though. Slooooow.
Flow2 (PS2.0 required)
Comment: A corrupted mandelbrot set with two merging rendering schemes.
Personal Rating: 8/10. Its really very nice to look at.

Annoying Blue Circle (PS2.0 required)
Comment: A sphere with displacement shader and cool colours.
Personal Rating: 8/10. It works, its fun and has good sound by ampli.

Mandelflow (PS2.0 required)
Comment: A corrupted mandelbrot set with candy colour scheme.
Personal Rating: 7/10. Its nice to look at but not quite as advanced as flow2.

Morpheus (PS2.0 required)
Comment: A sphere with displacement shader.
Personal Rating: 7/10. It works, it has sound and texture.

Trinity (PS2.0 required)
Comment: A sphere with displacement shader and noise.
Personal Rating: 8/10. This is my fav of the matrix trilogy. This one feels like trinity to me. No sound loses it points ut the presentation works very well.

MrAnderson (PS2.0 required)
Comment: A sphere with displacement shader.
Personal Rating: 7/10. The first OGL and shader 1k anywhere!

Ah Bollocks
Comment: A sphereflake (sortof) with a cool animated texture by mind.
Personal Rating: 4/10. I dont like it. Its rough and colours are depressing.

Grail1k
Comment: Curved, animated, 3d models in 1k!
Personal Rating: 6/10. OK it looks rough but curved 3d models gives it points for me.

Scotland the furball
Comment: Fur in 1k.
Personal Rating: 4/10. The fur should animate and its way too slow. Still - fur!

Revolver
Comment: A tenticular monster, animated.
Personal Rating: 4/10. Very low tech but it works ok, the animation is nice.

Hive
Comment: A proper intro (start, middle, music, textures, 3d model, camera move)
Personal Rating: 6/10. It looks rough again (why do I do this) but its got so much in it I have to rate it well.

Abscrapt
Comment: An interpreter language in 1k drawing some abstract rubbish.
Personal Rating:
3/10. Just awful colours destroy this one.
Mus1k
Comment: a real synth in 1k.
Personal Rating: 3/10. It just didnt work.

Hypnot1k (WinXP SP2 ONLY)
Comment: Music, speach, text and graphics in 1k.
Personal Rating: 2/10. My god what was I thinking - the colours - the sound.

Kagazoon (WinXP ONLY)
Comment: Watch your screen spin in 1k.
Personal Rating: 7/10 the first time. 5/10 thereafter. Its not bad looking but its a gimmick.

Rad1kal
Comment: 6 or seven scenes in 1k!
Personal Rating: 6/10. The scenes are too long and a bit ugly but damn thats a lot of effects in 1k! Show me any 1k with even half this many scenes.

Debut1k
Comment: A texture gen engine in 1k.
Personal Rating: 5/10. Not bad, not too ugly. Texture gen in 1k is not so easy.


Phew I think thats all. These days even a 1k takes me more than a month to find a good idea and nail it so it works on Nvidia, ATi and fits inside 1k.

3/6/08

My 4ks

I thought it was worth listing all my 4ks so far here. Not all credits in files say Auld. Thats because I liked to use different names to publish code under. These days I only use Auld.

Spheres Dream
.
Requirements: PS2.0, OpenGL 2.0
Comment: Done for Rebels demogroup. Voted best Mac intro of 2007. Second at Function 2007. Mellow, dreamy, spherey.
Credits: Auld (code and design), H20 (design), Pohar (synth), Vincennzo (music).

Fruit of the Loop
Requirements: PS2.0, OpenGL 2.0
Comment: Done for Rebels demogroup. Second at Kindergarten 2007. A bit weird.
Credits: Auld (code and design), Pohar (code and synth), Vincennzo (music).

Inferno.
Requirements: OpenGL 1.4
Comment: Done for Titan demogroup. Winner Evoke 2006 4k intro. Dantes trip to Hell, re-interpreted and set to hard music.
Credits: Auld (code, synth, design), Saida (tools, synth), Strobe (music), Alien^pdx (design)

GS
.
Requirements: OpenGL 1.4
Comment: Done for MUPS demogroup.
Credits: Auld (code, synth, "design" :-)), Saida (tools, synth), SOR (nfo file), ampli (music)

Halls o' Halloween
Requirements: OpenGL 1.4
Comment: done for DBF Halloween competition 2006. Won 1st place. Lots of geometry for 4k.
Credits: Auld (code, synth), Saida (tools, synth), Ampli (music)

3/1/08

To Vertex Shade or not to Vertex Shade

The GLSL specification says that it is legal to create a shader that has one instance of a fragment shader and no vertex shader. Under these conditions, the default vertex pipeline should run. This worked on Nvidia and ATi - sort of. ATi allowed it but did not set up gl_FragCoord correctly - effectively making the fragment shader useless. In other words, it didn't work.

However, on Feb 13th 2008 ATi released new drivers which cured the problem. So its now possible to write tiny glsl code without a vertex shader.

Only tested for sure on x1950 so far but will test on other cards soon...

2/26/08

Chocolux 1k intro

Chocolux is a real-time recursive raytracer using four spheres. Lighting and intersections are all approximated to fit the 1024 bytes boundary. I used crinkler 1.1 for compression. The executable can be downloaded at Pouet or Intro Inferno. For those with no PS3.0 card is a video:



The code can be downloaded here.

Probably the best space saving trick in the code is:

t=GetTickCount();
glRecti(t,t,-t,-t);


This allows the time to be passed into the shader without either using glGetProcAddress calls for the extensions or using glColor3f which is smarter but still not as good. So long as t is bigger than 1 (it will be as GetTickCount is a millisecond counter from boot time of the PC) the screen will be drawn and the value of the vertex can be used for the timer.

The recursive raytracer is no use to anyone outside this code as the maths is corrupted to give a more detailed image and smaller bytes. However, Pohar found a trick worth mentioning. The nested loops in the fragment shader both use i as the variable (rather than say i and j). This allows crinkler to really go to work and compress this code down. Its legal in shaders and, I'm told, C too.

One other byte saving trick I haven't seen anywhere else is I have no background test in the code when rays do not intersect objects. Normally this would be an if and some calculation to assign colour for the background. Instead, I place the scene inside a sphere so I know the ray will always hit one object. This also adds a lot of visual complexity to the scene.

There are pragma statements like:

#pragma data_seg(".shad2")
.
.
.
#pragma code_seg(".compile")

scattered through the code. These are to assist crinkler as it may reorder the code more, saving here, 6 bytes. These are placed just before data and just before every function and the main entry point.

2/17/08

POVRay 2008 Short Coding Compo Results

All I can say is wow, some of these animations are amazing. Congrats to all the winners. My personal favourite is second place. It lacks a little of the visual artistry of the winner but the technical aspects are amazing. Shaking camera, explosion of light, nuclear cloud. Animated. IN 512 bytes? Awesome work. The idea to use a sphere instead of a sky sphere so the sky glows for an instant when the explosion happens is really inventive.

Wada updated


I finally got around to fixing the colours and fixing the distortion in the wada fractal. The wada, as a reminder, is a non-self similar fractal formed by placing four reflective spheres touching each other in a kind of pyramid. Although I didn't size crunch, I guess the whole thing would be sub 1.3k. Its hard to crunch it as the wada is very sensitive to things like ambient, diffuse and specular contributions so a full raytracer has to be implemented, not just a fake approximation.

I'm rapidly coming to the conclusion that there are a range of interesting special effects available with very simple, recursive, raytracing. I won't publish code yet as likely I'll do a 4k using some of the tricks I'm working on. The point is, the wada would be very hard for traditional polygon rendering to do. The reflections would be too hard to achieve accurately. So, tiny raytracers should concentrate on lots of reflection and refraction instead of doing a range of simple primitives (sphere, cylinder, planes etc) and using you bytes this way is a mistake. Such scenes are unimpressive.

Add to this the possiblity for traditional 2d post processing (blur, depth of field, glow) on top of raytracing and there is definitely room for overcoming the "spheres on chequer board" factor.

The wada images above can be clicked on for larger versions. They are real screen captures from a real time wada renderer. Hence the larger images have some artefacts. A small blur post-processor shader will overcome this.

2/11/08

Helping Crinkler

There are two things to understand about crinkler that can help. Crinkler replaces your linker which means it has access to sections of code and data when linking. It can re-arrange these sections to achieve more compression. Even more, crinkler uses two different schemes for compression: one for code and one for data. The Crinkler manual talks about defining data and code blocks in assembler. However, its possible from C too.

#pragma data_seg(".name1")
#pragma code_seg(".name2")

The pragma statements can be and should be used just before every chunk of data and every new function. Any names can be used but meaningful ones are useful when Crinkler outputs its report.

1/17/08

POVRay short code contest now on

The 5th POVRay short code contest is running. I'm not entering this year but here are my entries from last year, complete with code. I didn't win but had a lot of fun trying.

The Cave:




#macro A(f)finish{reflection{,f}} #end
union{plane{z,20}normal{wrinkles}A(2)}union{sphere{z*22-3,5}A(1)}
union{plane{y,-3}normal{agate.3}A(1)}sky_sphere{pigment{agate scale 3}}


X-Ray:




#macro A(f)cylinder{<9*sin(f),6*cos(f*f),6>,,1,2} #end
union{
blob {A(4)A(5)A(8)A(9)A(0)A(1)A(2)}
pigment{wood}
finish {reflection{,6}}
}
sky_sphere{pigment{wrinkles}}

11/21/07

Another 4k Finished.
















Using the latham and kaleidoscope shaders, I've done another 4k. This was done with Pohar (code) and Vincenzo (music) of Rebels. You can get the executable here. It requires ps2.0. There is a final and a party version with wildly different colours. The key pieces of code are already on this blog further down. Hope you enjoy it.