Jun 132013
 

I hadn’t been to Cheltenham Science Festival before so last Friday I popped down for the day. I went to half a dozen presentations so here’s a summary of the interesting bits.

Eight Great Technologies

This was a talk by David Willetts, the Minister for Universities and Science, giving us reasons to be optimistic about the future of technologies, science and industry in the UK. Despite what the doom-mongers claim there are still loads of things that we’re good at in the country, and he talked about eight key areas where we shine:

  1. Computing and big data – we have excellent software engineers in many related industries (although I believe we need to do much more to encourage young people into programming), alongside smaller important projects such as the Raspberry Pi.
  2. Space and satellites – the UK is a world leader in making small satellites, and while we don’t have our own launch facilities, companies like Virgin Galactic are pushing further into the commercialisation of space.
  3. Robotics and autonomous systems – the new ESA Mars rover, Bruno, is developed using British technology, and will have much more autonomy than the existing rovers. Also interesting is the Symbrion robot ‘swarm’, developed in large part in this country.
  4. Synthetic biology – we have history in this area of developing gene sequencing and assembly technologies, and the existence of a unified NHS allows for more integrated ‘big data’ approaches to gene analysis and treatment evaluation.
  5. Regenerative medicine – from the original work on Dolly the sheep, we are now pioneering research into restoring lost body functions, for example the stem cell treatments for Jasper the paralysed dog.
  6. Agri-science – 80% of the world’s breeding chickens are designed in the UK, and now give twice as much meat per food as 20 years ago. Similar advances are being developed (and increasingly required) to increase wheat yields and reduce chemical use.
  7. Advanced materials and nanotechnology – from graphene to 3D printing, materials are a massive UK export industry (more about this in the next talk).
  8. Energy and storage – I think this is the most important technological legacy we should be funding and building on in the near future, so that we maintain our past expertise in nuclear and renewables.

Overall I was impressed by the Minister. I didn’t have any of the usual sense of frustration or brain-dissolving that I usually get when listening to politicians speaking, and despite not having a science background himself, he seems very able and keen to listen and learn. While it seems obvious to everyone in the field that many wide areas of science should get a lot more funding, I think that the focus on and support of key areas is probably a good compromise between results and political will. In particular, the derogatory remarks he kept making towards the Daily Mail and their ilk regarding their scare stories and general stupidity (my words but the general gist) reassured me that he has his head screwed on and that science in this country isn’t doomed yet.

A hare and a minotaur (I have no idea why)

Is The Age Of Silicon Over?

Next up was a talk on new materials, with three guys talking primarily about gallium nitride, graphene and metamaterials and photonics, respectively.

Gallium Nitride

Gallium nitride is a material with a wealth of possible applications. One common use at the moment is in LED lighting, where it is combined with indium to creates high brightness LEDs, and the wavelength of light (therefore the colour) can be controlled by the amount of indium used. Unfortunately, these GaN LEDs can only currently be fabricated on sapphire and are therefore very expensive to produce (hence LED bulbs costing £15 a pop). They are very efficient though, and have the potential to save 50% of the energy used in lighting, which makes up around 20% of the total UK energy use. New manufacturing techniques using silicon substrates instead of sapphire are being developed, and this should lead to a large reduction in cost and a much wider update of LED lighting.

Another really interesting use is that by combining it with aluminium instead of indium, you can produce LEDs that emit in the deep ultraviolet part of the spectrum. This type of light is fatal to life on earth, and the idea is that deep-UV lamps could be placed inside water pipes in developing countries where waterborne diseases are commonplace, killing all the microbes in the water at the point where it enters the home. A similar potential use is in air-con units to kill the recirculating bacteria.

A final use is that GaN is 40% more energy efficient that silicon when used for computing, thus leading to even more energy savings (another potential 5% off national consumption).

Graphene

Graphene was in the news a few years back when Kostya Novoselov and Andre Geim at the University of Manchester won the Nobel prize for its discovery. Since then it’s all gone a bit quiet in the mainstream press but this ‘miracle material’ will likely still cause a revolution in many areas.

It is 100 times stronger than steel, harder than diamond, very conductive, 98% optically transparent and impermeable. The possible uses talked about were in flexible electronics (e.g. bendable screens), wearable computing and supercapacitors, where the tiny thickness enables huge surface areas to be contained in a small space. Another use is in very accurate sensors, but I didn’t really understand the specifics (seems to be to do with the change in Hall voltage when a single sheet of graphene comes into contact with even single atoms of the thing being measured).

