ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

Making SHPs with 3D Apps

From ModEnc
Revision as of 21:38, 11 October 2010 by Gordon-creAtive (talk | contribs) (Directly converted into MediaWiki syntax, images currently missing.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This tutorial has been taken from http://web.cecs.pdx.edu/~ben_s/Misc/3DTut/index.html which is no longer available. All credits go to meselfs.

Intrada

When I first operated RA2, I immediately wondered how all those graphics were made. When I downloaded the XCC Mixer, I found myself taking long gazes into ra2.mix, looking at all those neat SHPs and wondering how they made them. Especially incredible were the infactry sequences, notably rocketeer. How did they make 900 frames of such quality and especially coherence?

In case you haven't figured it out by grace of the title of this article, they were not drawn in 2D pixel by pixel. They were made with 3D.

What exactly is this? Think of taking a picture. Take a rock- it is a physical 3D object (4D actually, if you consider atomic radius). Light bouces off the rock and enters the lens, its appearence depends on lighting, environment, and the rock's physical properties.

Making pictures in 3D on a computer is intended to be the same. You define a 3D object, and you use a process called rendering it to create a 2D image.

The analogy is perfect: the rock provides the information, the lense gathers it, the shutter processes it, the film stores it, and the photo displays it; your model provides the information, the renderer gathers it, the CPU processes it, your hard disk stores it, and your monitor displays it.

Because of all this, you can make top quality images of perfect coherence using 3D without the need for incredible artistic capability, and once you have all the 3D data ready you can render it (make the final image) from any camera angle, and also modify the 3D data with respect to time (animating).

3D isn't hard, don't get the idea that it is restricted to "professionals". The hard thing about 3D is getting your desired amount of detail in. For example, I can make a box, put a small box on it, and have a pipe sticking out of it, and call this arrangement Tank A. I can copy this and place it a distance away and call it Tank B. I can make Tank A approach Tank B, stop, and have a small cylinder fly out of Tank A's pipe, hit Tank B, and make Tank B disappear. This would take me 15 min or less.

I could instead make a nice environment, complete with desert, cactus, scorching sun, and maybe one or two small clouds. I could make the tanks as elegant as possible, with animated tracks and trackmarks. I could have Tank A slowly decelerate, point its turret at tank B, and have a small explosion appear at the business end of its barrel. I could have Tank B explode shattering debris all over a split second later. This setup would take several hours.

How is 3D data defined? A rock is made up of atoms- a computer cannot hanlde information like that. It uses something called a mesh, which is an array of 3D polygons that make up a surface. To this surface a material is added, which can have a great variety of properties, including color, transperency, luminence, bump, and many others. Note this importand difference: your mesh is a surface, but the real rock is a solid.

Other 3D data include cameras, lights, and the like.

Some quick terminology

Antialiasing Short AA, this is a very desireable smoothing effect. Because of the Way AA works (called oversampling), it will slow down rendering more than you think. AA MUST be left off for SHP making (unless you use the stupidest 3D program 3DS Max), the smoothing is accomplished an alternate way shown later.

Frame Still image produced by rendering, also this is usually the unit of time when animating.

Keyframe Used in animation, a keyframe records (keys) some property of the object such as position at a certain time. Add another keyframe at another time to make dynamic motion. Almost anything can be keyed, everything from rotation to the color of a light. Your keyframes can be as far apart as you want, each frame does not need to be keyed, and most animator programs allow smooth transitions (called interpolation) between multiple keyframes, to make motion look less jagged.

Material A set of surface appearence properties (such as color, reflection, etc...) that can be applied to a mesh.

Mesh 3D data that defines a surface, composed of polygon faces. Most basic 3D apps support only triangles, many support quadrangles, and some apps operate with polygons that have as many sides as you want ("n-gons").

Modeling This is the process of making your meshes.

Polygon Single face on a mesh. Ideally a trianlge, since a triangle is a planar shape, no matter what.

Raytracing This is a special rendering process which utilizes a simple yet winner way of rendering an image. Raytracing has many advantages over plain rendering, inlcuding better image quality, reflective surfaces, refraction, and many other goodies. A renderer that can raytrace is simply called a raytracer. In the raytrace, mathematical rays are sent out from each pixel (or subpixel if AA is on) of the camera, and the way they interact with the scene is measured.

Renderer This is the software that renders your scene into a final image. It is a CPU intensive process and may take more time than you'd like. The renderer is often integrated into the software your using. Some programs, such as the stupidest modeler GMax, do not have any renderer.

Scene This is the entire 3D setup, including models, lights, animation, textures, etc...

Texture An image, usually used to define surface color. Also called a "skin". A texture can also be Procedural, which is mathematically generated.

The Software

Remember when I said that the camera analogoy was perfect? Well, it's not. A camera is easy to manufacture, and can give you an absolutely realistic image in moments (if it's Polaroid). Using computer machines to make such images, you'll need some well designed software and a good CPU to render your final image(s) in a reasonable span of time.

