Skip to content
tristan edited this page Sep 19, 2018 · 1 revision

true

Custom shader bind callbacks

To control the uniforms depending of an object in a custom shader, the user have to apply the proper value just before the object is draft with the custom shader. To allow it python callbacks are added in BL_Shader.

The python callbacks are:

BL_Shader.objectCallbacks
BL_Shader.bindCallbacks

The first callbacks can receive one argument, the object currently rendered. The callbacks are called for every object rendered. The callbacks could be for example:

def objectCallback(object):
	shader.setUniformfv("color", object.color)
shader.objectCallbacks = [objectCallback]

The second callbacks receive none argument and it is called every time the shader is bind, one time before calling at least one time object callbacks.

For a scene with two objects, Cube and Cube2. The following script is blinking two objects, respectively yellow and green.

from bge import logic
from mathutils import Vector

own = logic.getCurrentController().owner

mat = own.meshes[0].materials[0]
shader = mat.shader

def bindCallback():
    print("bind")
    shader.setUniform1f("time", logic.getRealTime())

def objectCallback(object):
    print("object %r" % object.name)
    if object.name == "Cube":
        shader.setUniformfv("color", [1, 1, 0, 1])
    if object.name == "Cube2":
        shader.setUniformfv("color", [0, 1, 0, 1])

vert = """

void main()
{
    gl_Position = ftransform();
}
"""

frag = """

uniform vec4 color;
uniform float time;

void main()
{
    gl_FragColor = color * mod(time, 0.5);
}
"""

shader.setSourceList({"vertex" : vert, "fragment" : frag}, True)
shader.objectCallbacks = [objectCallback]
shader.bindCallbacks = [bindCallback]

Material and texture UI panel refactor

A lot of the UI option unused for the game engine are now removed to simplify the interface. The material panel now looks:

true

The texture panel:

true

Parralax UI refactor

The parralax settings are now put in a new panel in the texture panel, the panel look like:

true

Physics settings

The physics settings were in the material, but only the settings in the first material were used. To avoid ambiguity the settings are moved in the object physics panel. This panel now looks:

true

Standardized and colored messages

All the message print by the game engine are now using standardized format and colored prefix for errors, warnings and debugs. There is an example of these messages:

true

Clean up and refactors

  • Optimize VBO modification. (see #fb20494)
  • Optimize bounding box update. (see #8f84e7a)
  • Move modification flag in RAS_IDisplayArray. (see #8a1e32c)
  • Clean up KX_BlenderSceneConverter.[h/cpp]. (see #92601f6)
  • Remove display list and vertex array render storage. (see #b286d18)
  • Remove usage of using namespace std. (see #996ab30)
  • Clean up KX_CollisionEventManager.[h/cpp] KX_CollisionSensor.[h/cpp]. (see #e91928c)
  • Remove UI face texture option. (see #f5e86de)
  • Remove commented debug messages. (see #14eb890)
  • Simplificate VBO update handling. (see #5718bff)
  • Don't sort object for transparency object in shadow render. (see #6ffd24a)
  • Remove dome in UI. (see #33a03ce)
  • Implement implicit cast in CListValue::iterator. (see #668b9fb)
  • Use CListValue::iterator when possible. (see #d78f606)

Bugs fixed

  • Fix orthographic billboard and halo. (see #5bd1854)
  • Fix environment lighting in blenderplayer. (see #c1d673c)
  • Fix blender player usage loop. (see #660ee15)
  • Fix AABB not initialized to mesh AABB for deformers. (see #4e3edc6)
  • Fix GLSL inverse support. (see #b5238de)
  • Fix mesh active uv and color layer for unspecified texture. (see #b7b3dee)
  • Remove game property range and increase mass limit. (see #e291c4a)
  • Fix elements erasing in KX_BlenderSceneConverter::FreeBlendFile. (see #6d165ed)
  • Fix crash when calling setTexture in KX_2DFilter. (see #77cb6cd)
  • Fix GG.shaders.instancing not deleted. (see #c374b33)
  • Fix KX_TouchSensor not replaced in python documentation and titles. (see #40bb11c)
Clone this wiki locally