(electronic music)
- We've been working on a birthday card,
a VR birthday card for my niece, Lauren.
Let's take a look at what we have so far.
Well, we've got a scene,
it's got a nice birthday cake in it.
We can see it's rendering pretty well,
the trees are in here, two different kinds of trees,
nice mountain background.
Well there's three things I want to change.
First of all, the lighting looks very strange,
certain things are shining when they shouldn't be,
the ground isn't quite the right color of green,
the sky, of course, is blood red, nobody wants that,
this is a birthday card, not a Halloween card.
So let's work on the lighting and change the sky.
Let's go back to our code.
First thing, in initContent, first thing we do
is scene.background = THREE.color.
So let's change the color to at least be
something of a nice blue, how about, 2288ff.
Now, let's change that more of a sky blue.
Okay, now we have a nice sky blue.
Let's look at the lighting.
What we have by default is a standard light.
This is a directional light.
Now you might think, well, what's a non-standard light?
Well it turns out there's many kinds
of light that we use in VR.
First, and simplest, is called ambient light.
All that does is make everything brighter.
Doesn't matter where it is in the scene, where the sun is,
nothing, it's just ambient light.
It essentially simulates what it would be like for the light
that bounces off of everything and hits everything else.
And that will help lighten up places that seem
to be completely black, like under the tree.
In real life, nothing is completely black,
there's always some color there.
So let's add an ambient light.
We will set the color of the light to be white,
and an intensity of 0.3, so we're just kind of
brightening up the shadows a little bit.
It's not gonna completely overwhelm the scene.
So we created a light, now we need to add it to the scene.
And now we can see that those super dark places
underneath the tress have now brightened up,
and we can see they are in fact green, not completely black.
So the next thing we want is some directional light.
Directional light means light that comes
from a particular direction,
as if that point was infinitely far away.
You'd use directional light for generally lighting a scene,
to simulate a sun or moon,
or something that's very far away.
Right now we have sunlight turned on,
it's set to a position of one, one, one.
Instead, I want to move the sun to be mostly overhead.
So change the x to zero, change the y to 10,
and leave the z at one, which means it will be
directly overhead, and just a teensy bit behind me.
Now we can see the scene in general feels brighter
and much more happy, because we've got light coming
on those mountains, they don't seem so dark and ominous.
Now the third kind of light is a point light.
Point light is light that comes from a particular source
that you can see, like a light bulb.
You can set the exact position, it goes in all directions,
and it falls off, so as things get
further and further away, they'll have less light.
So let's add a point light next to the thing
that's the most important part, which is the cake.
Create a point light, also make this white.
Though if I was doing a night scene,
I might want to make it a color, like red or blue.
And let's set the intensity to one, for now.
Being a point light it needs an actual position,
so position.set, we want it to be near the cake.
Zero, and the cake is probably around negative five,
so let's put it at negative three
and see what it looks like.
Now we can see it is a little bit brighter near the cake,
but we might wanna increase it just a tad more,
so let's just increase the intensity of the light.
I think the position's actually pretty good.
And it's definitely got a nice glow
around the cake now, which is great.
Let's just move it a little bit closer,
so we can see here at the bottom,
I'm getting some glare in the ground in front of me.
Much better, but now the intensity's
a little too bright, so let's reduce it a bit.
So you can see, putting light
into a scene is very much an art.
You try different things, you tweak it all the time
to get the effect that you're looking for.
Okay, I think that's pretty good,
it kind of looks like the cake itself
is putting off some light.
So we've shown three different ways to use light.
There is an ambient light,
which is light that goes everywhere,
there's direction light which we use
for representing something like the sun or moon,
where it comes from infinitely far away.
Then there's a point light, which goes in all directions
but has a specific position and falls off.
There's a fourth kind of light called a spot light,
which is similar to the point light
except it only goes in one direction.
If I was doing a night scene,
I might use something like a spot light,
but for this, there's three kinds of light:
directional, ambient and point light,
are exactly what I want.
So I think we have a pretty good scene here.
The problem is I can't actually move around in it.
I need some way to move within the scene,
some kind of navigation.
So next time, we'll look at how we navigate in VR,
what the different options are,
and build a simple teleportation system.