The software I will present here are all freeware. If you have something like 3DS or Maya, then nevermind...

...but remember, although freeware software generally require more work, they can easily be just as good or in some cases better than their you-must-pay-ware counterparts.

I will show you 3 pieces of software. There are many more. To download these while you read, see downloads at the bottom.

Blender 3D

This is easily one of the best freeware 3D programs ever made, some crazy people even prefer it over such software as Maya. It is fairly abrubt to get used to, but once the incredibly efficient UI is mastered you will have no sweat.

Learning the UI is crucial. Spend as much time as you need and go through the tutorials, you won't regret it. It will probably take you 2 weeks to get accustomed to things.

Blender has a competition quality raytacer, although renderers like YAFRay are typically preffered.

I recommend Blender for most people. It's a little hard to learn and very different, but will produce great results.

POV-Ray + Some Modeler

POV has a history of being what is probably the best of all freeware renderers. It's photorealism is comparable, if not in excess of, many you-must-pay-ware programs. Before you get excited, a warning: POV does not have a 3D GUI. Everything in your scene is defined by text, or to put it less kindly computer code. For example, have a look at this example POV code:

   camera{
       orthographic
       location <1,1,1>*20
       look_at <0,0,0>
   }
   
   light_source{<10,20,-5>
       color <1,1,1>*.8
       parallel
       point_at <0,0,0>
   }
   
   box{<-5,-5,-5>,<5,5,5>
       pigment {color rgb <0.5,2,4>}
       translate <0,5,0>
   }

When this code is rendered an image with a simple box is made:


Modeling cannot be done with POV. An external modeler, such as Anim8or or Wings3D, must be used alongside POV to produce meshes. There are several modelers available that are specifically designed for used with POV, although really any modeler that can export something that can be converted to something POV will recognize may be used.

Since your modeler and POV have no direct contact, you must export your scene as a 3DS file and use the 3DS2POV utility (see downloads) to get the data into POV text. Other conversion routes possible.

POV does not handle keyframe animation, animating with POV is complicated and requires alot of math. However, there is an include file for POV called clockmod which greatly simplifies animation, and even people with the math experience will find it to be quite a timesaver. Speaking of math, POV has many conviniences, for example: vectors are represented with angle bracket notation: . x,y, & z, when used alone, represent the unit vectors i,j, & k, respectively.

Recent versions of the 3ds2pov utility will convert animation. Makes things much easier!

I recommend POV only if you're feisty with math & code. Not worth learning otherwise.

I've made two POV files, templates. One is for making shadows. Download here.

Wings3D + YAFRay

Wings3D is my favorite freeware 3D modeler. It's an efficient program that is very easy to learn, and can be used to produce good quality models in no time.

The interface is pretty good too. To perform an operation, all you have to do is right click in open space and select what you want: it's context sensitive. Except the layout, it's very customizeable.

Wings3D also has a nice variety of export formats.

Like Anim8or, Wings3D has no decent renderer, but it comes with a very nice plugin that directly communicates with a free renderer called YAFRay. YAFRay(Yet Another Free Raytracer) takes info given by Wings, and renders it in one convinient step. To allow for such intricate things as authoring your own procedural textures, you can use the Wings plugin to save a YAFray file and then edit that file with Wordpad. YAFRay uses XML files, which are sharply different from POV, they take getting used to.

Unfortunately, YAFRay is kinda slow, but otherwise it's a great renderer.

You can, ofcourse, export a 3DS from Wings and convert that to POV, if you'd prefer.

Making the SHP

So suppose you've chosen your 3D program, now what? The part of modeling, texturing, animating, etc... is up to you, find tutorials on how to do that specific to your software.

But for SHP making there are conditions that need to be met. Specifically:

Camera

The camera projection must be dimetric. A dimetric camera is special a parallel (orthographic) camera, in the case of RA2 the camera is elevated 30° off the ground:

In some 3d apps, you specify a point the camera points to, in others you specify its direction in angles. For each case:

  • The camera must be positioned at 1,1,.8164965 ; or any multiple of that. The irrational number is (2/3)1/2
  • The camera must point at 0,0,0.
  • The camera must be elevated 30° off the ground.

Some reading about this.

Model

Your model's topmost tip (at the base) must lie at 0,0,0 ; so that when you render it the model's base's topmost part will be at the exact center of the image. Refer to RA2 SHPs to see that graphically.

After Rendering:


Lighting