Photonics

Photonics is to do with processing and manipulating light. I have to admit I didn’t really take in anything that this guy was saying, save that optical computers are still a long way off and we’ll have to stick to electronic computers for the time being.

The festival venue

 Quantum Biology

With a title like this I couldn’t not attend, even though I didn’t really know what to expect. Executive summary: this is a very new field looking at quantum mechanical effects on and used by biological systems. And nobody is really sure how important it is.

The general principle is that classical physics works when you have loads of atoms or molecules, because all the quantum variations cancel out. However, down at the level of DNA and some cell biology you’re dealing with individual molecules, and therefore you may have to take quantum effects into consideration.

The problem with quantum biology is that to get observable quantum effects, you need coherence. For example, the double-slit experiment gives an interference pattern, showing photons behaving as waves, only when the you use a coherent light source such as a laser. In the warm and wet world of biology, being able to maintain coherence for long is challenging.

There are currently three main candidates for quantum effects – photosynthesis, sense of smell and magnetic sensing in birds. The most well-developed theory is with photosynthesis where it’s hypothesised that the electron transfer is made more efficient by quantum tunnelling – the tunnelling destinations are defined by the peaks in the interference pattern of a coherent source, similar to in the double-slit experiment.

There were some thoughts about consciousness being a result of quantum effects – the opinion being no, as thought is far too slow and the brain is too big and complex (all other observed quantum effects are between one or two molecules only).

One of the presenters, Paul Davies, finished up were some of his more ‘wacky’ (in his own words) theories. Did quantum mechanics facilitate life to begin with? Quantum superposition can enable rapid exploration of a vast number of arrangements of matter, and if a self-replicating state is in some way selected for, this could vastly reduce the search space. There is more about this in chapter one of his book.

Camera phones don’t work well in the dark

Particle Physics and Energy

These two talks weren’t presenting anything new, but were entertaining and fast-paced introductions to particle physics and the Standard Model, and the concepts of energy respectively. The Particle Physics talk went through 100 years of scientific progress, from the initial discovery of the atom to the Higgs boson, and our understanding of what all matter is composed of. The Energy presentation started with all the different forms energy can come in (kinetic, potential, sound, chemical etc) and how most of these are different forms of the same thing, before bringing in Einstein and the energy of empty space, and finishing with some brief words on the Casimir effect, negative energy and wormholes.

These were good fun but I think next time I’ll benefit more by heading to talks on subjects that I’m less familiar with, as they usually seem to pitched at a scientifically-literate but definitely non-expert audience.

I found the Portal facility

Famelab Grand Final

This session was well worthwhile. Famelab is an international competition to find the next generation of young science communicators. Contestants have three minutes to do a talk on an interesting scientific topic, but in as entertaining and engaging way as possible. All of the presentations were really good, and the winner was Fergus McAuliffe from Ireland, who you can see here talking about freezing frogs:

Another entertaining one was Christopher See from Hong Kong, talking about probabilistic medicine:

The rest of the talks are all up here as well.

Overall it was a very enjoyable and worthwhile day out, and I’ll definitely be going back next year.

Jun 082013
 

Hardly anyone I know shares my taste in music. To potentially help alleviate this I present a selection of great female-fronted bands who aren’t as well known as they should be. (Looking back at my selection it would appear I mainly like musical duos and singers with red or black hair…)

Anyway, in no particular order:

1. Helalyn Flowers

Helalyn Flowers are an Italian duo who I randomly stumbled across a couple of years ago, and are now one of my favourite bands. They have a very catchy melodic electro/goth sound, and you can hear a bunch of their stuff here.

They have three albums out, A Voluntary Coincidence,  Stitches Of Eden and their recently released White Me In / Black Me Out. The new one hasn’t quite grown on me yet so I’d have to recommend Stitches Of Eden as the best one. Standout tracks for me are Hybrid Moments and Friendly Strangers.

Hoping they’ll make it to the UK one day, but I suspect that’s unlikely.

2. Indica

Indica are a Finnish all-female melodic rock band with some classical influences. They have one English album, A Way Away, which is well worth a listen. My favourite tracks are Precious Dark and Islands of Light:

 



Apparently they have a new album out soon, so I’m looking forward to that. I need to get hold of some of their earlier material too.

3. I:Scintilla

