Blender / Cycles / Particles / Motion blur artefact fix

A render with lots of particles (baked), using Blender and Cycles. I was getting this peculiar streak artefact right next to the particle emitter:

After a bit of fiddling around, I’ve sussed what’s causing it. The default setting for Motion Blur in Cycles is to centre the motion blur around the frame time: it opens the “shutter” before the frame time, then closes it after the frame time.

So when it’s rendering frame 7 with a half-frame (180¬į) shutter, it’ll actually render the portion of time from 6.75 to 7.25. But it seems that when Cycles reads the particle data from the cache, it only reads the previous frame and the current frame. So the second half of the motion-blurred period doesn’t have the correct particle data to work from.

Easy fix then: choose either Start on Frame or End on Frame instead. Which one to choose will depend on your scene, but it should become obvious when you test it.

Streak artefacts gone! (Phew)

Star Wars: The Force Awakens – atmosphere and evenings

R6AxklN

When I left the cinema, it was this one shot that stuck in my head more than any other. And there were plenty of beautiful, memorable shots throughout the film – but there’s something about seeing futuristic space fighters against a sunset that really resonates with me, something in that shot that elevated the film above other sci-fi flicks.

I think it’s because it’s evening.

Sci-fi¬†always seems to happen¬†at night. Of course a lot of sci-fi happens in space, where it’s always night time; but sometimes stuff happens in the daytime – and when it does, it’s usually bright and harsh and dusty. But there’s something about evenings that’s extremely important to humans: it’s that calm transition, the moment of calming and changing gears at the end of a day’s work, before heading out on the town (or wherever). There’s a whole cosm of human experience tied into the atmosphere that evenings bring.

And the Star Wars films have always used evenings to their advantage. You can be on a planet at the far edge of the universe, a gazillion miles from home, but if you’re watching a sunset (even multiple suns setting), something primeval kicks in and you suddenly feel: this place ain’t so different. Show me a character looking into a sunset and I instantly know and connect with the atmosphere there. I can feel the temperature dropping, feel the anticipation of night falling – but it hasn’t fallen yet. Relief the day’s work is over; expectation of what the night will bring.

SW_binary_sunset

And day and night are such broad textures to paint your scenes with that they don’t really tell you anything much about the time. An EXT. DAY shot doesn’t tell you whether it’s morning or afternoon without adding lots of other visual or scripted cues. Likewise an EXT. NIGHT – it could be 10 at night or it could be 4 o’clock in the morning, but either way, you can’t easily communicate that subtlety in a shot until you start adding other elements.

But evening can be communicated instantly. And they communicate so much human stuff – it’s not just an arbitrary time of day, it’s evening, and that’s a¬†very special, a very human, time, rich in atmosphere.

And boy, how important a single shot can be to a whole film: a¬†single shot can colour your whole experience of a movie. I saw The Force Awakens in the cinema, and now, a year or so later, it’s on the movie channels every other day, and I often have one of the screens on my desk playing it as part of my background noise. So I’ve probably seen 90% of the film about a dozen times… but for some reason I keep missing that sunset shot. I glance up and see Finn and Rey in that temple bar place, then glance up again and they’re in the rebel base, and I know I’ve missed that shot again. Huh. Maybe next time.

Why is that shot so important for me? It’s¬†just some spaceships in the air, after all… but yet it was the shot that brought home the Star-Wars-iness of the story to me. These are stories set in fantastical locations a million miles from my sphere of experience, but show me¬†a character watching the sun setting:

Screen Shot 2017-01-26 at 04.54.18

… and I’m there. I know exactly what it feels like to be there on that strange planet, the air cooling, the day over, the night not yet here. I instantly get it. I’m there.

And now I can watch Luke fly a space ship and blow up a Death Star and do¬†whatever fantastical stuff the script wants, but because we had that shared moment together watching the sun setting, I know he’s just a human like me.¬†His universe and mine aren’t so different after all.

Bike helmet Larson scanner [U]

A friend wants a Knight Rider style Larson scanner for the back of his cycle helmet. Simple enough. Especially now we have intelligent LED strips available, which only need power plus one data wire to drive a load of LEDs.

Note: if you want to do this sort of thing, make sure you understand the dangers of having LiPo batteries close to your head, and take suitable precautions – see the note at the bottom of this post.

But first things first: I knocked out some very quick and dirty code to do a nice scanning effect (thanks Adafruit for the WS2812 library! Doesn’t half save some time) My¬†code is here. Nothing fancy, but it has a nice decay effect, and a gamma lookup table to keep things pretty. Used an Arduino Mega board to do the testing:

