KX_2DFilter(BL_Shader)
base class — BL_Shader
- class bge.types.KX_2DFilter
2D filter shader object. Can be alternated with
BL_Shader
’s functions.Warning
The vertex shader must not apply modelview and projection transformation. It should be similar to:
in vec4 pos; in vec2 texCoord; out vec4 bgl_TexCoord; void main(void) { gl_Position = pos; bgl_TexCoord = vec4(texCoord, 0.0, 0.0); }
- mipmap
Request mipmap generation of the render bgl_RenderedTexture texture. Accessing mipmapping level is similar to:
uniform sampler2D bgl_RenderedTexture; in vec4 bgl_TexCoord; out vec4 fragColor; void main() { float level = 2.0; // mipmap level fragColor = textureLod(bgl_RenderedTexture, bgl_TexCoord.xy, level); }
- Type:
boolean
- offScreen
The custom off screen (framebuffer in 0.3.0) the filter render to (read-only).
- Type:
KX_2DFilterFrameBuffer
or None
- setTexture(index, bindCode, samplerName='')
Set specified texture bind code
bindCode
in specified slotindex
. Any call tosetTexture
should be followed by a call toBL_Shader.setSampler
with the sameindex
ifsampleName
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
ifsamplerName
is passed in the function. (optional)
- setCubeMap(index, bindCode, samplerName='')
Set specified cube map texture bind code
bindCode
in specified slotindex
. Any call tosetCubeMap
should be followed by a call toBL_Shader.setSampler
with the sameindex
ifsampleName
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
ifsamplerName
is passed in the function. (optional)
- addOffScreen(slots, width=None, height=None, mipmap=False)
Register a custom off screen (framebuffer in 0.3.0) to render the filter to.
- Parameters:
slots (integer) – The number of color texture attached to the off screen, between 0 and 8 excluded.
width (integer) – In 0.3.0, always canvas width (optional).
height (integer) – In 0.3.0, always canvas height (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 (framebuffer in 0.3.0) the filter render to.