Material and Texface Game Engine changes

In the beginning there was texface …

Tex Face is part of Blender original design from 15 years ago. The functionality it brought to the Blender Game Engine is still useful nowadays. However its design hasn’t changed and it lacks integration with other parts of Blender.

In order to support this legacy without holding our way to future designs we are introducing a total integration with the old system into the Material pipeline. The changes presented here are already in trunk and will be part of Blender 2.6.

What Changed in a Nutshell:

  • “Texture Face” panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
  • “Texture Face” Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).

New Material Panel

New options in the Material Panel

  • Shadeless option in the Material panel is now supported for all three Shading modes.
  • Physics is now toggleable, this is the old Collision option.
  • Two Side (on) is now called Back Culling (off).
  • Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
  • Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
  • “Face Textures” and “Face Textures Alpha” (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).

The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.

Reasons to Change

The material system in Blender has grown wide and complex. With the advent of new graphic cards, new functionalities came for the game engine with more modern lighting techniques, shading and textures support.

Blender has a commitment of supporting old hardware, and so does the game engine for that matter. Over time this lead us with three shading systems and an inconsistent workflow between them. For example, in 2.59 and before, regardless of your shading mode you need to use the TexFace panel to set things such as Billboard, Collision, Alpha mode. However there is no way to navigate through your mesh and query what faces share what properties. Some of the properties are obsolete (i.e. Shared), and some are supported only in some modes (e.g. Light, more about this later).

By bringing all the settings to the material panel we are exposing to the user something that the game engine already does internally – see here. This takes full advantage of the material management tools such as the option to select, deselect and assign faces based on their materials – which, as we mentioned, was impossible with the old system.

The Painless Way of Migrating to Blender 2.6

or: how to ensure your file will be converted with 100% of success.

If you are working in Blender 2.59 (or even in the 2.4 series) there is a way to ensure you will have no problem when you decide to migrate to new versions of Blender. The golden rule is: do not share materials between faces/meshes when they do not share the same game settings.

Even if you are using the former Texture Face shading mode you can create redundant materials if you don’t want to set lighting/shadeless after you migrate. If you can, use the options per object, e.g. in the Physics panel you can set collision on and off, and also the visibility of the mesh.

On Load Conversion

If some of your meshes have no material but are making usage of texface properties, a new material will be created for them. For non-existent materials the name will be Material.TF.flag, where flag is a number representing the combination of game settings used by this meshes/faces. Faces that had no material and share the same game settings will be sharing the same material as well.

If your meshes all have materials but you are using texface game setting the material will try to be converted. This will be only possible if all the faces using the same material share the same game settings. In case they don’t we have a conflict and the solution is to split your material into as many materials as needed. This would affect “render” files though, thus it’s not done automatically at first. Instead you will see an error message and be invited to convert the remaining materials with a script:

Post Load (i.e. manual) Conversion

If you got an error message while loading your Blender 2.59 file don’t worry. That means it was not possible to automatically convert all your meshes and materials. In the console you can find a list of all the materials that fall on that situation.

Go to the Help menu and click in “TexFace to Material Convert”. Your conflicted materials will be split into copies of the same but with unique game settings. The original materials will be kept in the file, but with no mesh using them they will be removed after you save and re-open your files. This should be enough in 95% of the cases. But …

There Gotta be a Catch

There certainly is. Although most of the usual and corner cases are addressed, there are some decisions that had to be made that will require extra fiddling. The main one is the “Light” flag in the old Tex Face panel. From the three shading systems the former Face Texture and Multitexture are the only one to use this parameter. The GLSL mode, however, completely ignores this. Since the GLSL mode is the latest mode this was the one prioritized here. Therefore if the material of your faces need individual control over the light (on/off) you need to set it in the Material panel in the Shadeless option.

Also linked materials are not analyzed/converted during the load nor the post-load conversions. If you are using material from linked Libraries you need to convert them in their original files.

My Exporting Script was Relying on the TexFace Properties

We still have access at the same functionality as before. But instead of accessing it per face we have it per material. A mesh can have an infinitude of materials which give as much flexibility as the old system.

But Why Do We Keep Breaking Old Files?

Speaking both as a user and a developer I know how painful it’s to find that your old files don’t work as it used to. In order to prevent that, more than half of the coding time for this patch was poured in the conversion code. Sometimes in order to move on we need to let it go of some legacy. If you face any particular problem in dealing with your old files please do contact me. If the needs arise I can put together a FAQ and a list of common pitfalls.

Final Notes:

Things may change slightly before the 2.6 final release. Make sure you read the release log when time comes.

The Future of Overrides
This Summer’s Sculpt Mode Refactor
Geometry Nodes Workshop: October 2024
New Brush Thumbnails

12 comments
  1. When first working with bye I had to search and investigate really hard to finally find out what I had to do to get alpha textures working properly.
    I think it’s much more intuitive to have these settings where they are now.

  2. A bug with alpha has been committed recently (today). Please test and if the problem persist file a bug report? It’s really hard to keep track of discussions in the blog ;)

  3. on blends that worked perfectly before these commits, I’m now RANDOMLY getting an issue after these commits that is NOT allowing me to enable viewport 3D alpha transparency, UNLESS I switch to BGE render mode, and then use the “Alpha Blend:” pulldown menu to select the type of transparency, then switching back to “Blender Internal”. This is VERY bothersome, as I dont need the BGE at all now for any current projects, and am finding it annoying to have to switch to BGE Render Mode just to BE ABLE to select the relevant 3D Viewport transparency settings I need. I can then switch back to “Blender Internal”, and all works as it used to, and should, in the blender 3d viewports. This took me an hour of testing just to randomly see if this “last ditch effort” would revive my model’s transparency in the 3D viewport :-(. I’ve been able to reproduce this for a number of blends now, all blends that had properly functioning alpha transparency in the 3D Viewport before these commits. I update my SVN often, many times a weeks and have seen this issue appear only recently.

    • I’ve started with a clean blend, and attempted to reproduce this with the Suzanne default mesh, and have gotten the SAME issue as I describe above with my own blends.

  4. hello Dalai…
    Somehow Blender is not able to show alpha values in glsl mode. They just appear black! This is only for the viewport.. when starting the bge it works, and rendering works too. But it is annoying when working in the bge, and the alphas don’t work. Is this issue known?

    • The last sentence was ment so:
      But it is annoying when working in the viewport,…

    • Ahh… forget my question! It works! I didn’t know I had to set it to Alpha Blend!

      Works great! And it is really an improvement! Thanks for this updates!!!

  5. Hi EONMACH.

    I don’t understand the point you are making. The behaviour for “non-BGE” users should be the same as in 2.59. If not it’s probably a bug. Could you please report it in the tracker with a simple sample file (created/saved on 2.59) and an explanation of the expected/buggy effect?

    http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse
    Thanks

  6. Hi!!!The transparency of a object in solid mode based on alpha value set in materials(3D view) looks pretty nasty compared to older revisions, what should I do to look like 2.59 trunk?

  7. Bananaft: Billboards and halos are oriented so that faces facing the positive X-axis (worldspace) are rotated to face the camera. There is no need to disable backface culling or flip any normals.

    Just make sure there is no extra rotation on the object (Apply Rot!)

  8. Hello.
    Maybe, if you anyway breaking billboards, you can fix it’s shading, I mean billboards always shaded backwards. And you need to flip their normals and set to Double sided (Backface culling off ;) ) to get right shading.

In order to prevent spam, comments are closed 7 days after the post is published.
Feel free to continue the conversation on the forums.