KX_2DFilter(BL_Shader)

base class — BL_Shader

class KX_2DFilter(BL_Shader)

2D filter shader object. Can be alterated with BL_Shader’s functions.

Warning

The vertex shader must not apply modelview and projection transformation. It should be similar to:

void main()
{
    gl_Position = gl_Vertex;
}
mipmap

Request mipmap generation of the render bgl_RenderedTexture texture. Accessing mipmapping level is similar to:

uniform sampler2D bgl_RenderedTexture;

void main()
{
    float level = 2.0; // mipmap level
    gl_FragColor = textureLod(bgl_RenderedTexture, gl_TexCoord[0].st, level);
}
Type:boolean
offScreen

The custom off screen the filter render to (read-only).

Type:bge.types.KX_2DFilterOffScreen or None
setTexture(index, bindCode, samplerName="")

Set specified texture bind code bindCode in specified slot index. Any call to setTexture should be followed by a call to BL_Shader.setSampler with the same index if sampleName is not specified.

Parameters:
  • index (integer) – The texture slot.
  • bindCode (integer) – The texture bind code/Id.
  • samplerName (string) – The shader sampler name set to index if samplerName is passed in the function. (optional)
setCubeMap(index, bindCode, samplerName="")

Set specified cube map texture bind code bindCode in specified slot index. Any call to setCubeMap should be followed by a call to BL_Shader.setSampler with the same index if sampleName is not specified.

Parameters:
  • index (integer) – The texture slot.
  • bindCode (integer) – The cube map texture bind code/Id.
  • samplerName (string) – The shader sampler name set to index if samplerName is passed in the function. (optional)
addOffScreen(slots, depth=False, width=-1, height=-1, hdr=bge.render.HDR_NONE, mipmap=False)

Register a custom off screen to render the filter to.

Parameters:
  • slots (integer) – The number of color texture attached to the off screen, between 0 and 8 excluded.
  • depth (boolean) – True of the off screen use a depth texture (optional).
  • width (integer) – The off screen width, -1 if it can be resized dynamically when the viewport dimensions changed (optional).
  • height (integer) – The off screen height, -1 if it can be resized dynamically when the viewport dimensions changed (optional).
  • hdr (one of these constants) – The image quality HDR of the color textures (optional).
  • mipmap (boolean) – True if the color texture generate mipmap at the end of the filter rendering (optional).

Note

If the off screen is created using a dynamic size (width and height to -1) its bind codes will be unavailable before the next render of the filter and the it can change when the viewport is resized.

removeOffScreen()

Unregister the custom off screen the filter render to.