esperesa: (Default)
Yuxi ([personal profile] esperesa) wrote2011-12-22 06:43 pm
Entry tags:

[Tutorial] How to add correct drop shadows to objects.



Lack of shadows on objects are a bit of a personal pet peeve, and I often add them to objects that don't have them (or have faulty ones) for my own usage. They add just that little extra bit of realism. I thought it might be useful for others to have a little guide for them, because the object creation tutorials I've seen don't go into a lot of detail.

This is a pretty basic tutorial, but I'm going to assume you have basic knowledge of Photoshop, Gimp or Paint Shop Pro, have poked through the innards of an object .package before (so you know what a GMDC is), and rummaged around a bit in Milkshape so you know the basic controls. What you need is, of course, an object in need of a shadow. If you never messed with Sims meshes before, you will need to put the Unimesh plugins" in your Milkshape folder to be able to import and export GMDCs.
So let's begin!


For this tutorial, I'm going to give this mirror from the long-dead site Habitat43 a wall shadow. (You can get it here - it's called B43_ornamental_wallmirror.package.) This is what it looks like:



It's pretty and all, but I think it lacks a bit of depth. The creator of this object deleted the shadow plane from the mesh, but all the resources (the references in the SHPE file, the texture, et cetera) are still there in the .package file. Fixing this is almost the same as fixing the shadow for your own new object, which is why I chose this as an example.

1. First of all, open the object in SimPE and extract the mesh (the GMDC file - in this case the object is a mirror and thus has two meshes. Skip the 'boundingbox' one). Also export the texture file - this object has two: The shadow itself, which is a small black and white image, and the texture for the mirror itself. You can ignore the shadow for now.



2. Import the mesh you just extracted into Milkshape. I have three windows in Milkshape: Two on the left and one main window. Go to Window > Viewports > 3 Windows (2 left, 1 right) to get this view as well. I've set the top-left projection to 'right' and the bottom-left projection to 'front'.
The creator of this object didn't add a plane for the shadow, so we're going to add it ourselves. Go to Model > Plane and set the HDivs and VDivs to '1'.



Go to the bottom-left window and draw the plane around the mirror frame. Then, select 'Move' in the 'Model' tab and drag the plane in the top-left window to just behind the frame. You'll end up with this:





3. Now, I looked into the SHPE file in the package, and noticed that the correct file for this shadow should be 'southwallshadow'. Go to the 'Groups' tab and rename 'Plane01' to 'southwallshadow'. Open the Comment and paste this into it:

ModelName: southwallshadow
Opacity: -1


It's important that the ModelName/Group name is the same as the name in the SHPE file, or else it won't show up.

4. Now to create the shadow image. Hide all groups except the one named 'frame'. Go to the bottom-left window and [i]deselect[/i] 'Show Axis' and 'Show Grid', and set the view to 'Flat Shaded'. It will look like this:



Make a screenshot of your screen using the Printscreen button/Fraps/Gadwin whichever and paste it into your image editing program (I use Photoshop). Don't close Milkshape just yet!

5. Crop the image to the frame shape. Now, what we want is make the background black and the shape white, as the white part is what will show up as the shadow. Set the image colours to 'Negative' (Adjustments > Negative), making the black frame part white. Then, go to Adjustments > Replace Color and select the grey background with the pipet. Put the 'Lightness' to -100:


(I hope it's clear despite the Dutch.)


Next, go to Blur and use Gaussian Blur on it. I used a strength of 4. The original size of the shadow image was 64x64, but I want to make it 128x128 because of the frame detail. Simply create a new image of 128 by 128 pixels, then copy the image you just made, and paste it in there as a new layer. Go to Transformation > Scale and resize it so it fits.



This would be a pitch black hole of a shadow, so fill the background with black and lower the opacity of the frame layer to 50% or 60%. I thought the shadow was still a bit sharp, so I used Gaussian Blur again (with a strength of 1.7 this time). Save this as a .png.



6. Back to Milkshape! Go the the Materials tab and add two new textures (just click 'New'). Select the frame texture you extracted earlier for the first, and the shadow for the second. Unhide the shadow layer you hid earlier. Select the 'frame' group and assign the frame texture, then do the same to the shadow texture and the shadow plane. It should look like this:



The shape is a bit off, so let's edit the shape of the shadow plane. Go to the bottom-left window (with the 'front' view) and make sure 'Textured' and 'Wireframe Overlay' are selected. Move the vertices of the plane around so the shadow shape fits the frame. When you're done, it should look something like this (I deselected the wireframe again so I could see it better):



Export the mesh as a .simpe file and go back to the .package file.

7. Go to the GMDC files again, right-click on the mesh you extracted earlier (again, not the boundingbox one in case of a mirror) and replace it with the edited mesh you just exported from Milkshape. Don't forget to hit 'Commit'.



8. Now go to the textures and go to the shadow texture. In this case, the texture was one left from the Maxis mirror the object was originally cloned from, and it is a 64x64 size (while the one we made was 128x128). Use BuildDXT to import the new shadow.



It's a bit blurry, so next we're going to 'Import' to select the shadow texture again. Right click and hit 'Update all Sizes'. Hit commit. Note that if the texture you have is the same size as the shadow texture that is already in there, you can skip the BuildDXT and only need to use Import+Update all Sizes.

The most important thing here is to change the format to ExtRaw8bit, or else you will get a black box instead of your pretty shadow.



So let me repeat that: Change the image format to ExtRaw8Bit.
Again, don't forget to commit!

Now, save the package and test the object in your game. Go check if the shadow isn't disappearing in the wall (if it does, no sweat; just move it forward in Milkshape a bit). In the end it looked like this for me. Looks just a wee bit tidier, no?



Good luck!



You can get the fixed mirror here. If you have any problems, comments or questions, please feel free to post them here.
maaron: (Default)

[personal profile] maaron 2012-01-30 12:00 pm (UTC)(link)
Oooh, how come I see this only now???? >:O

I'm a shadow-fan myself and gracias to you, I am thinking of trying to improve some objects! :D This doesn't seem that bad... Note the word seem.
maaron: (Default)

[personal profile] maaron 2012-01-31 12:00 pm (UTC)(link)
But the tutorials-tag was begging me to click it! D:

I shall obey my master V__V If my game dies, I'll blame you! :D