Showing posts with label models. Show all posts
Showing posts with label models. Show all posts

11.23.2012

The UVMapping Hurdle.

I'm actually writing this post while I'm in the middle of figuring this out.

This has actually had me stuck for a long while now, and that's model/mesh texturing. In a perfect world, I feel like you should be able to just directly paint onto the 3d object and save it as a texture file to use later. That's probably an option for the really high-end stuff, but when you use the free stuff beggars can't be choosers. I've known for a long time it's possible though, and it involves this thing called UV Mapping. I don't quite get all the technical bits about it, but the important part her is that UV maps take 3d objects and flatten them out into 2d schematics. Those 2d pictures are what you use to create textures on/with.

For a while, I thought I could get away with not doing it. I thought maybe if I could get clever enough I could make my models efficient enough that I could just do a simple material instead of a full texture. That doesn't work though, and at it's best it still wouldn't look that great. It doesn't help that it looks like it should be incredibly easy. Blender has a button that says 'Unwrap to UV' and another to 'Export UV map to png'. Over in Unity, you can apply a texture with a regular drag-and-drop directly onto the model.

I can't count how many weeks I've been stuck on trying to get this to work. Only right now do I think I may have finally cracked it, so here we go. Right now, I'm using the Y-Frame from the Unicycle as my experiment. It's a custom mesh made of 2 separate pieces overlapping. The top bar (the seat would be connected to the top) is a cylinder that flares at the bottom. That opening is normally hidden by the bottom half, which is another cylinder that's been elongated, bent into shape, and the ends have been tapered off where the axle for the wheel would go. Looks like an upside-down tuning fork.

It's also the front half of the bicycle.

The answer to my problems is a single button that says 'Mark Seam'. It's not very descriptive on it's own, but  it does exactly what it says. You pick out a line of points and click that button to create a seam in the object. Then when you go to unwrap it, Blender has a point of reference for how to unwrap it. I don't think there are any specific rules regarding how you're supposed to mark of the seams, like if you're supposed to open it top-down, or sideways, or whatever, so I went with what made the most sense.


You can ignore that one grey square. That's some dumb Blender thing.

That's a top-down view of both separate pieces of the frame. Now from here, I can export it as a png and use it as a texture template. This is extremely helpful if you have super hi-poly models, because you can craft intricately detailed models, flatten them out, save that texture, then paste it on a low-poly model to make it look identical. I haven't gotten that far yet, but I don't think I need to right now. My current vehicles are already low-poly and look well enough. It'll probably more important later when I start working on level art and assets.

Anyway, now that I have this uv map, I think I'm supposed to export it to Gimp, paint a texture file, save it, bring that back over to Blender, and replace the 'blank' uv map with the painted one. I'm still a bit fuzzy on details, but if this works it'll be a huge breakthrough. I still have to deal with getting it to work in Unity, but at least things are moving in the right direction.

There is still one other annoyance I need to solve in Blender. One of its options lets you split the screen up in many different ways, and each panel can be any combination of Uv/Image editor, Render Viewer, Animation Console, Default Workspace, and several other such choices. It's pretty handy and sometimes mandatory. The problem is that each window can be resized or created, but not deleted. Furthermore, if you shrink the window at all the other window(s) don't move to compensate, but instead just create a duplicate window. You can sort of resize it to almost-zero, but not really. The only way I know to fix it is to just save everything and restart Blender. Seriously, look at this mess. That's about a dozen different window panels of the SAME THING. Ridiculous. I wish I could say that that's the only time it's happened to me. Today.

7.31.2012

Baby's First Performance Issue

A couple days ago I decided to jump the gun a bit, and now I'm glad I did because it's taught me something new and caught a huge mistake early enough that it can be fixed.

One of the downsides to working alone and self-teaching is that it's incredibly easy to miss things, big and small. What I missed was that there's an inherent limit to the amount of "stuff" that can be rendered at any one time. And that makes sense to me, computer power isn't infinite. What I did was grossly overestimate how much stuff I've actually been making. Take for example the following:

Cue the circus music.

That's the first vehicle, made over one single night. It's not textured or properly shaded yet, but that's ok because it'll be easier to do in Unity. Since I'm all about efficiency, I can take parts from this and use it for the bicycle model I have planned and save a fair amount of time. Looking back, I still maintain these are good ideas in the right direction, but I was slightly wrong because I didn't have enough knowledge. Here's another look at the same unicycle:

