Real-time GLSL Materials

Материал из Blender3D.

Перейти к: навигация, поиск

Содержание

Realtime GLSL Materials

For the Apricot open game project, support for more advanced display of materials in the viewport and the game engine was added. Enabling it is done through the Game menu at the top of the Blender window, and it will then show in Textured draw mode.

In contrast to the existing Texture Face and Use Blender Materials options for the game engine, the purpose of this system is to stick closely to the material system as in Blender's internal renderer. Only a subset of the material options are supported, with hopefully more in the future, but the ones that are supported should give nearly identical results. Some advanced features like raytracing are not likely to be added given that graphics card don't support them efficiently yet.

Graphics Card Support

This implementation takes advantage of the OpenGL Shading Language (GLSL), and requires a graphics card and drivers that support it. The game engine already supported such GLSL shaders, though they had to be manually written. The following cards typically support it, though the earlier ones have restrictions on the complexity of materials and the number of lights. Be sure to install the latest graphics card drivers as they might fix bugs and improve performance.

  • ATI Radeon 9x00, Xx00, X1x00, HD2x00 and HD3x00 series and newer.
  • NVidia Geforce FX, 6x00, 7x00, 8x00, 9x00 and GTX 2x0 and newer.

Intel or VIA graphics cards, ATI Radeon cards older then the Xx00 series, and Nvidia Geforce cards olderthan the 6x00 series are unlikely to support this functionality well, unless through a slow software fallback. The game menu provides settings to disable things such as lights, advanced shaders or shadows which can help on older graphics cards or complicated scenes.

Supported Material Features

In short, the main supported features are:

  • All material diffuse and specular shaders.
  • Diffuse and specular ramps.
  • All nodes, except for the dynamic node and limited support for material node.
  • Image textures only with few options.
  • A subset of the texture mapping options.
  • All lamp types except area, and basic support for shadow buffers.

The following images explain in more detail which features are supported. Yellow indicates the feature is supported, red indicates it is partially supported.


Game Engine Support

The game engine supports GLSL materials as well, and the results should be very similar to would is drawn in the 3d viewport since the same shaders are used. Note however that there are some limitations:

  • Unlike multitexture materials, most material and light settings are currently not animateable with GLSL materials.
  • All objects will compute the lighting for all lamps, even if they are far away or on another layer. Hence it is important to keep the number of lamps as low as possible. For example for outdoor scenes, two sun or hemi lamps can illuminate the whole scene already.
  • The game engine supports maximum two UV layers and no compatible Orco texture coordinates.

Since Blender's materials system was designed for offline rendering and the GLSL material attempt to be compatible with the internal render, they may not render as fast as more optimized game engines. Therefore it is important to optimize the material and light settings for best performance:

  • If some settings are set to values like 0.001 or 0.98, the visual difference with settings 0.0 or 1.0 may be very small, but it makes it harder for Blender to optimize the shader. Therefore it is advised to set such settings to 0.0 or 1.0 so that the effect can be completely disabled and does not need to be computed at all.
  • Various materials shaders are supported, but may perform very slow. Lambert and Phong are fastest, so if possible those should be used. Note that for specularity CookTorr is the default, which can in many cases be switched to Phong without much difference.
  • Additionaly it helps to disable specularity if it is not needed. Not only can the Spec value be set to 0.0 in materials, but it also helps to enable No Specular on lamps, so only one lamp affects specularity for example.
  • If an image does not have alpha, it can help to disable Use Alpha in the texture buttons.
  • Avoid slow texture or ramp blending modes, mix/add/subtract/multiply are the fastest, hue/saturation/value/color are very slow.
  • Alpha blending needs to be avoided if possible, and Clip Alpha is a faster alternative, see the game engine alpha blending notes for more information.
  • For shadows, it is more efficient to bake them for the whole scene, and use an OnlyShadow spot lamp for the character. On this spot lamp it is best to set the shadow buffer size low, enable No Specular, set SpotBl to 0.0. Also then the Layer option for shadow can be enable so that the lamp only casts the shadow of the character.
Личные инструменты