Something a bit more industrial this time. I:Scintilla come from Chicago and have been going for over a decade. They have a couple of great albums in Optics and Dying & Falling, for when you’re looking for something with a harsher sound and a bit more energy.

Swimmers Can Drown is from Dying & Falling:

My recommended tracks from their previous album Optics are The Bells and Melt.

4. L’Âme Immortelle

L’Âme Immortelle are an Austrian duo with a French name who sing in a mixture of German and English. Lyrically they can be a bit cheesy but on half the songs I don’t understand the language so I let them off. They used to be predominantly synth-based, but then they moved into more traditional rock territory which I wasn’t so keen on. Therefor my pick of their albums would be a couple of their older ones, Gezeiten and Als Die Liebe Starb.

They have a playlist here, of which I recommend Judgement, Tiefster Winter and 5 Jahre.

5. Collide

Slowing the tempo a bit, Collide are an American duo who mix stark electronica with ethereal vocals and Eastern influences. They have a few songs here, and I Halo and their cover of White Rabbit.

For albums, I’d probably go for Chasing the Ghost or Some Kind of Strange.

6. Hungry Lucy

Winning the award for most bizarre band name is Hungry Lucy. They are another American duo and have been around for fifteen years now, writing haunting melodies alongside some more upbeat grooves. Their entire catalogue is available to stream on their website.

To Kill A King is my album of choice, although it was Alfred from Apparitions that first made me curious about the band.

7. Emilie Autumn

Emilie Autumn styles herself on a Victorian asylum aesthetic, mixed with elements of industrial music, so you can expect violins, harpsichords, synths, guitars and drum machines, presented with elements of caberet, burlesque and some humour.

Recommended tracks are Opheliac and Fight Like A Girl, while Thank God I’m Pretty and Girls! Girls! Girls! have good use of comedy to make a point. Opheliac is my recommended album overall, and the live shows are good fun (she’s touring the UK later this year).

Jun 042013
 

The last basic rendering technique to talk about is shadowing. Shadows are really important for depth perception, and are vital for ‘anchoring’ your objects to your world (so they don’t look like they’re just floating in space).

Shadowing is a very popular topic for research, so there are loads of variations on how to do it. Years ago you could just draw a round dark patch at a character’s feet and call it done, but that doesn’t really cut it these days.

Blob shadows

Shadows are usually implemented using a technique called shadow mapping. To go right back to basics, you get shadows when the light from a light source (e.g. the sun) is blocked by something else. So if you were stood at the sun (and assuming no other light sources) you wouldn’t see any shadows, because you would only see the closest point to the sun in any direction. This fact is the basis of shadow mapping.

Shadow map texture

What we’re going to do is draw the scene from the point of view of the sun, into a texture. We don’t care about the colour of the pixels, but we do care about how far away from the sun they are. We already do this when drawing a depth map, as I spoke about here. Because we need to use the shadow map when rendering the final image, we need to render the shadow map first (at the beginning of the frame).

There are considerations when rendering your shadow map that I’ll get to later, but first I’ll talk about how we use it. Here is the final scene with shadows that we’re aiming for:

Final scene with shadows

And this is the shadow map, i.e. the scene as seen from the light (depth only, darker is closer to the camera):

Shadow map rendered from the light source

When drawing the final image we use ambient/diffuse/specular shading as normal. On top of that we need to use the shadow map to work out if each pixel is in shadow, and if so we remove the diffuse and specular part of the lighting (as this is the light coming directly from the sun). To work this out we need to go back into the world of transforms and matrices.

Rendering with the shadow map

When I spoke about view matrices I introduced this, which is how the basis, view and projection matrices are used to get the screen position of each vertex in a model:

FinalScreenPosition = BasisMatrix * ViewMatrix * ProjectionMatrix * Position

If you remember, the basis matrix will position an object in the world, and the view and projection matrices control how the camera ‘sees’ the world. In the case of shadowing, we have two cameras (the usual camera we’re rendering with, and the one positioned at the light source). The other thing we have is the shadow map, which is the scene as viewed with the second camera at the light.

To perform shadowing, we need to find exactly where each pixel we’re drawing would have been drawn in the shadow map. So, when transforming our vertices, we need to do two separate transforms:

FinalScreenPosition = BasisMatrix * MainViewMatrix * MainProjMatrix * Position
ShadowMapPosition = BasisMatrix * ShadowViewMatrix * ShadowProjMatrix * Position