POLYGONS!

That's the 3d mesh version, and if you zoom far enough in you can manipulate each individual vertex, line segment, or polygon. This unicycle is made of a little over 32000 vertices making nearly 27000 polygons. To put that in perspective, the models Capcom did for RE5's cutscenes only have about 20000 polys. Of course I only just now looked that number up, but maybe you can see where the problem is. At the time though, I'm still proud about making a pretty nice looking model. Charged by this excitement I wanted to drop it into Unity right away, put some basic movement scripts on it and see how it looked.

It didn't go well. To be honest, it didn't go at all. It took minutes to render, and when it finally did, the fps dropped to about 0.2. This was from only 1 (relatively simple) vehicle and 1 plane (4 vertices and 1 face). If I go through with making this an 8-player simultaneous game, then adding the the level and all the decorations, I can only think about my computer melting because of it. I was disappointed that this great job I did turned out to be not great, but more disappointed that I'd have to go back and redo a lot.

Optimization is mandatory. It's not something I wanted to do at first, but it's necessary and it's given me more ideas on how to streamline things for later. Looking around on Google for a while, I came to realize the following:

* It's not so much about the polygons as it's about the vertices.
* For each mesh, take into account the number of materials and shaders applied, the complexity of the physics applied, and the number of attached scripts. Each of these gets refreshed on each redraw for each frame and can tank performance.
* Redundancy is a bitch. If an asset (a tire, a seat) can be reused more than once, save it to a separate file and rebuild the object(s) in Unity later.
* Baking is something I need to learn. Yes, I'm well aware of the irony.
* A sense of scale is important. There's no sense in making ridiculously detailed models if it's too small to be seen. Those tire treads above? 23k vertices and they wont hardly be seen by the time you scale the model down to fit in the level.
* Similarly, there's no reason to render things that can't be seen. Any "invisible" polygons are just wasting time and power.


Baking (as mentioned above)... I don't know hardly anything about this. From what I gather, you can break meshes down into flat files to make thing render easier later, or something? I'm supposed to use it on high-res models to apply to a low-poly model to make it look really high-res, but Blender doesn't make it easy to figure out.


All of this leads to me cleaning up my models, redoing a few of them yet again, and trying to build them "differently". As mentioned above, redundancy can be worked around but you have to have each piece separate from the whole. With the Unicycle above, almost all of it can be reused for the bicycle later, so the Seat, Pedals and Assembly, Wheel, Spokes and Metal Rim, and Y-Frame have to be separated to be imported later. Once I get to Unity, I can import each individual object, put the pieces together and save the schematic as a Unicycle GameObject. After I finish making the bicycle frame in Blender, I can add that too, use the other imported parts, and make a bike with only one new asset. It's a bit disjointed to think about, but if it's going to make things run better than I'm all for it. Here's a preview:


Look at all of those vivid colours.

It still has a long way to go, but it's going alright so far. You can see the reused Unicycle assets here, but it's the "unoptimized" assets. Since making that bike, I've cleaned up the Unicycle a bit. I've reduced the vertices from 32k to just under 5k just by cleaning up unnecessary things. Rebuilding the bike wont take much time, and the only new asset to clean up will be the bike-frame and I'm not even done making that.

After the bike, I'm working on the next vehicle. I'm making a pogo stick.

6.12.2012

Literally reinventing the wheel.

Several days later, I don't have nearly as much to show for it as I'd like. I've made and destroyed three different models so far, and I'm working on number "about-three-and-a-half-ish" right now. The more I make them, the more I realize that I hate the design and need to learn more. Seriously... while I'm picking up on the nuances of Blender, there's so many options that it's still unwieldy to use. Watching a 20 minute tutorial takes upwards of 2 or 3 hours, and only scratches the surface of one particular thing (usually without actually explaining the "how and/or why" part of things).

I know I harp on this a lot, but Blender is nigh-impossible to to use without tons of external help and support. An example I came across earlier; want to open a background picture to trace over? First, you have to push N to open another menu (by default this is turned off (Seriously? A hidden but important menu?)), check Background Images, expand that menu, click add image, search for the image, apply the image, expand the View menu, change the opacity (default is 0; completely transparent) and size (default is miniscule), accept the changes, AND THEN you have to find it. Because it's a 2d image in 3d space, it's only viewable when the camera is locked to one of the 3 planar views. All of this to open an image you can't even manipulate. But I digress.

