-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the PygameShader wiki!
Pygame shader project is a 2D game library
written in Python and Cython containing
special effects
for development of multimedia applications like video games, arcade game,
video and camera image processing or to customize your sprites textures/surfaces.
This library is compatible with BMP, GIF (non - animated), JPEG, PNG image format.
pygame may not always be built to support all image formats. At minimum it will support
uncompressed BMP. If pygame.image.get_extended() returns 'True', you should be able to
load most images (including PNG, JPG and GIF).
The shaders can be applied to the entire game display
for a real time rendering @ 60 fps
for games running in medium resolution such as 1024 x 768
.
Some algorithms are more demanding than others in terms of processing power
ex : median filtering and predator vision (due to the fact that it is built with more
than one shader to provide a composite effect). Consequently, not all shader will run at
the same speed at medium resolutions. Feel free to experiment with higher display resolutions
while the shader provides 60 fps or above.
If you are using the shader library for sprites texturing and special effects then the overall processing time should be extremely fast due to code optimization with cython. Nevertheless, to keep a good frame rate, it is advised to keep the sprites below the screen display resolution e,g 200x200 texture size.
rgb_to_bgr(object surface_) -> void:
:param surface_ : Pygame surface or display surface compatible (image 24-32 bit with or
without per-pixel transparency / alpha channel)
:return : void
This shader change a given pygame surface with RGB (red green, blue)
pixel model to an equivalent BGR (blue, green, red) model instead.
This method will also works with surface format different to RGB model,
the shader will swap both channels (red & blue)
The argument surface_
represent a pygame surface object.
The surface is either 24 - 32 bit with or without per-pixel transparency
(Per pixel alphas are different because they store a transparency value for
every pixel).
Surfaces with 8 - bit pixels are not compatible.
This "function" does not return any object (void) and the surface passed
as an argument will be change inplace. Consequently, the surface will have
the same attributes that the original surface/texture
The function will hold a pygame lock while processing the given surface
If the surface is own by another process (locked), the function
will raise an error message. Please refer to pygame documentation regarding
the lock/unlock functionalities if necessary
If the surface is already a BGR model then the output surface will revert to
an RGB surface.
e.g:
rgb_to_bgr(surface_)
rgb_to_brg(object surface_) -> void:
:param surface_: Pygame surface or display surface compatible (image 24-32 bit with or without
per-pixel transparency / alpha channel)
:return: void
This shader change a given pygame surface with RGB
(red green, blue)
pixel model to an equivalent BRG
(blue, red, green) model instead.
This method will also works with surface format different to RGB model,
the shader will swap the red channel for the green channel, the green
channel swapped with the blue and finally the blue channel swapped with
the red
The argument surface_
represent a pygame surface object.
The surface is either 24 - 32 bit with or without per-pixel transparency
(Per pixel alphas are different because they store a transparency value for
every pixel).
Surfaces with 8 - bit pixels are not compatible.
This function does not return any python object (void) and the surface_
passed as an argument will be change inplace. Consequently, the surface will
have the same attributes that the original surface/texture
The function will hold a pygame lock while processing the given surface /texture. If the surface is own by another process (locked), the function will raise an error message. Please refer to pygame documentation regarding the lock/unlock functionalities if necessary
e.g:
rgb_to_brg(surface_)
greyscale(object surface_) -> void:
:param surface_ : Pygame surface or display surface compatible (image 24-32 bit with
or without per-pixel transparency / alpha channel)
:return : void
This shader convert your game display or surface into a grayscale luminosity model. The grayscale mode can be used to change completely the style of your game by adding contrast between the colorfulness of your game and the greyscale equivalent format. When an image or display just seems overwhelmed by color a greyscale or sepia effect can calm down the whole image
It can be used for various effect:
-
to strain the sadness of an action or to display a sad story or special event.
-
to create a scene transition using the grey scale and the full range of color at the beginning of chapter or level.
The argument surface represent a pygame surface object. The surface is either 24 - 32 bit with or without per-pixel transparency (Per pixel alphas are different because they store a transparency value for every pixel). Surfaces with 8 - bit pixels are not compatible.
This function does not return any python object (void) and the surface passed as an argument will be change inplace. Consequently, the surface will have the same attributes that the original surface/texture
e.g:
greyscale(surface)