Here's the VFX breakdown for my own version of Real Steel. ;)
Friday, February 28, 2014
Getting my feet wet with Blender
Whenever I watch movies, I am always on the lookout for parts where CGI is used. I used to be good at catching those part but these days, you just don't know what's real or not anymore. Most of the time, I enjoy watching the visual effects (or VFX) breakdown more than the actual film because I know what it takes for them to be believable. Every small detail has to fit well in the scene or it will give away the illusion.
The most serious VFX not only take a lot of computing power but the tools they use are very expensive. Something which are not available to the average Joe. The best tool around for VFX is arguably Adobe After Effects but I just can't afford it. Luckily, there is an open source alternative - Blender.
I know they are not exactly comparable. Blender is mainly for 3D modeling but it also has a video and node editor which can do things that After Effects can (like compositing, keying, camera solving). I just need to learn how to use it. As for the animation part, you will need a modern PC with a beefy GPU. I am currently stuck with an old PC and not lucky to have a graphics card that can help speed up rendering so it takes a loooong time to render animations using blender's cycles rendering engine. But hey, beggars can't be choosers, right?
Since blender is a big and complex tool, I don't think I will be good enough to use it without the help of guides and tutorials, anytime soon. So just to get the hang of it, I tried to do something simple but challenging. Something that involves camera tracking and animation.
To get some raw footages, I shot a video of my son pretending to be fighting with someone. It was hard getting him to act continuously but after a few tries, I had my raw material. The letters scattered around are markers to help track the camera.
Turns out, tracking the camera movement was the easiest part. The next thing was model a 3D character to animate. This is where I got stuck. I was starting to think that I might have bitten off more than I could chew. Modeling a character is something I would do if I really have to, but something I would avoid if possible since it takes a lot of time to do. This time, it was blendswap that saved me. Put simply, blendswap is a library of 3D models shared by artists. Some of the models can be used for your projects for free.
For my video, I was going for a Real Steel type of thing so I used a model called Nomad by Mennoknight. The model is completely rigged so it made it a little easier to put into my scene.
Animating this model took me around 7 nights just to get the movement right. What's difficult is that you have to make the character move in a way that matches the movement of the actor in the raw footage. Planning and choreographing those movements take a lot of time.
Once i got the animation right, the next step was to get the lighting right. The direction of light and the shadow should match to sell the effect. Since the raw footage was taken in a room with only one light, it wasn't hard to get it right. After approximating where the light should be, adjusting the intensity, and adding the shadow, it was time to render the clip. This is when you have to summon all of your patience. Or maybe not if you have a powerful PC and GPU. No wonder why it takes years for animated films to be made. Just for a 10-second clip like this, it took overnight for my core2duo processor to render all the frames. If that's what it takes, then fine.
The next morning, I watched the result. It was good but not great. The movement was fluid, the hits are natural, everything looked good and yet, something seemed out of order. There was just no impact. And you know why? You guessed it - there was no sound! Just when I thought I was done. Where do I turn to? Another open source software of course! I used Audacity to edit the robot sounds and plugged it back to blender video editor. This time, I had to match them with the movement of the robot and the punches. Another time consuming task but the result is very rewarding. You can see it for yourself here in case your browser does not play the video below.
I'll try to make a VFX breakdown video and post it.
Update:
You can check out the mini VFX breakdown here. Enjoy!
The most serious VFX not only take a lot of computing power but the tools they use are very expensive. Something which are not available to the average Joe. The best tool around for VFX is arguably Adobe After Effects but I just can't afford it. Luckily, there is an open source alternative - Blender.
I know they are not exactly comparable. Blender is mainly for 3D modeling but it also has a video and node editor which can do things that After Effects can (like compositing, keying, camera solving). I just need to learn how to use it. As for the animation part, you will need a modern PC with a beefy GPU. I am currently stuck with an old PC and not lucky to have a graphics card that can help speed up rendering so it takes a loooong time to render animations using blender's cycles rendering engine. But hey, beggars can't be choosers, right?
Since blender is a big and complex tool, I don't think I will be good enough to use it without the help of guides and tutorials, anytime soon. So just to get the hang of it, I tried to do something simple but challenging. Something that involves camera tracking and animation.
To get some raw footages, I shot a video of my son pretending to be fighting with someone. It was hard getting him to act continuously but after a few tries, I had my raw material. The letters scattered around are markers to help track the camera.
Turns out, tracking the camera movement was the easiest part. The next thing was model a 3D character to animate. This is where I got stuck. I was starting to think that I might have bitten off more than I could chew. Modeling a character is something I would do if I really have to, but something I would avoid if possible since it takes a lot of time to do. This time, it was blendswap that saved me. Put simply, blendswap is a library of 3D models shared by artists. Some of the models can be used for your projects for free.
For my video, I was going for a Real Steel type of thing so I used a model called Nomad by Mennoknight. The model is completely rigged so it made it a little easier to put into my scene.
Animating this model took me around 7 nights just to get the movement right. What's difficult is that you have to make the character move in a way that matches the movement of the actor in the raw footage. Planning and choreographing those movements take a lot of time.
Once i got the animation right, the next step was to get the lighting right. The direction of light and the shadow should match to sell the effect. Since the raw footage was taken in a room with only one light, it wasn't hard to get it right. After approximating where the light should be, adjusting the intensity, and adding the shadow, it was time to render the clip. This is when you have to summon all of your patience. Or maybe not if you have a powerful PC and GPU. No wonder why it takes years for animated films to be made. Just for a 10-second clip like this, it took overnight for my core2duo processor to render all the frames. If that's what it takes, then fine.
The next morning, I watched the result. It was good but not great. The movement was fluid, the hits are natural, everything looked good and yet, something seemed out of order. There was just no impact. And you know why? You guessed it - there was no sound! Just when I thought I was done. Where do I turn to? Another open source software of course! I used Audacity to edit the robot sounds and plugged it back to blender video editor. This time, I had to match them with the movement of the robot and the punches. Another time consuming task but the result is very rewarding. You can see it for yourself here in case your browser does not play the video below.
I'll try to make a VFX breakdown video and post it.
Update:
You can check out the mini VFX breakdown here. Enjoy!
Wednesday, February 26, 2014
Using raw PIR motion sensor without arduino or microprocessor
If you happen to have a bathroom without a window like ours, you need to use the light even during daytime which is not convenient if you are a kid and can't reach the switch.
For this next mini project, I just want a simple way to turn on or off the light when my child gets in the bathroom to pee. In my first arduino project, the PIR sensor has 3 pins (5V, ground and signal). When I bought another PIR sensor from the same store, I noticed that it has 2 more pins with the label "out".
Looking at the spec sheet, I found out that the load pins will give out the same as the supply voltage when a motion is detected. But this is not the only difference. This new PIR also has 2 potentiometers - one for the delay, which indicates how long the pulse signal will stay on when a motion is detected, and the other is the lux, that considers how bright the surrounding is before giving out a signal. Very useful if you only want motion to be detected at night. Considering the price is the same, this new sensor saves me a lot of parts!
So instead of using an arduino, or even the attiny85 microprocessor, we can use the PIR directly to turn on a light. The load part of this PIR can only give out 100mA of current but should be enough to power some LEDs. To keep things simple and avoid messing around with high voltage wires, I am just using a cheap LED torch as the lamp.
The torch is being powered by 2 x 3V coin cell but I am going to use 4 rechargeable AA batteries for power giving around 4.8 to 5V. A white LED needs about 20mA, I was concerned that the 100mA output of the PIR won't be enough for 6 LEDs but after a quick try, things worked out well.
The PIR only draws less than 1mA. A set of fully charged AA batteries lasted about 6 to 8 weeks but can last up to 3 months depending on your settings. I set it at about 40 seconds delay and only gets triggered only when it is dark. If you turn on the lights, the torch won't come on. The only glitch I noticed is that the PIR detects motion when you turn off the main light wasting a bit of the power from the battery. Maybe the light bulb I'm using in the bathroom emits infrared light that is being sensed by the PIR. Not a big issue anyway.
EDIT: Now that I have built my 3D printer, I made a case for it.
SB00622A-2 |
So instead of using an arduino, or even the attiny85 microprocessor, we can use the PIR directly to turn on a light. The load part of this PIR can only give out 100mA of current but should be enough to power some LEDs. To keep things simple and avoid messing around with high voltage wires, I am just using a cheap LED torch as the lamp.
![]() |
LED torch |
![]() |
Raw PIR powering the lamp |
EDIT: Now that I have built my 3D printer, I made a case for it.
Tuesday, February 25, 2014
Arduino based motion activated light and gas sensor for the kitchen using attiny85
I've been wanting to get my hands on arduino after seeing how powerful
it is. Luckily, I was able to find a clone here in the
Philippines, which is good enough to tinker with. This board is named Aceduino and is very similar to the Uno.
It wasn't hard to find what I'm going to use it for (endless possibilities!). The immediate application around the house is automation. It's not like I have a big house that flicking a switch is a big effort. There are just some things you want done automatically especially when it is going to make things safer.
For this project, I wanted it to automatically turn the kitchen counter light on and off so we don't have to touch the switch with wet hands. I shopped for a few components to go with the arduino:
- PIR sensor - to detect motion near the counter or sink
- 5V Relay - to turn the light on/off
- Some diodes, resistors and a small switch
Using a few guides on the net, I was able to make a working prototype. That's when I realized this board would be a huge waste if all I'm going to use is just a couple of I/O ports. This is where the attiny85 comes in.
Aceduino and Attiny85 |
I went to buy the additional parts:
- MQ5 Gas sensor
- Buzzer
So here are the features of the final build:
- motion activated light
- detects a gas leak and sounds an alarm when it does
- manual switch - if you want to keep the light on even when no motion is detected or if you want to suppress the alarm
And here it is in action:
Edit:
Here's the sketch for the attiny85 chip:
const int inPin1 = 1; // switch connected to digital pin 1
const int ssrPin = 2; // relay
const int pirPin = 4; // PIR sensor
const int buzPin = 0; // buzzer
int motionDetect= 0;
int manualSwitch = 0;
int motionSwitch = 0;
int gas = 0;
int buz = 0;
unsigned long timer;
unsigned long timerGas;
unsigned long timerPIR;
unsigned long timerBuz;
unsigned long timerBuzMin;
void setup() {
pinMode(ssrPin, OUTPUT);
pinMode(pirPin, INPUT);
pinMode(inPin1, INPUT);
digitalWrite(ssrPin, LOW);
timerPIR = 0 - 70000;
timerBuzMin = 0 - 6000;
//Serial.begin (9600);
}
void loop()
{
timer = millis();
motionSwitch = digitalRead (inPin1);
if (motionSwitch == HIGH) // Motion Mode
{
gas = analogRead(A3); // read gas sensor
if (gas >= 500) timerBuzMin = timer; // range is from 0-1024
if (timer - timerBuzMin <= 5000)
{
if (timer - timerBuz >= 300)
{
tone (buzPin, 2000, 200);
timerBuz = timer;
}
}
//Serial.println("motionDetect");
motionDetect = digitalRead(pirPin);
//Serial.println(motionDetect);
if (motionDetect == HIGH)
{
digitalWrite(ssrPin, HIGH);
timerPIR = timer;
}
else
{
if (timer - timerPIR >= 60000) // turn on relay for at least a minute
{
digitalWrite(ssrPin, LOW);
}
}
}
else digitalWrite(ssrPin, HIGH); // Manual on
}
Subscribe to:
Posts (Atom)