The first design was a flat skeleton that didn't have any textures applied to it (because I couldn't figure it out). It had the basic shape right but wasn't more than a flat white bumpy cylinder and box with 2 tubes on it. The second model was about when I figured out how to smooth the surfaces AND add colour. Still a far cry from where it needs to be, but inching closer.

Model 2: For legal reasons, this is not a Segway(tm).
See that tire texture there on the right? You'd think it'd be easy enough to line it up proper and texture the wheels, but then you'd be wrong. I can't even recreate how awkward it looked, but take my word for it; it looked less like treads and more like bluish marbling. Horrible. It had to go. The third design was a smidge better. A couple minor changes to the body (seen below), but nothing amazing.

Model 3: Untextured
Model 3: Textured, still horrible.
I tried adding a brushed-metal texture to the frame of the body, and the result was... less than desirable. It's like I'm slowly progressing through history; starting with Starfox SNES and ending up just before Quake with all the visual effects turned down. The current version has a long way to go, but has stepped up another generation.

Model 3.5: Gentlemen, BEHOLD!
This was another case of things being non-intuitive, but at least I figured out how to design proper tire-treads from scratch without textures. This was a complete rough-draft design, they're not great, but I'm not too worried about it. I'm actually fighting the urge to go back and re-re-re-redo them. On a tiny screen, no one is going to be able to see the tiny details like sidewall writing. The next thing to tackle today is finishing a new rim design. Then the main gearbox/motor/platform assembly, the steering column, and the finally the handlebars. Only then can I worry about other things like level design and assets.

Given the current pace and workload, I may have to pare back the total number of vehicles. I had planned for 3-5 different selectable vehicles but right now I dunno. I'm more concerned with getting 1 vehicle and 1 track finished and working, at which point I'll have figured out enough infrastructure to add more later.

6.06.2012

The "joys" of working with Blender

Amidst all the madness of E3 I found some time to start official work on the games. Most of the 'planning' stuff is already done, I have a decent idea of where I want to go and how to get there, I can sort of the details later when I get to it. The first step I took today was making the models. I gotta say though, it's a very slow start.

Given 2 programs, Blender and Unity, I know (roughly) what each one is capable of, but not their full potential. The original plan was to make all of the models in Blender, import it to Unity, and finish everything there. My first impressions of Blender aren't entirely positive. I'm familiar with Photoshop and Illustrator and the like, but Blender has billions of options and nearly all of them are unlabeled. Options disappear, reappear, and change dependent on which mode you're in and with which type of object you have selected. Most of the basic/common actions are bound to the keyboard but there's no real mention of this anywhere. The fact that I have to use a tutorial to figure out how to do the most basic things isn't a great start. It took me nearly half an hour to figure out how to move the camera, which is ANOTHER dumb thing. It's mapped to the middle-mouse button of all things, which means I can't use it at all on my laptop, and I had to manually remap my mouse to make it work.


GAZE UPON MY INFINITE COMPLEXITIES

BUT! After all that, if you can look away from the labyrinthine layout, it's actually pretty nice. I haven't figured out how to apply textures (even though I see options for it all over the place none of them have actually done anything yet) but I feel like I'm getting close. By the end of the day, I hope to have that sorted out and have a fully functional model.

In the interest of experimenting, the next logical step was to move to Unity and see what I could do. Importing Blender files was surprisingly easy, which is promising for later. The overall layout is a lot cleaner, but therein lies a new problem. It's intuitive in exactly the opposite direction from Blender. It's easier to choose objects, but harder to manipulate them. It's easier to move the camera, but I can't figure out how to re-position it to point a different direction. It's easier to fine-tune the exact coordinates and sizes or objects, but they can ONLY be changed by manually typing out exact decimal numbers for each individual object.


Less is More is Less.

To be fair though, just because I don't know how to do it (I only looked at it for about 30 minutes with no tutorials or background) doesn't mean it can't be done. It may ultimately be easier than Blender for all I know. Personally, I'd prefer to do it all under 1 roof instead of shuttling files around between multiple programs, but I suppose a single one-way transfer isn't too bad. That was the original plan after all, who am I to stray from it?