russlarseon-001-1

The code works fine, but it needs to run from something a bit smaller than an Arduino. An Attiny85 does just as well (the 45 would probably have worked but I don’t have any): Continue reading

Quick hacker tip: DIY pseudo-BGA

h_solar_monitor_b 4

Man, I hate drilling holes in PCBs. I make my boards with a mill, so it shouldn’t be too hard to swap the V-cutting bit for a drill bit, but I Just. Can’t. Be. Arsed.

And besides, I like making things as small and slimline and dinky as possible.

The little PCB above is a backpack for an LCD. Couldn’t avoid having to drill holes along the top to connect to the LCD itself, but everything else can be surface mounted.

But sometimes you need a way to connect, say, an nRF transceiver, or one of those newfangled ESP8266 WIFI module to your PCB, and they come already fitted with a pin header. And that would mean drilling more holes, and having the module standing off the board slightly. Yuck.

So here’s my hacky approach. First, design your PCB so the pads are on the top of your¬†board, rather than the bottom: we’re going to take advantage of the fact the little transceivers are always double-sided boards, with through-hole plated holes.

Transceiver on the left, my board with its 8 pads on the right:

h_solar_monitor_b 5

First step, get that header off the transceiver. With a blade, you can carefully lever off the plastic spacer tying the header pins together – do it gently, a little at a time, working from both ends of the header.

Then you can remove the pins one at a time nice and easily. Last one:

wireless 122

Next step – with the board held vertically, soldering iron on one side and solder sucker on the other, you can clean out all the solder from the holes:

h_solar_monitor_b 6

Important – when you’ve removed the pins, you need to make sure the now-empty pads on the bottom of the board are tinned with solder; as the header was originally soldered on the other side of the board, they may not be. So give ’em a blob of solder.

Then remove as much solder as you can from the holes. You need it to be as tidy as possible, every through-hole tinned, but as clean as possible:

h_solar_monitor_b 7

Next step: on your PCB, tin all the pads with the thinnest layer of solder you can. Then put a slightly larger blob of solder on diagonally opposite pads. Try and make them nicely rounded blobs, as they’ll act like locating pins:

wireless 125

Which means¬†when you press¬†the transceiver board down in position over the pads, it’ll locate itself perfectly squarely, with all the pads (hopefully) lining up perfectly between the two boards:

h_solar_monitor_b 8

Touch your soldering iron to the two corner pads to melt the blobs and fix your boards together:

wireless 127

You should be able to look through the remaining holes to see whether they’re lining up perfectly with the pads underneath, then just fill the remaining holes with solder so they connect all the way through.

It’s a balancing act – you want enough solder to fill the hole and join up with the tinned pad on the board underneath, but you don’t want so much solder that it creates shorts inbetween the two boards.

wireless 128
h_solar_monitor_b 10

Result: two boards stuck together, without the extra height the header would create:

wireless 131

Check the connections with a multimeter before powering it up, just to make sure there are no shorts. If there are (which has only happened once out of the few dozen times I’ve done this), you can separate the boards by melting the solder, pad by pad, working a bit of folded-over kapton tape between them to keep them from reconnecting as they cool. Then clean up the two boards and have another go.

h_solar_monitor_b 11
It may seem like a complicated way to avoid drilling eight little holes, but once you’ve done it a few times it’s surprisingly quick and easy and it knocks quite a few millimetres off the height of the board.

Finished PCB in position (note to future self: gotta find a way of moving those electrolytic caps off to the side of the board next time):

h_solar_monitor_b 12

Final result: a wireless LCD readout for my solar panels:

h_solar_monitor_b 13

Note: this is a hacky and, arguably, utterly unnecessary technique, but I like it, so there ūüôā

Illuminated control panel

IMG_9190

A friend of mine has had his recording studio fitted out with custom built furniture and wanted a smart control panel to give quick access to some bits and pieces.

I laser cut a piece of smoked acrylic and mounted some sexy (and surprisingly cheap) illuminated switches from eBay. The decals on the switches are laser printed onto OHP film, cut out, and fitted inside the keycaps:

poseidon_control_panel 2

I soldered up the connections on the back of them… lots of wires. Each switch is illuminated, so it’s 4 connections per switch, 32 in total. The last thing you want is wires hanging loose, even though this panel will be mounted in a box, but I’ve seen some neat ways of “cable lacing” to tie them all together into a neat loom. Wikipedia has¬†some nice pictures you can use as a guide; usually waxed cotton is used (I’m guessing the wax stops the knots from falling apart) but it turns out dental floss works just as well:

poseidon_control_panel 1

