Monday, July 27, 2009

Fun with Specular Maps and Stanley Fish

For the last few days, in addition to getting a handle on the Blender Game Engine and Python scripting language, I have also been working on developing a workflow for creating 3D game models. Thinking that starting off small would probably be the best way to go, I decided to create a mesh texture for this sign, which I have seen in numerous photos of the Stuttgart Fußgängerzone:


As I was to quickly discover, creating the 3D mesh to begin with was the easy part; actually getting the thing textured in a realistic manner (which, in my opinion, I still haven't quite yet got right) was the more difficult part. The primary problems were the "bump" and "specular" maps that give the 3D model a sense of realism. Let's look at the following as an example:

The top image is a 3D model "straight out of the render box," so to speak, without any bump or specular maps. The problem is, that it looks too good and unblemished to be real. What I really want is what I have seen in real-life: A sign with scratches on the plastic surface that influences how the light gets reflected off the surface. Thus, the bottom image with specular map applied.

However, I'm still not quite happy with the "feel" of the sign as the stainless steel surface, although smooth in real life, nevertheless still has minute scratches and a rough surface that just isn't coming across in the render. I think that I will revisit the sign in a few days and focus specifically on how to use a bump map to get the texture for the stainless steel just right. In any case, here are some animation renders of the sign:





Seeing some of the excellent work that other artist are doing with Blender (e.g., the Angela Guenette Demo Reel), I am somewhat (actually, very) hesitant to post my work here. However, considering that I was originally trained as a medievalist and have branched off into 3D modeling and game programming only recently and am largely self-taught, I suppose that this is not a bad start. Now that I have somewhat of a modest handle on the concepts of bump and specular maps, I will be wrestling with Blender in the coming days to get the images that I have in my head to be reflected in the images that Blender actually cranks out.

Finally, I recently came across an essay by Stanley Fish addressing the use of the humanities in education today. In this essay he argues that the humanities cannot be justified "except in relation to the pleasure they give to those who enjoy them." Although I would agree with Dr. Fish that a humanities education offers something intangible to those who pursue it, something that cannot (should not?) be commodified, I would hesitate in asserting that a humanities education needs no justification within the context of higher education. Not feeling the need to explain ourselves to anyone, we end up explaining ourselves to nobody. How sad that, in a time of expanding global opportunities and falling boundaries, the humanities have failed to make connections to other corners of the academy and, especially in the study of foreign languages, find themselves on a path of increasing isolation. The real power of digital technologies within a humanities context is, I think, the power of making connections and explaining ourselves others in new and innovative ways, which probably explains why The Digital Humanities Manifesto 2.0 took Dr. Fish to task and savaged his 401K.

So, in a small way, I hope that the DigiBahn Project will be a way for German Studies to find points of connection to other disciplines (e.g., computer science, art, instructional design) and reach out to a new generation of students through interactive new media. Ultimately, I'd like to sink my teeth into a more ambitious digital humanities project:
A 3D digital game-based learning environment that explores aspects of the Middle Ages. Think about the connection that this project could make, both in the students' minds and among colleagues at the university!

Wednesday, July 15, 2009

Delving Into Python: Free Stuff!

I just love free programming resources, don't you? Since the Blender game engine uses Python as its programming language of choice, I recently decided to dust off my coding skills (I went all the way up to C3, data structures and algorithms, while retooling as an unemployed, post-PhD graduate) and get more involved with Python. But where to begin?

I found an excellent and thorough introduction to Python, Dive Into Python, on the Web. Good stuff, and even funny! Looking for an IDE I was able to find Komodo Edit 5, which seems to have some good reviews and a Python plug-in. There are some other Python editors out there as well, I'm thinking of Pydev and Eric, but I've played with Komodo in the past for PHP and thought I would revisit it now in a different context. I'll let you know how it goes.

Friday, July 10, 2009

Game Level Map: A Good Start

It occured to me a few days ago that a game level map would not only help us visualize the direction in which we want to go, but would also help us in marking progress and keeping track of what meshes we need to create in order to complete the level. So, after a few hours of tinkering around in Open Office Draw, I came up with the following:


Granted, this is just a rough sketch-up and will probably change as we develop the level, but at least now I have a clearer idea of what the end product may look like. Basically, the player will be inserted into the pedestrian mall and confined there through game-based obstacles (e.g., a conveniently parked postal van) until all the level objectives have been met. Although at this point in time we do not have the game scripted so that the player can enter the various stores, this can be expanded upon in the future.

It was not possible to model the pedestrian mall in Stuttgart as completely as I would have liked due to its length and size. Instead, I have opted for what should be considered a "typical" German pedestrain mall with bakery, post office, and a few stores thrown in for good measure. These features can be found in nearly all German pedestrian zones and therefore should produce good transferable mental schemata.

As it is currently conceived, the game level has three areas:
  1. Immediate pedestrian zone. This consists of the items and NPCs the player will interact with and will also be where the game and level challenges will be housed.

  2. Backdrop. Will consist of buidlings (e.g., church) that the player can see from the pedestrian zone and will change based on player perspective, but which cannot be reached by the player.

  3. Skybox. The distant cityscape and sky.
I have been working on getting Blender down, specifically on applying and baking textures to meshes. As soon as I get a model completed I will post a 360-degree turntable video.

Sunday, July 5, 2009

DigiBahn + Blender Game Engine

Did a quick run-though today of the DigiBahn game with the Blender game engine (BGE). I was able to find a script for mouse/camera control on the Web, although it is using Python 2.5 and many of the functions – its seems – have been deprecated for Python 2.6. Future development in Blender 2.49 and, eventually, 2.5 (both of which will use newer Python releases) will need to take this into consideration and most likely program new code for player interaction with the mouse and screen. I arranged the Blender logic blocks to support a standard WASD key configuration for game movement, although the player movement in the game does not “follow” the mouse; the camera simply pans to where ever the mouse is pointed. Again, something that needs to be addressed in future game prototypes.

Once the BGE is turned on, one can see the physics in effect: The camera drops until it collides with the ground and the camera bounces a bit as it goes down the stairs:



Other than that, the screen capture was done with Blender in a solid viewport draw type as not everything was textured and, accordingly, would not appear in texture draw mode.

While doing the run-through, it occurred to me that future development should focus on these areas:

  1. Player interface. What type of GUI are we going to have? The objects present in the game should also be explained to the player in some fashion as many of them will be immersed in this virtual representation of a foreign sociocultural space for the first time. What about a PDA that the player can access whenever s/he has a question? Perhaps a mashup with Wikipedia that downloads information directly into the game via the PDA screen? This idea sounds promising as a PDA would not interrupt the game flow and many players would have their own PDAs in the real world.

  2. NPCs. Once we get the meshes fleshed out and imported, we'll need to have people to occupy the spaces. The art people on the project probably should focus on character animation and rigging in order to create authentic-looking NPCs.

I'll be spending more time with Blender, making meshes and texturing them. Once I get enough meshes developed in this area, and have developed more competency, I will turn my attention to the BGE and work through some tutorials. I have been using the 2nd edition of The Blender Gamekit, which has been OK (if you overlook the typos), but I have been happier with Mastering Blender as an intermediate introduction to Blender as a 3D content creation suite. Once I got a handle on modeling and the BGE, I'm going to focus more intently on Python as this will be the way to really get the game to do what I want.

Wednesday, July 1, 2009

First Animation Render in Blender!

Well, it took me the better part of the evening to render ~ 13 seconds of video in Blender, but I finally got it knocked down. I didn't take too much time for cleaning up or smoothing the meshes, so some areas are a bit rough. I just wanted to test out Blender's animation capabilities and see how the meshes looked:



We tried to make the scene as realistic as possible to the lower part of the Königstraße in Stuttgart. However, as the pedestrian area would simply be too large for inclusion in the game level, we decided to limit the area through the inclusion of buildings one would normally find in the pedestrian area. The Deichmann building is actually based on the fassade of a building in Oldenburg. Some random information from the rendering process:

400 frames
30 frames/sec
13.33 seconds in length, without intro and extro
23075 vertices
25075 faces

And, in case you are interested, here is a screen capture of .blend file from which the animation was rendered:



Some of the camera turns went a bit quick, making me fairly dizzy, so I lowered the frame rate by 40% while adding the intro and extro in Camtasia. I should be able to do the same in Blender, but I just needed quickly to convert the file to the .mov format before I could upload it to the blog. I also noted that rendering lagged with the light posts; probably because I extracted a circle mesh along a Bezier curve to get these figures, which resulted in a high number of vertices. There also seemed to be a lot of lag time in areas of intense light, which means I should keep an eye on my light sources. All in all, a good first attempt.

Saved by a Python Script

While rendering the first test images of Stuttgart Central in Blender a few days ago, I couldn't help but notice that the handrails on the moving walkway were a bit "chunky," for lack of a better word. This part of the mesh was actually the most difficult part to create as it required me to extrude faces on a curved surface. Apparently my first attempt at solving this problem had not worked as well as I would have liked, hence the chunky surfaces despite repeated attempts at smoothing them out.

So, yesterday I spend the better part of the afternoon playing with all combination of extruding, copying vertices and edges, and scaling to get the smooth handrails that I so desired. After repeated attempts and near the edge of my patience, I recalled seeing a tutorial on the Web on architectural modeling in Blender that just may solve my problem. A Google search later and a few tweaks of the mesh, the following (and improved) surface emerged:

And here is a screenshot of the rather ambiguously named Python script that saved my bacon:

I am particularly intrigued with the "Discombobulator" script and wonder what type of effect it would have on my mesh (or life). . .