The light must be parallel, just like the camera. Think of it this way: a light bulb casts divergent rays of light, they diverge outward from the light. The sun, however, casts parallel rays, they all go the same direction (actually they don't, but since the sun is so big and we are so small it seems to be parallel). The shadow cast by the light must be set to hard. For the color I use pure white. The location of the light was found to be (-41.012,100.409,144.338), this is for a right hand coordinate system with z pointing up and the positive x & y axes facing the camera. If your 3D app has a different coordinate system, you'll have to switch the numbers around a bit... The brightness of the light depends on the brightness of the environment. Environment (AKA ambient light) can be thought of as a global illumination. For example, where light isn't cast, something will be dead black, right? In practice that's not true, and ambient lighting will cause illumination in unlit areas. I personally use a brightness of 70% for the parallel light and 45% for ambient (note that these do not add up to 100%, they don't need to).

For TS, the coordinates are (0,51.619,85.448)

Background

Use a plane (infinite if available). Set the color of pure blue (0,0,255).

Shadows

To make shadows, you can either render them seperately or have them rendered into the same image as the reast of your model, and have them split during SHP conversion. To render seperate shadows: first make a copy of your scene, rename this (nameofscene)_shadow or something like that. Now set ALL your materials to full luminescent blue (0,0,255), nothing else. Note that a luminescent surface does NOT cast light contrary to the name (unless indirect lighting is enabled, but nevermind that), instead what will happen is that all your modeling will be pure blue no matter what. Now disable ambient light and make a plane surface, a floor. Set the floor's color to 0,0,255 and set the brightness of that color to something insane, like 100000%. Now render. What will happen is that your models will cast a shadow onto the floor, but since they're blue you won't see any model, just a shadow on a blue background. Rendering everything onto the same TGAs is very convinient, it's dead simple to do: use a high-brightness blue color for your floor (non-luminescent), which will come out pure blue (or whatever you use for BG). Exclude ambient lighting from the floor. The color of the shadow should be color 1 (with 0-based indexing. The second color) on your palette.

The reason we set the floor color's brightness to such a high number is to guaruntee a pure blue color, but unlike the luminscent surface it will recieve a shadow.

Note that if you're modding TS, the background is magenta (255,0,255).

AntiAliasing

AKA AA, this is a smoothing effect done by your renderer. AA must be disabled for SHP making!!!

The thing is that the smoothing effect will cause a "bleeding" of colors to the background color, and when you convert your frames to SHP you will get an assortment of nasty colors on the edge. Color filters work poorly in fixing this.

Ofcourse, leaving AA off solves the edge problem but introduces a new one: your images will look crappy, they look like someone with a master sense of proportion has made the SHP in Paint.

The solution lies in the way AA works: what AA basically does is it renders your model at an extra high resolution then resizes that on the spot. The result is a smooth image of desired resolution. Instead of calculating each pixel, it calculates 4, 9, 16, or some square number subpixels, then averages all those pixels into one.

What you must do is leave AA off and render at a high resolution yourself; for most cases use 3 times the resolution (eg if you want a 100 by 100 SHP render at a resolution of either 300x300 or 500x500). For some cases you may want use 5 or 7 times the resolution (but 3 is almost always sufficient).

Now these images must be resized in a special way...

Resizing & Building the SHP

I made a nifty little utility that'll allow you go from TGAs to SHP in one painless step, called Downsizer: Download it

Read the readme.

Links & Downloads

Blender

POV-Ray

ClockMod

3DS2POV

Anim8or

Wings 3D

YAFRay

Irfanview

XCC Mixer


Concluding words It takes time. Do not think you suck if all you can make is an egg after a week. I've been doing this stuff for over a year yet I learn something new every day. Note that I do not spend as much time in front of computer machines as most people, so you'll probably learn in a shorter time then I.

Do not hesitate to ask me for help, I'll do anything in my power to get as many people as possible making fully original SHPs.

My MSN: meselfs_himself|at|hotmail.com

If you choose to get one of those commercial 3D programs, I recommend any of these:

Cinema 4D | Formerly unpopular and unpractical. Rapidly gaining acceptance. Very powerful & efficient, and very easy to use. Lightwave | A big rival for 3DS; I've heard that once 3DS lUsers try Lightwave they never go back. Maya | Very, very popular for cinematography. Slowly but surely, Cinema 4D is starting to rival Maya. XSI | No clue. 3DS Max | Just kidding! Not recommended!


And remember, AutoCAD will NOT work. Don't even think about it. CAD in general is a bad idea unless you render with something else.

A note on renderer quality

I may have used words like 'photorealism' here and there. A question: do we want this sorta stuff for SHP making? No.

The reason why you would want it is that if you were going to go through the trouble of learning 3D, you might as well have the capacity to make things other than SHPs.




Happy trails!