At the bottom of the panel, I’ve put the studio logo, all nicely backlit. The actual backlight is an old iPod display – take it apart carefully and you can remove the LCD glass, leaving you with a nice, evenly lit rectangle.

To create the logo, I laser printed several copies of the studio logo onto acetate, then carefully lined them up on top of each other and stuck them together with a little spray mount. Why multiple copies? If you try doing this with a single laser/acetate, you’ll find the black parts of the print aren’t dense enough to block the light properly. Layering up a few copies builds up the contrast, so you don’t end up with a glowing rectangle with the logo on it. Then I stuck it to the front of the iPod backlight, and glued it to the back of the acrylic panel:

poseidon_control_panel 3

The buttons are connected to a Teensy LC running in keyboard emulation mode, so they just trigger keypresses on the Mac the panel’s connected to.

 

Looks pretty smart in situ (that’s it just over the keyboard):

IMG_9184

Motion Control: the source code

The source code is online.

Warning: it’s awful. It has worked, and may still work, but it’s offered more for entertainment than anything else. There are several thousand hard-coded gotchas, and a pervading bad code smell in just about every file. But hey – it’s the biggest project I’ve tried putting together, and my first in Swift. And it’s not like there’s a standalone app you can run and play with; you need the hardware (which has similarly unpleasant firmware) in order to stand a chance of getting it working.

But I’ll do what I can to clean it up, document it etc. in the coming weeks.

Link: https://github.com/howiemnet/MotionControl

Reverse swear box

Most swear boxes work the wrong way round: you say something naughty, then you have to put money in the box as penance. This is the opposite – press the button and this device generates a random swear word for you to use in conversation at your leisure. Technology, eh.

It’s not a new idea: a few years ago I came across this beautiful “Four Letter Word” clock made with delicious old fashioned nixie tubes:

flw1

Designed and built by Jeff Thomas, Peter Hand, and Juergen Grau. More information here.

I wanted to make something quick and simple as a birthday present for a friend, and I had four little LED starburst displays sitting in a box, so some sort of random word dispenser seemed like a good idea. Designed a quick circuit in Eagle:

Screen Shot 2014-05-20 at 07.36.07

Download schematic and layout: FourLetterWord

The schematic in Eagle is pretty messy and tangled. I often find that if I’ve got loads of connections to make to a microcontroller, it’s not until I’m laying out the board design that I can see the way things should be connected.

This is the perfect example: I’m connecting two identical starburst displays to the microcontroller in a multiplexed fashion. In an ideal world you’d connect the anodes of the displays together, segment A to segment A, seg B to seg B and so on, leaving just the cathodes of each digit to be connected separately. This makes the software a little simpler – pin D3 (say) on the microcontroller controls the same segment on all the digits:
Screen Shot 2014-05-20 at 08.06.23

On a single sided PCB, though, routing the connections like that gets really tricky – you end up with loads of connections that have to jump over others so they end up on the right pins.

The alternative is to design the circuit so it’s easy to route (even if that means segment A on one display is connected to segment F on the other etc) and then sort it all out in the software.

Screen Shot 2014-05-20 at 08.06.36

Hence the relatively neat looking PCB design:

Screen Shot 2014-05-20 at 07.36.25

Note that there’s an error in the design / layout – I didn’t realise until too late that two of the microcontroller pins I wanted to use (A6 and A7) wouldn’t work as digital pins, so I had to use some wires to connect them to some free pins on the other side of the controller. Live and learn.

HFLW-IMG_0219

With the PCB milled out and populated, I hacked a rectangular hole out of a random wooden box I had knocking about, and stuck a switch and a button on it, and squished a bit of foam and a CR123A battery holder in.

HFLW-IMG_0223

CR123A batteries are great for this sort of project – they only run at 3 volts, but that’s enough to drive LED displays without needing to add current limiting resistors. Helps that the display is multiplexed, too; though it looks like all the displays are lit up simultaneously, they’re actually taking turns, one digit at a time. Stops the LEDs from burning out – at most they’re on for 25% of the time.

The software’s pretty simple – there’s a list of about 45 swear words chosen at random. Proper randomness isn’t easy for a microcontroller (or a computer) to do on its own, so I measure how long the user has pressed the button, in microseconds, and use that value to help choose a word.

HFLW-IMG_0227

Press the button and an animation sweeps across the display, with each letter of the word coming up one at a time like a fruit machine.

HFLW-IMG_0216

HFLW-IMG_0233

Download software: FourLetterWord-Arduino code

It’s surprisingly hard to come up with lots of 4-lettered obscenities, so there are some strange ones in there. My favourite is “MILK”…