# Texture Shader for Generating Textures
There was a discussion recently on our forum (in the topic [HLSL] Przekazywanie struktury ?!?) about shader performance and execution time of texture fetches versus arithmetic operations. When we need a sophisticated function that involves many costly computations in a shader, sometimes it is better to prepare a special texture to be sampled as a lookup table for values of this function. But how to generate such texture?
Of course you can write a simple console program, create Direct3D device of type D3DDEVTYPE_NULLREF, create a texture in the D3DPOOL_SCRATCH pool, fill its pixels and finally save it to a file. But there is another solution called Texture Shaders. It's not a new shader type introduced in DirectX 10/11/... It actually exists for quite a long time and is available in D3DX for generating textures with a shader. Such shader is always executed on CPU. If you are interested, look at functions D3DXCreateTextureShader, D3DXFillTextureTX and the ID3DXTextureShader interface.
Another good news is that you can utilize Texture Shaders without coding any program in C++. All you need is AMD RenderMonkey shader IDE. To generate a texture procedurally:
Here is my example:
Interesting curiosity: there is a intrinsic function in HLSL available only in Texture Shaders - noise, which generates Perlin noise.
# Unusual Devices at Work
One of the best things in having a real job as a programmer is working with unusual devices that cannot be seen in an average house. For example when I worked at Microsoft I've been using a KVM - a device that allows a user to control multiple computers from a single keyboard, video monitor and mouse. At Metropolis Software we had Xbox 360 Devkits - gray boxes a bit taller than normal Xbox 360, which could execute and debug game code developed on the PC. And now in Cyfrowy Polsat we have numerous strange boxes doing different things, like RedRat, which simulates IR remote control.
I'm also dealing with a PDU (Power Distribution Unit). It can supply many devices and outlets can be turned on/off programatically via SNMP protocol. By the way, SNMP (Simple Network Management Protocol) is a UDP-based protocol for monitoring and controlling devices connected to a network, such as routers, advanced switches, printers etc. It looks like a hierarchical "property grid" with variables of different types (like string or number), which can be queried and set. There are many client applications, both free and commercial - just look at the list at SNMPLink.org portal. When it comes to libraries for programmers, I've found free Net-SNMP for C and SNMP++ for C++.
# Sockets and How to Learn Them
Everyone who wants to code transferring data across a network has to learn the concept and API of sockets, no matter if he works in Windows or Linux. I currently work with them again. The most popular tutorial to start with sockets is AFAIK Beej's Guide to Network Programming (and here is my mirror of the Polish translation: [html], [pdf]). I've recently came across another great document: Winsock Programmer's FAQ. I generally like FAQ-s as a good way to start learning about new topic and this one contains many valuable advices. I especially like the article Which I/O Strategy Should I Use? beacuse it explains what ways are available to do asynchronous I/O with sockets under Windows.
Each time I use sockets, I ask myself whether it has to be so much complicated, with all these states, errors, structures, flags etc. I'm afraid it always has to be this way as I've seen many implementations of wrappers and all looked very similar or almost the same as the original. The only way to simplify this API is to limit its functionality or to take it to the higher level of abstraction, like RPC. I believe writing network code is so hard because:
# Mounting Drives and Directories in Windows
You don't have to use only drive letters C:, D:, E: and so on for subsequent disk partitions. Windows gives much freedom in managing drive letters and partitions, if you know how to do that.
First, you can change a drive letter for a hard disk partition or removable disk drive. For example, I like to have my DVD as drive X:. To do that:
Second, you can mount whole partition or drive in an existing, empty directory. To do that:
And finally, you can do the opposite - mount a directory as a separate drive. The way to do it is quite different, as it requires to use a console command:
subst s: d:\Dir\Subdir
To remove such drive, use the following command:
subst s: /D
# Recent Demoscene Parties
There have been several interesting demoscene parties recently. First one is RiverWash in Warsaw, Poland (I have been there by myself :) Next one is Function in Budapest, Hungary. And finally, today was the end of MAiN in Arles, France. After each party it's nice to download prods from compos (productions from competitions) from Pouet.net website (see prods from this year's RiverWash, Function and Main). Demos and intros are worth watching!
Different topic: the new Nvidia Fermi architecture looks very promising. Just have a look at White Paper PDF and watch Next Generation GPU Fluids on YouTube. This architecture is going to be released soon as GT300 graphics card. Intel Larrabee is no longer a revolutionary idea :)
By the way, the whole GPU Technology Conference (San Jose, USA, Sep 30 - Oct 2) looks like an interesting event. I wonder if there will be any papers available for download...
# New Job: Cyfrowy Polsat
Today was my first day in a new job. I now work for Cyfrowy Polsat (Polish digital satellite television provider) in the section that deals with set-top box programming (Sekcja Oprogramowania Dekoderów). I will neither go into details here about why did I leave Metropolis Software and not work in gamedev business any more (for now), nor about what happened in Metropolis Software and the whole CD Projekt (although according to recent news    there are some interesting things happening and I wish them best in their project).
Of course I won't blog about my company secrets, but I think it's not secret that for the start I learn about DVB (Digital Video Broadcast) protocol.