3D Game Development with Microsoft Silverlight 3: Beginner's Guide — Save 50%
A practical guide to creating real-time responsive online 3D games in Silverlight 3 using C#, XBAP WPF, XAML, Balder, and Farseer Physics Engine
In this two part article series by Reynante Martinez, we will learn how to digitally sketch/draw your scenes, give them subtle color shifts, add fake lighting, and apply filter effects to further emulate how 3D does its job in a step by step process. We will start off from scratch and move on to create a realistic 3D scene with just some 2D tools.
We will discuss:
- creating an appropriate canvas
- layer modes
- layers as backups
- selection tools
- color transition and theory
- faking Depth of Field
- faking reflections
- simple post processing
In the previous article I've written ( Creating Convincing Images with Blender Internal Renderer-part1), I discussed about creating convincing 3D still images through color manipulation, proper shadowing, minimal lighting, and a bit of post-processing, all using but one application – Blender. This time, the article you're about to read will give us some thoughts on how to mimic a 3D scene with the use of some basic 2D tools.
Here again, I would stress that nothing beats a properly planned image, that applies to all genres you can think of. Some might think it's a waste of precious time to start sitting and planning without having a concrete output at the end of the thought process. But believe me, the ideas you planned will be far more powerful and beautiful than those ideas you just had, when you were just messing around and playing with the tool directly.
In this article, I wouldn't be teaching you how to paint since I'm not good at it, rather I'll be leading you through a series of steps on how to digitally sketch/draw your scenes, give them subtle color shifts, add fake lighting, and apply filter effects to further emulate how 3D does its job. Primarily, this all leads you into a guide on how I create my digital drawings (though I admit they're not the best of its kind), but somehow I'm very proud, I eventually gave life to them from concept stage to digital art stage.
It might be a bit daunting at first, but as you go along the series, you'll notice it gets simpler. However, some might get confused as to how this applies to other applications since we're focusing on The GIMP in this article. That's not a problem at all once you are familiar with your own tool; it will just be a matter of working around the tools and options. I have been using The GIMP for a long time already, and as far as I can remember, I haven't complained on its shortcomings since those shortcomings are only but bits of features which I wouldn't be need at all. So to those of you who have been and are using other image editing programs like Adobe Photoshop, Corel, etc., you're welcome to wander around and feel free to interpret some GIMP tools to that of yours. It's all the same after all, just a tad bit difference on the interface.
Just like what Jeremy Birn has said on one of his books: “Being an expert user of a 3D Program, bit itself, does not make the user into an artist more than learning to run a Word Processor makes someone into a good writer.”
Additionally, one vital skill you have to develop is the skill of observation, which I myself ham yet to master.
- Basic Drawing
- Selection Addition, Subtraction, Intersection
- Gradient Coloring
- Color Mixing
- Layer Modes
- Layer Management
- Using Filters
- Latest version of The GIMP (download at http://www.gimp.org/downloads)
- Basic knowledge of image editing programs with layering capabilities
Let's Get Started!
I would already assume you have the latest version of GIMP installed on your system and is running properly, otherwise, fix the problem or ask help from the forum (http://www.gimptalk.com). I'm also assuming you have all your previous tasks done before sitting down and going over this article (which I'm pretty much positive you are). And then lastly, be patient.
Sketch it out
The very first thing we're going to do is to sketch our ideas for the image, much like a single panel of a storyboard. It doesn't matter how good you draw it as long as you understand it yourself and you know what's going on in the drawing. This time, you can already visualize and create a picture of your final output and it's great if you did, if not, it's fine still. The important thing is we have laid down our scene one way or another. You can take your time sketching out your scenes and adding details to them like how many objects are seen, how many are in focus, what colors do they represent, how are your characters' facial expressions, what is the size of your image, etc. So just in case we forgot how it's going to look like in the end, we have a reference to call upon and that is your initial sketch. This way, you'll also be affected by the persistence of vision where after hours and hours (yay!) of looking on your sketch, you somehow see an afterimage of what you are about to create, and that's a good thing!
I'm not good at sketching so please bear with my drawing:
After this, it's now time to open up The GIMP and begin the actual fun part!
After executing GIMP, this should (and most likely) be the initial screen that's going to be displayed on your screen:
The GIMP Initial Screen
We don't want Wilbur (GIMP's Mascot) to be glaring at us from a blank empty window all the time, do we? And right now we could go ahead and add a canvas with which we'll be adding our aesthetic elements into, but before that you might want to inspect your application and tool preferences just to make sure you have set everything right. Activate the window with the menu bar at the top (since we currently have three windows to choose from), and then locate Edit > Preferences, as seen below:
Locating GIMP's Preferences
Everything you see here should be self-explanatory, if it isn't, just leave it for the moment and check the manual later, since I'm pretty much sure that thing you didn't understand on the Preferences must be something we will not use here. So go ahead and save whatever changes you did and sometimes, GIMP might ask you to restart the application for the changes to take effect, then do what she says and we should be back on the black canvas shortly after application restart.
By now, we should be having three windows, the main Toolbox Window (located on the left), the main Image Window (located on the middle), and the Layers Window (located on the right). If, by any chance, the Layer Window is not there, go ahead and activate the Image Window and go to Windows > Layers or press CTRL + L to bring up the Layer Window.
Showing the Layers Window
Creating the Canvas
Now that everything's set up, we'll go ahead and add a properly-sized canvas that we'll paint on, which will be the entire universe for our creation at a later stage. Let's go and create than now by going to File > New or by pressing CTRL+ N. A window will pop up asking you to edit and confirm the image settings for the canvas you're creating. You can choose from a variety of templates to use or you can manually input sizes (which we are going to do). Before that, change the unit for coordinate display to inches just so we could have a better visual reference of how big our drawing canvass will be. Then on the Width input box, type 9 (for nine inches), and for the Height input box, type 6 (for six inches) respectively. This, however, is a very subjective portion, since you can just have any size you prefer, I just chose nine inches by six inches for the purposes of this article. Clicking the Advanced Options drop-down menu will reveal more options for you. But right now, we'll never deal with that, just the width and height are sufficient for what we'll be need. When you're done setting up the dimensions and settings, click OK to confirm (is there a chance we could chance the OK buttons to “Alright” buttons, which sounds, uhmmm, better).
Creating a New Image
At this moment, we should be seeing a blank canvas with the dimensions that we've set awhile back. Then just at the right window (Layers Window), you'll notice there's already one layer present as compared to the default which is none. So everytime we add a new layer (which is very vital), we'll be referencing them over to the Layers Window. Since the creation of the layering system in image editors, it has been a blast to organize elements of an image and apply special effects on them as necessary. We can imagine layers as transparent sheets overlaying each other to form one final image; one transparent sheet can have a landscape drawn, another sheet contains trees and vegetation, and another sheet (which is above the tree sheets) is our main character. So together, we see a character with trees on a landscape in one. But as far as traditional layering is concerned, digital layering has been far more superior in terms of flexibility and the amount of modes we can experiment with.
New Image with Layer
This time might be a good idea to save our file natively, by that I mean save it in a format that is recognizable only by GIMP and that is lossless in format, so whether we save it a couple of times as such, no image compression happens and the image quality is not compromised. However, the native format is only related to GIMP and is not known elsewhere, so uploading such file to your website will show no image at all because it isn't recognized by the browser. In order to make it generally compatible, we export our image to known formats like JPEG, PNG, GIF, etc. depending on your need. Saving an image file on its native format preserves all the options we have like selections, paths, layers, layer modes, palettes, and many more.
This native format that GIMP uses is known as .XCF which stands for “eXperimental Computing Facility”. Throughout this article, we'll save our files mainly in .xcf format and later on, when our tasks are done and we call our image finished, that's the time we export it to a readable and viewable format.
Let's go ahead and save our file by going to File > Save, or by pressing CTRL + S. This brings up a window that we can type our filename into and browse and create the location for our files. Type whatever filename you wish and append the “.xcf” file extension at the end of the filename, or you can choose “GIMP xcf image” from a list on the lower half of the window.
Saving an Image as XCF
|A practical guide to creating real-time responsive online 3D games in Silverlight 3 using C#, XBAP WPF, XAML, Balder, and Farseer Physics Engine|
eBook Price: $29.99
Book Price: $49.99
The Creation Process
Now that we've done the necessary preparations, let's go ahead and fiddle around the tools, we'll be needing and the actual creation process. First thing we'll do is to activate the Layers Window then let's add a new layer above the currently selected one (which is the default layer action). Always remember that whenever we want a newly created layer to appear above another one, we must first select that layer, then add a layer, this automatically places the new layer above and not elsewhere.
Creating a New Layer
To add a New Layer, click on the lower left hand corner of the Layers Window (highlighted in red in the previous image), then type in a name that you could interpret what the layer does, as in our case, I named it “black bg”, since it will be our not-so-black background for the rest of the image. Also, don't forget to choose the Layer Fill Type as Transparency, if it's not the selected default. Press OK and you'll notice that a New Layer was added on the Layer stack right above the “Background” layer.
New Layer Options
New Layer Stack
However, no changes have been made or have affected our image when we look at our Image Window, that is because the layer we just added has a Transparent Layer Fill Type, which means that it basically is not having any RGB values at all, so we see the underlying layer even though it's the active one. So to justify its name (“black bg”), we'll now add a descriptive visual value to that layer.
On our Toolbox Window, click the two colored boxes to change the foreground and background color. Make the foreground color a dark red tone (almost maroon) and the background layer pure black (or nearest black).
Changing Foreground and Background Colors
The reason we changed the foreground and background colors is to prepare us for the next few steps which will primarily involve the choice of colors we have. Yet again, it doesn't matter which colors you choose, but since I already have a picture in my mind bound for this writing, I'll have to choose these two colors.
Proceeding further in this step, is choosing the Gradient/BlendTool from the Toolbox Window, which will enable us to blend and mix colors on different directions depending on our mouse/tablet strokes. You can select the Gradient Tool by clicking its icon or by pressing L, which will eventually show us more options on the lower half of the Toolbox Window for further tweaking.
Essentially, what you see on the tool options are settings for the gradient. Since we literally need the exact colors, we chose for the foreground and background, we will choose the mode as Normal which is the default option selected. The default values are our best bet for this part here, so we wouldn't be touching any of its settings. Just in case the Dithering option was turned off by default, you should turn it on since this will smooth out our gradient and prevent the perception of banding where we can obviously see the transition between colors (which is not a good idea). Now, to apply the color gradient to our canvas, click and hold the left mouse button at the top portion of the image and drag it until the bottom part of the image then release the left mouse button. This way, we have a nice smooth transition between the two colors. There's enough room for experimentation though, so you can try lessening the distance between the start point and the end point and notice how the transition becomes obvious and clipped the lesser the distance between the two are. One tip that might be useful in using the tool to gradiate the colors is to use the SHIFT key to constrain the direction into straight lines.
Try gradiating the colors again, but this time with the SHIFT key pressed. On the image below, using this key made it easier for me to apply the gradient.
Applying the Color Gradient
Giving us this result:
Color Gradient Applied
Basically, that is all there is to our background, everything else would just then be a matter of layer modes and some nifty effects we'll be adding afterwards.
And now we proceed to the most important aspect of our image – the subject. The subject, or otherwise known as our main character/objects, will be the primary focus of our image and we need to create it such that it drives the visual perception of viewers and will eventually lead them to our main point and story which is told mostly by our subject in this case. We can create an array of interesting subjects on our 2d canvas, ranging from basic shapes to the most complex irregular things. I would love to lead you into the creation process of an intricate character with sets of props but that would take me days, or even weeks, to finish it up, or worse, it might bore the hell out of you already. So just for the purposes of this article, we'll create just simple shapes, spheres to be exact, and apply pseudo-3D effects on them to make it look “as though” it was 3D. And hopefully though, we'll be able to do just that.
To begin with, let's start from where we left off last time where we created the basic colors for our background. Go ahead and add a New Layer over to the Layers Window and name it “sphere”, or whatever symbolic name you want for it, don't worry since we can always rename it anytime by just double-clicking on the layer name on the Layers Window to rename the layer. Set layer sphere's Layer Fill Type to Transparency so that whatever objects we place on this layer will not entirely block the lower layers, depending on the amount of alpha and scope set.
Select (if it is not by default) the newly added layer “sphere” to make it our active layer to work on and let's begin creating our subject/s.
New Layer “sphere”
Go ahead and click the Ellipse Select Tool or press E key on your keyboard.
Oftentimes, it is a better idea to get yourself familiar with the tools and applications you're using before actually starting to fiddle around with it. Understanding what it can and it can't do is one thing you must consider so just in case you screw something in the long run, you know how to work around those mistakes.
In this sense, it's an advantage if you know and memorize keymaps/hotkeys/keyboard shortcuts that come with your software. Not only does it make it convenient to select tools and issue a command but they also increase your productivity as compared to lifting your hand, holding your mouse, and moving it over, then clicking the tool (which might take a few seconds slower than just pressing a single key on your keyboard). This is one of the primary reasons why software developers and user requests often have the functionality to customize your keyboard shortcuts, it comes for a greater reason.
In GIMP, you can almost customize all of the keymaps by going to Edit > Keyboard Shortcuts and assign or change them accordingly.
If you're having trouble finding the tool on the Toolbox Window, here's a screenshot:
Ellipse Select Tool
On the tool options that shows on the lower half of the Toolbox Window, leave the default as is. If, by any case, they're not the same as the screenshot above, kindly copy the settings we have. Now, go ahead and play around the tool on the canvas, draw “a lot” of circles and familiarize yourself with the tool, and when you're done, get back here and read further. Ok, with the Ellipse Select Tool active, move over your cursor to the Image Window (make sure you have the “sphere” layer active) and hold SHIFT while click-dragging the circle selection that you're creating, in this manner we're constraining the sphere at a perfect height and width ratios, meaning, a perfect circle. If you don't see a perfect circle on your screen while doing this, there might be something wrong with your display aspect ratio or your tool options.
Creating an Ellipse Selection
|A practical guide to creating real-time responsive online 3D games in Silverlight 3 using C#, XBAP WPF, XAML, Balder, and Farseer Physics Engine|
eBook Price: $29.99
Book Price: $49.99
After releasing the left mouse button, you'll notice that the selection we made became a circle with moving dashes and points on the outline. This moving dashes and points are called “marching ants” and are a good way to visualize your active selection/s and their respective ranges. Now with the selection active and the Ellipse Select Tool still alive and kicking, click anywhere inside the active selection and you'll notice the cursor change from a circle to a four-arrowed cross, which literally means the move tool for this selection has been activated and is a good way to create translations and moving on our current selection/s.
If, as in my case, it seems that the selection you just created was off by what you have intended from the beginning, this tool is just the right thing for you. So while the move tool for the Ellipse Select Tool is active, click and drag the circle selection we just did to move it on a place that'll look better when presented, since placing objects dead center is not always a good idea. So what I did here was to move our ellipse over to the left a bit just to create more room the the right of the image where we'll be placing some objects as secondary/supporting subjects.
You'll see my screenshot below:
Offsetting the Ellipse Selection
We've already placed the circle selection at a decent location; next step is to create an initial life to it by adding up a color. To save us time, we wouldn't be painting manually and tediously the whole selection with a paintbrush/pencil/etc. or by filling it with a solid color then later adding shades to it, rather, we'll go directly and add a subtle variation and diffuse color to the currently active selection. But how? We take advantage again of one of my favorite tools in GIMP, the Blend/Gradient Tool, but this time with a little alteration to the settings such that we change the Blend Shape from “Linear” to “Radial” and you'll see why in a while.
Before we apply the gradient, we must first define what colors are to be gradiated to the selection. I chose mine as shades of oranges/brown and I really can't tell you neither myself why, it's just an onset of my visual taste. Refer to the image below for the colors.
As for the gradient application, we'll do the same procedure of stroking the colors such that the farther we go from the start click and hold point, the more gradiated and less obvious the color transition becomes. But as compared to the Linear Blend Shape, the Radial Blend Shape starts its origin on the click and hold point and transitions the colors on a radius equally distant from the starting point. So basically, when applying the Radial Blend Shape, we are actually defining the radii of the gradients we create and not the circumference.
To nicely emulate light coming from a source, we'll start click-dragging the gradient from the upper left point of the selection and end it almost at the middle (see image below).
Applying the Subject Gradient
This will look like the image below:
After Applying the Gradient
And yet again, with the selection still active, go ahead and add another layer and name it “upper shine” which will be, as the name suggests, the shine on top of the sphere (let's now call it a sphere instead of circle to better attribute it to our final output and to give it now a more 3D feel).
New Layer “upper shine”
With the selection active, right click on the Image Window and go to Select > Shrink.
Shrinking the Selection
Then on the window that pops up, type in an appropriate value and unit for the shrinking, I chose “5” and “pixels”. Then click OK to confirm.
Shrink Selection Dialog Window
Shrink Selection Applied
Here comes the tricky part of selections: the addition, subtraction, and intersection of such. This time around though, we'll be subtracting a selection from the currently active one by using, yes you guessed it right; another selection. The reason for doing so is for us to only have the upper left portion of the sphere as our active selection and put colors on it. There are several ways of doing it, and as far as I can remember, we can either do it using the Paths Tool in GIMP or Pen Tool in Adobe Photoshop (or whatever name they call it in other apps) if we wanted more control and contour over our selections or we can simply use the ever-powerful selection tools. And yes, we're using yet again the Ellipse Select Tool for this matter.
With our shrinked selection still active and the Ellipse Select Tool selected, click the icon in the lower half of the Toolbox Window which is third from the left and is displaying a rather obvious image of selection subtraction. Then activate the Image Window then click and drag (while holding SHIFT to constrain the height and width) from the lower right portion of the selection to the near upper left portion of the selection to create another elliptical selection just offsetting the original one.
You'll notice that right after releasing the left mouse button that our previous shrinked selection has now only a portion of the original one, which is what we actually need for this process.
Subtracting the Selection
And now time to add some color to this selection. First, let's change our foreground color to solid white. Select the Blend/Gradient Tool again and this time altering some of the default settings. Click on the Gradient selection and choose Foreground to Transparent instead of the default FG to BG (RGB). And lastly, choose Radial in Shape. Just like how we added a gradient to our sphere selection awhile back, we'll certainly do the same thing here, only with a variation on the stroke. The image below shows you how it is done.
Applying the Gradient
Creating this result:
Selection with Gradient
At this moment, we can now deactivate the currently active selection since we don't need it anymore. To do that, you can select either the Ellipse Select Tool or the Rectangle Select Tool, then hover your cursor over to the Image Window and click on any part of the image outside the selection (you'll notice the cursor showing an “anchor” icon). Or you could just right click on the Image Window and go to Select > None or do a CTRL+SHIFT + A.
We should be good with this one already, but just to add some little detail to it, we'll just add another little shine on the lower right part, just a tad. Just to be safe and organized, let's add another layer and name it “lower shine”, with a Layer Fill Type of Transparency.
Since our elliptical selection for the sphere has been deactivated already, you might wonder how in the world could we create another selection which is exactly the same shape and size as the original sphere we have, from which we will subtract our new selection. There are numerous ways to do this. We can use guides, or we can simply use the Alpha to Selection tool which is way faster and more convenient to use.
To create a selection from the original size of the sphere, select the layer named “sphere” where the base sphere is placed on, then right-click on the layer and select Alpha to Selection, instantly, you see an elliptical selection generated from the sphere itself. What we did was to tell GIMP to create any selection from that layer that has values of full alpha (or partially). Since we have a fully transparent background and a fully opaque sphere on that layer, the selection was then generated from the fully opaque one, which is, in our case the sphere.
Alpha to Selection
Now that we have the selection at hand, let's go back and activate layer “lower shine” and let's create the shine on that layer. Be careful not to do any stuff on layer “sphere” (where we derived our selection from), or else creating the layer “lower shine” wouldn't make sense at all.
With the selection still active and you see the ants doing their march, go ahead and shrink the selection just like the way we did before. Right click on the Image Window, and click Select > Shrink, then type in the same value we used last time, 5 pixels.
Shrinking the Selection
This time however, instead of starting the subtraction selection from the lower right portion of the sphere up until the upper left part, we'll do it the other way around. So with the Elliptical Selection Tool selected and its mode set to subtraction, start click-dragging towards the lower right direction until only a portion of the selection will be left behind after releasing the left mouse button.
Subtracting the Selection
With the selection subtracted and only a small portion of the previous ellipse selection is left, do the same steps that we did for coloring the upper shine with a radial gradient with foreground to transparent (rgb) setting. This will look closely like the image below:
Lower Shine Added
About the Author :
Reynante Martinez is a self-learnt graphic designer, illustrator, web designer, and 3D generalist. His interest in CG started nine years ago and was directly introduced to The GIMP as one of the open source image editing applications available in Linux. Aside from being an animator at work, he also has experience in mentoring and has been a speaker and workshop conductor at several occasions during the past few years. He is also the co-founder of PinoyBlender, a Filipino Blender User Group. Since his discovery of Blender six years ago, his passion for CG art grew even more, with more upgrades coming now and then and with an active and helpful community of Blender artists being one of the most exciting factors in his career. He can be reached through the email or through his weblog and you can also view his online gallery.
Books From Packt