The first tells us where on the screen the vertex will be drawn (X and Y positions, and depth), and the second tells us where in the shadow map it would be drawn (again X and Y positions, and depth). Then in the pixel shader, we can perform a texture lookup into the shadow map to get the depth of the closest pixel to the light. If our calculated depth for that pixel is further away then the pixel is in shadow!

One problem you will have is shadow acne. When you’re rendering a surface that’s not in shadow, you’re effectively testing the depth of that pixel against itself (as it would have been rendere into both the shadow map and the final image). Due to unavoidable accuracy issues, sometimes the pixel will be very slightly closer and sometimes it’ll be slightly further away, which leads to this kind of ugly effect:

Shadow acne

Because a surface should never shadow itself we use a depth bias, where a small offset is added to the shadow map depths to push them back a bit. Therefore a surface will always be slightly in front of its shadow, which cures this.

Rendering the shadow map

You need to take some care when deciding how to draw your shadow map – exactly as when you’re drawing your scene normally, you could point the camera towards any point in the world and your frustum could be any size. Also, you could use any sized texture to render into. All of these things affect the shadowing.

Let’s start with the easy one, the resolution of the texture. A small texture won’t have enough resolution to capture the small details in the shadow, but a large one will take a long time to draw, affecting your framerate. You might go for a 1024×1024 pixel shadow map, or double that if you want high quality.

The effective resolution of the shadow map is also affected by how wide a field of view you use when rendering it – if it’s very zoomed in then you’ll get a lot of pixels per area in the scene, but you won’t have any information at all outside of that area (so you won’t be able to draw shadows there). Therefore you need to pick a happy medium between high detail and a large shadowed area.

Cascades Shadow Maps

There is a way to get around the problem of having either detailed shadows or a large shadowed area, and that is by using a technique called Cascaded Shadow Maps. This just means that you use multiple shadow maps of different sizes. Close to the camera you’ll want detailed shadows, but further away it doesn’t matter so much. Therefore you can draw a second, much bigger shadow map (that therefore covers a much larger area) and when rendering you check whether the pixel is within the high detailed map. If not, sample from the lower detailed map instead.

This scene is showing how a cascade of two shadow maps can be used. You can see the blockiness caused by the lower detail map on the blue part of the box, but it enables the shadows to be rendered right into the distance:

Cascaded Shadow Maps – red is in the high detail map, blue is in the low detail map, green is outside both maps and not shadowed

You don’t need to stop at two shadow maps – the more you have, the more detailed the shadows can be in the distance, but the more time you have to spend drawing the maps. Three maps is a common choice for games with a long draw distance.

Filtering

One of the biggest problems with shadowing is filtering, or how to get soft shadows (which I talked a bit about here). The shadows we’re drawing here are hard shadows, in that each pixel is either fully in or out of shadow, with a hard edge in between. In the real world, all shadows have some amount of ‘softness’ (or penumbra) around the edge.

With standard texturing, you can avoid hard-edged pixels by blending between all the neighbouring pixels. This lets you scale up textures and keep everything looking smooth. Or you can not, and you get Minecraft:

With and without texture filtering

This doesn’t work with shadow maps. Using a shadow map always gives a yes/no answer: is the pixel further from the light than the shadow caster. Using texture filtering on the depth map between two pixels at different depths give a depth somewhere in between. It will still only give you a yes/no answer, but it’ll be wrong because it’s using some unrelated depth value. Instead, you have to use a more complicated method.

There are vast numbers of ways to do nice soft shadowing, so I won’t go into them here apart from to mention the simplest, which is called Percentage Closer Filtering (PCF) [one thing I find is that most graphics techniques have long and complicated sounding names, but they’re usually really simple]. With PCF, instead of doing a single shadow test, you do a few tests but offset the lookup into the shadow map slightly for each one. For example, you could do four tests – one slightly left, one right, one up and one down from where you would normally sample from the shadow map. If, for example, three of them were in shadow but one wasn’t, then the shadow would be 75% dark. This gives you some amount of soft shadowing.

Basic 4-sample Percentage Closer Filtering

As you can see it doesn’t look great, but more advanced sampling and filtering can be used to give decent results, and PCF is exactly what the soft shadowing in a lot of modern games is based on.

End of part 1

That sums up my introduction to basic graphics techniques. Hopefully it made sense and/or you learnt something… I will be carrying on with a bunch of more advanced techniques that I find interesting, and hopefully manage to present those in a way that makes sense too!