Wednesday, December 14, 2011

Alpa Transparency and Unity

I ran into a problem when I tried to create a material with a transparent texture in Unity.
The image (texture) would always show with a black background on my model. I had saved it as a PNG so it should have worked. The solution was to change the shader on the material to Decal and place the transparent texture image in the RBGA slot (the second one).
Also you can set the shader to Transparent-Diffuse or something similar within the Transparent option. Don't forget to set the image as the texture.
Shader options can be found by selecting the material in the Project panel, then choosing options in the Inspector panel.
link: How do I use Material/Texture alpha on a plane?

Importing FBX files from Blender to Unity

First off, here are two good video to watch:
Importing Blender 2.5 Objects into Unity 3
Exporting a Lowpoly Model to Unity 3D

I had so much trouble with this that its not even funny (well it sort of is now) but it took me an incredibly long time to figure out how to get my lovely models from Blender into the Unity game engine.

Here is a checklist of things you must do and problems you may run into (I'm sure I ran into ALL possible problems):


 "You need to have Blender version 2.45-2.49 or 2.56 or later (versions 2.50-2.55 do not work, because FBX export was changed/broken in Blender)." According to the Unity Manual.
Fix: Get the newest version (2.56a) which seems to be working fine for me.

You may get an error that says: "Object '...' has a scale of ..., Armature deformation will not work as expected. (Apply scale to fix). This is because the model was scaled, rotated, or moved around in object mode. If you don't fix this, you won't be able to save the .fbx file.
Fix: While in object mode with your model selected, click Object > Apply > Rotation (as well as Location and Scale). Be sure to set the origin to (0,0,0) Object > Transform > Geometry to Origin.
link to answer:
BlenderArtists.org: wont export to .FBX

You may succeed in saving the .fbx but find that there is nothing visible when you get into Unity. Also, you may have imported unwanted objects like camera or lights. Or you may have not been able to import animations.
Fix: The first video up top has the answer to that, so watch it for more detail, but basically you have to select the item(s) in Blender that you want to export before you save your .fbx file.
link to answer:
Importing Blender 2.5 Objects into Unity 3

Model imports to Unity VERY small! This problem has to do with Unity - it defaults to import fbx at .01 scale (sort of dumb).
Fix: in the Project panel, click on your imported model > look in the Inspector panel for the FBXImporter section > set Scale Factor option to "1". Then click somewhere else for it to take effect, some message will pop up - just click okay.
link to answer:
Objects from Blender (FBX Exported) are scaled wrong

For a while, my objects were showing up just fine in Unity, but when I pressed play, the model would "disappear"! If this is happening, your object is not disappearing from the scene, it is just jumping its location from where you put it to (0,0,0) the origin of the scene. I was so mad, but I realized that I had missed an important step.
Fix: You have to place a prefab of your object into an Empty Game Object. Click up top on Game Object > Create Empty. Shortcut (ctrl + shift + N). In the Hierarchy panel, the new Game Object will appear. Drag your prefab model object into this Game Object. Rename it to whatever you want.
links to answer:
3d Studio MAX FBX Export question
extreme newb - importing keyframed maya mesh

I highly suggest going to all of the links listed and reading the posts, because they were very helpful to me - they could give you a better idea of what you should do.


While trying to paint trees on a terrain I got this error : "Tree...couldn't be instanced because the prefab contains no valid mesh renderer".
Fix: Be sure to import a single mesh, object, or model or it may break Unity. I had my tree's Trunk and Leaves as different meshes in the saved .fbx file. After I went back in and joined the meshes in Blender and re-exported to .fbx as one mesh, the problem was solved.

Thursday, July 21, 2011

Leg & Foot Rigging: Trial and Error

After trying Tob's tutorial for the first time yesterday, I failed. Not completely, but things weren't working right. I was trying to apply it to my model while watching the video. I renamed bones differently because I didn't like his conventions and so forth - that may have thrown me off.  Last night I spent a few hours toying around with what I've learned so far until I got tired.  It seemed pretty hopeless in the moment, but I learned some IK behaviors in the process.

Today, I started Tob's tutorial afresh from the basic scene - no mesh - no nuthin.  Maybe things have settled in my brain a bit better - I've succeeded in getting through videos 2 & 3 which are the hardest parts (so he says. I'm feeling better about this whole IK thing, but really, I just can't wait to get to the point where I can start animating some actions properly.


Q&A
Here are some questions that I had, my solution, and links to the source.

Q. Why are my bones with IK constraints showing as orange rather than yellow?
A. The bone is not being targeted "correctly". In order for a true IK to work you must target a bone that is outside the chain / is not parented to any bone in the chain with the IK. If the bone is targetless or if auto IK is on, this  means that when you are animating you have to track all of the bones in the timeline individually vs. only having to track the targeted bone.

revolt_randy on BlenderArtist.org :

First off, you don't have a proper IK setup. Notice how the bone with the IK constraint is orange in color. That means there is an error, proper IK constraint setups are yellow in color. The way you have it set up, it works as a 'fake Auto-IK'. You can use it this way, but you have to do a couple of things. First, when you set your keyframe on frame one, you will have to set rotation keyframes for all the bones. It's easiest to just select all the bones, and set loc/rot keyframes for them all. Then make sure you turn on auto keyframes in the time line. (that's where I had my stupid moment) Now advance to frame 31, grab you bone with the constraint and move it. Keyframes will be made for the bone you moved and all other bones that were moved. Then it works how you expect it to.

You can also, remove the constraint, and in the toolshelf, select the 'AutoIK' option, then repeat as above, does the same thing.

To make a 'proper' IK chain, you need to add one more bone, which acts as a controller for the chain. This extra bone cannot be parented to any bone in the IK chain. Then you can control all the bones in the chain by just keying this one bone.
view entire thread


Q. How do I lock rotations in an IK chain?

Inverse Kinematics options

A. The closest thing I've got is the documentation on WikiBlender.org,  but the documentation is for version 2.4:  http://wiki.blender.org/index.php/Doc:Manual/Rigging/Posing/Inverse_Kinematics
I've found that in 2.5 the options / settings are in (Armature Pose Mode) Properties Window > Bone Panel > Inverse Kinematics.  Here you can lock the bone from rotating in certain ways even if it's in an IK chain.

In order to limit a bone's rotation / location / scale in any other scenario, you can select the bone, then add a Limit Rotation / Location / Scale Bone Constraint from the Bone Constraints Panel while in Pose Mode, or toggle Transform Locks in the Bone Panel while in Pose Mode.

Wednesday, July 20, 2011

Leg & Foot Rigging

Wow, when it come to rigging and Blender, this guy really knows what he's talking about it seems:
Tobuslieven Youtube Chanel

Image of rig from Tob's tutorial

The last tutorial I found for rigging a squat or sit was pretty bad in hindsight, or was just too simple for what I want to achieve. Problems came up when I tried to move the foot independent of the leg. It was not a very sound structure for animation.

Tob is making some clean rigs that I can't wait to try. I'm going to eventually scrap my last leg rig (uuug) and try out this one.  His tutorial is in version 2.5 which is a plus for sure, and following the foot tutorial he has a tutorial for a leg rig which I haven't viewed yet - all of which can be found here:
Youtube Playlist: Blender 2.5 Foot and Leg Rigging Tutorial

Thanks Tob, and everyone who takes the time to make tutorials, even the ones that turn out not so great. I've learned something from every one that I've viewed so far.

Tuesday, July 19, 2011

First Human Character: Progress

I haven't been tracking my progress very well, but I have been learning a ton. Here is a screen shot of my most recent model:

my model squatting / sitting using IK Constraints
I'm being lazy about my blog but here are the steps and skills I used to create her:

PREPARATION
> Created orthographic sketch in MyPaint and GIMP
> In Blender, added sketch to background and split 3D window and set to front and left orthographic views

MODELING

> Added a mirror modifier to a cube split down the middle and mirror-modeled one side of body mesh (body mesh included body arms and feet)
Mirror modeling saves a ton of time and allowed me to work maybe 3-5 times as fast because I didnt have to manually match up left and right and I didn't have to duplicate or create anything separately.
> Modeled hand mesh in separate file, saved as .dae and imported to main character file
> Joined hand and body mesh
> Created head from a split UV sphere in body mesh

> Created left side of armature naming all future duplicate bones with the extension .L

TEXTURING

> Created UV map of completed mesh for texturing
> Textured a bikini using MyPaint and GIMP (Linux OS so no Photoshop)
> Learned how to implement transparent (alpha) UV textures
> Learned how to map a texture onto a material and use premul (premultiply) for smoothing of edges


ARMATURE
> Parented armature to mesh with named groups
> Manually assigned all vertices to vertex groups
> Created a couple items like a hat and hair, then parented to head bone of armature.> Tested rigging thoroughly
> Mirrored armature
> Learned how to automatically rename .L extension to .R by pressing Wkey in Edit Mode
> Combined armatures

> Learned how to automatically create reflected vertex groups and apply to complete armature

IK RIGGING

Now I'm learning how to create IK chains - it's probably been the most frustrating step next to learning how to implement textures with alpha.  However, it might just be me making a simple thing into a difficult one - I tend to do that sometimes.

RIGGING CHARACTER TO SIT AND SQUAT

My most recent breakthrough was rigging my character to squat or assume a sitting position using IKs. I watched these videos and found the solution:

Video 1 teaches you how to set up the pelvis bones:
Blender Rigging Intro Part 1

Video 2 sets up the patenting hierarchy and foot bone IK targets:
Blender Rigging Intro Part 2

Video 3 finishes up the IK constraints and targeting so the character can sit or squat :
Blender Rigging Tutorial-Part3

This guy's video is alright, I got impatient watching it, mostly because he makes mistakes in one vid that you have to be sure to go back and fix once you see it in another. Pay close attention to his set-up, IK rigging, and mistakes through all three vids and you should be alright.

EVENTUALLY

Eventually, I'm going to create some tutorials of my own for others to view, but right now, I'm too busy making mistakes and learning from them. If there are any questions about the steps that I make above, feel free to leave a comment, and I'll elaborate.

Tuesday, June 21, 2011

First Human Character

Alrighty, so I already know this entry is going to take a couple days, and possibly cause me a few headaches, but it should be fun. I'm going to create a human-like character in Blender 2.5 starting with an orthographic sketch, and moving on to a double-view mirror-editing technique. If you haven't already seen it go to my last entry about My Blender Beginner Resources and see Peter's Massive Blender Tutorial for an example.


The Orthographic Sketch
An orthographic sketch makes things easier to shape. In order to model in 3D, you need at least two views, and it is best to choose two important views - front and side. To start I drew an orthographic view. In order to properly create an orthographic view, you need to pretend that your character is facing you inside of a glass box. If the subject is facing you and you turn your box to the right (clockwise from the top), your character would now be facing left. This is an important concept to learn! Here is my example below. You may understand clearer from the sketch:


character faces front & left

If the figure on the right was facing the other way, this would be wrong!

Also, you may notice that I drew parallel lines and labeled them on the far right. This is so that both drawing are drawn on the same height scale. The head must be the same height, the torso must line up, the legs, arms and feet must be the same height in both drawings!  Seeing as your 3D model will be a composite of both views, they need to share the same heights.

Well, this is it for now, more to come. I'll talk about setting up Blender to begin modeling next!

Monday, June 20, 2011

My Blender Beginner Resources


Starting off, I was very tentative.  I didn't understand how I was going to be able to create 3D objects on a 2D screen.  I thought modeling would be super technical and complicated, but once I got used to navigating the view and using the basic tools, I discovered that it was surprisingly simple.  I could write some tutorials on the basics, but it would be super redundant seeing that there are great resources out there already.

Blender.org Video Tutorials
As I said before, I started Blender with little to no previous knowledge or experience with 3D programs, so my first stop was the Blender.org website. They have a listing of 7 video tutorials that will give you a basic introduction to Blender.

Gryllus.net Blender (2.5) 3D Design Course
This is a free course that teaches Blender from square one and is probably one of the best recourses I've found.
There are links to great videos and he has lists of projects that you can do. Two very helpful videos in Unit 2 were about rotation, pivot points, and center points :


Peter's Massive Blender Tutorial

Peter's Massive Blender Tutorial is a kick-ass 9-part Youtube tutorial series by PXstriker that teaches you his method of modeling low poly characters. I suggest getting comfortable with some basic controls first - he goes a bit fast.

Chapter 1 - Blender Basics (basic commands)

Chapter 2-1 - "Modeling" (setup mirror modeling & model the body)
Chapter 2-2 -  continued (arms & joints)
Chapter 3 - "Hands"
Chapter 4  - "Heads" (hair)
Chapter 5 - "Meshing the Meshes" (combining meshes / attaching)
Chapter 6 - "Texturing" (UV texture maps)
Chapter 7 - "Bones" (armature & animation)
Chapter 8 - "Rendering"

HotKeys Reference
Here is a great reference for hotkeys that's gotten me out of many a sticky situation:

How I Killed Blender With Subsurfaces... Oops

During the week or so I have been working, Blender has only crashed once, and that was my fault - I added a subsurface modifier to a mesh then set the subdivisions to, say, possibly 100! This cut up the surface of a mesh into thousands of smaller polygons, and created some kind of math that my computer couldn't handle. Needless to say - don't do that when you learn how to use subsurfaces and subdivisions. 
Anyway, this is how I did it, and this is also how to create a subsurface modifier if you are curious:
  • In Blender 2.57 open a new project
  • Right click your default cube (it should already be selected)
  • Go to your Properties panel (hover your mouse over a panel and press SHIFT+F7)
  • Go to Modifiers (the wrench icon) > Add Modifier > Subdivision Surface
If you look at your cube in the 3D View window you'll notice that it has "rounded out" into a clumpy spherical shape. If you increase the subdivisions, this breaks up the 6 faces of the cube into more and more polygons. With the next two steps I managed to kill Blender.
  • Found Subdivisions option and set to 100 (or anything over 7 I've come to find)
  • Pressed Enter ( KABLAMO - broken )
click to enlarge

As a side-note, I found when you set Subdivisions, be sure to set both View and Render.  If you don't adjust the Render property, your rendered image or animation will look different than your view.  Keeping the View number low when making a model and rigging animations helps the program run faster in real-time playback (there are less polygons to keep track of).

Friday, June 17, 2011

Invert Z-Depth ( Back-Face Culling ) in Blender 2.57

These are some of the first things that I created to start off in Blender and how I made them.

A Cube Inside of Another Cube
My first few creations were inspired by an artist on Deviantart.com - Cezkid.  He makes 3D pixelated 8-bit video game characters (voxel models) that I found to be pretty novel - Cezkid Voxel Characters. He uses Google SketchUp not Blender.


cube inside of another cube with Invert Z Depth enabled
So at first glance, this cube looks quite unimpressive. You'd think it was just a cube with a big blue border around it, but it's not. And it wasn't that easy to figure out how to execute.  I asked Cezkid for some leads and he mentioned "back-face culling". Well it was a lead, but it did me little good because Blender doesn't have an option named back-face culling or anything similar.  Also, this was my first model, and I had little to no idea how to determine the visibility of a polygon or face.  After many hours of Googleing and tweaking, I happened to stumble upon the Invert Z Depth property (Zinvert in earlier versions) by accident - success.
Brief Invert Z Depth Explanation:
These are two cubes- a small one ( solid grey material with Recieve Shadows and Cast Shadows turned off and Z Transparency turned on), and a bigger blue one ( solid blue material with Shadeless and Invert Z Depth property turned on).  This creates a mesh (the big cube) that has transparent faces when they point to the camera.  This also works on two-sided faces in case anyone's wondering. Read on to see exactly how I did it.



Invert Z Depth Tutorial:
You don't need an actual mouse with a wheel for this tutorial. A touch pad will suffice.
  • Open a new Blender project
  • Right click on the cube in the 3D View to select it.
    selected cube object
  • Go to Properties Panel (SHFT+F7) and select Material
  • Materials icon in Properties panel
  • Scroll down to Shading and check Shadeless
  • set Shading to Shadeless
  • Scroll down to Options and check Invert Z Depth
  • Inver Z Depth
  • Place the cursor in the 3D View and press the ZKey to show the cube in Mesh mode.
  • Be sure the cube is selected and press SHFT+DKey to duplicate the cube. 
  • Press ESC (otherwise the duplicated cube will move around)
  • Press SKey > type the number .5 > press ENTER (this scales a cube down to half size)
  • scaled cube inside duplicate in mesh mode
  • Now be sure that the smaller cube is selected and go to the top of its Material panel.
  • Remove the Material by pressing the minus-looking button.
  • Remove material and add a new one
  • Press the + New button that pops up.
  • Check the Transparency option and enable Z Transparency (THIS IS IMPORTANT)
  • enable Z Transparency in the smaller cube
  • Scroll down to Shadow and un-check Recieve.
  • un-check Recieve in Shadows option
  • Press F12 to render!



If everything went smoothly, you should see this:


 Hope this may help anyone who may be looking for something similar. I have no idea how this will hold up under other scenarios or circumstances, but it worked for this example.



Other Objects
Here are two other objects that I created with the same concept.





Setting Up Blender 2.57

What - It's Free?
Yes, Blender is open source and is no cost to download and use.  I didn't know that a free program could be so elegant.
Download from official site : http://www.blender.org/download/get-blender/

Shaking Hands With Blender

So when I first approached Blender, I wondered if it would even work on my machine. I have an Asus Eee PC 1005HAB Netbook.

Brief Specs:
Memory - 2 Gib
Processor - 1.60 GHz (Intel)
Operating System - Linux Mint

Nothing special to say the least. I was worried that my little netbook may not be able to handle a 3D program, but Blender is pretty gentle.  My computer and Blender make pretty good friends. There is no lag (except in Weight Paint mode, and it takes a while to render animation). So even if you think your computer may not accept Blender, try anyways. What's the worst that could happen?


Blender 2.57
I'm using Blender 2.57.  This has been one shortcoming in my learning process since it seems that the entire interface has had a complete makeover since previous versions. They have reorganized a lot of things, and even some of the hot keys are different from 2.4 and before.  I have been reading a book "The Official Blender 2.3 Guide" and have been fumbling with interface - trying to find certain properties or tools and such.  Even most YouTube tutorials haven't caught up with the new interface.
In short, if I have trouble finding this or that, and I figure it out, I'll post it up here, both for my own reference and for others who may be feeling the same pain.  Oh, the woes of being a noob.

Linux and Blender
According to Blender.org running Blender in Linux (as opposed to Windows) is beneficial when it comes to speed, you can read more here: http://www.blender.org/education-help/faq/linux/

Installation on Linux
My installation experience - the short answer - I didn't install it myself.  I'm new to Linux so I had help. Initially, I installed version 2.4 from the Software Manager, but I wanted the latest version.  Now I see that Software Manager is dishing out version 2.57.1 so it should be alright to just search for Blender and get it from there. Good luck, with your installation!

Thursday, June 16, 2011

Purpose

I am new to Blender and 3D modeling in general, so I decided to start a blog to track my progress and share this experience. I'm a 2D artist with little to no 3D modeling experience. I fumbled around with AutoCad in college for a required course, and it almost turned off my interest in 3D modeling completely. My interest has been revived with the prospect of modeling, rigging, and animating characters for game engines.

Up to this point, I have been working solo with Blender for a week (reading books and watching tutorials on the web).  I'll upload some things I've created so far and post my favorite links.

Enjoy