-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Yoann Berenguer edited this page Aug 21, 2022
·
24 revisions
Welcome to the PygameShader wiki !
Regading the GPU shaders
You can fetch some information regarding the GPU capability
and the
correct values for block
and grid
(given a specific screen resolution)
from PygameShader.shader_gpu import *
get_gpu_info()
block_and_grid_info(WIDTH, HEIGHT)
The line below automatically select the grid and block for you. These values
are compulsory for some of the GPU shaders.
You have to get these values only once after initializing the Pygame display
or each
time the resolution has changed.
grid, block = block_grid(screen.get_width(), screen.get_height())
Check the demo folder for a complete example of running GPU shaders
Example of GPU shader call:
chromatic_effect = chromatic_gpu(screen, mouse_pos.x, mouse_pos.y, grid, block, 0.999, fx=VARIABLE)
screen.blit(chromatic_effect , (0, 0))
pygame.display.flip()
zoom_effect = zoom_gpu(screen, mouse_pos.x, mouse_pos.y, grid, block, VARIABLE)
screen.blit(zoom_effect , (0, 0))
pygame.display.flip()
Here the list of all the GPU shaders:
PS - Some of the shader(s) will be removed in the next version if the performances are not improved compared to the CPU version.
invert_gpu(surface_)
invert_inplace_cupy(cpu_array_)
sepia_gpu(object surface_)
bpf_gpu(object surface_, unsigned int threshold_ = *)
bpf1_gpu(object surface_, grid_, block_, unsigned int threshold_ = *)
grayscale_gpu(object surface_)
grayscale_lum_gpu(object surface_)
median_gpu(object surface_, unsigned int size_ = *)
median1_gpu(object surface_, unsigned int size_ = *)
gaussian_5x5_gpu(object surface_)
gaussian_3x3_gpu(object surface_)
sobel_gpu(object surface_)
prewitt_gpu(object surface_)
canny_gpu(object surface_)
color_reduction_gpu(object surface_, int color_number = *)
hsv_gpu(object surface_, float val_, object grid_ = *, object block_ = *)
mult_downscale_gpu(object gpu_array)
downscale_gpu(object gpu_array_, int w, int h)
upscale_gpu(object gpu_array_, int w, int h)
bloom_gpu(object surface_,
unsigned int threshold_ = *,
bint fast_ = *,
int flag_ = *,
unsigned short int factor_ = *
)
bloom_array(
object gpu_array_,
unsigned int threshold_ = *,
bint fast_ = *,
int flag_ = *,
mask_ = *
)
cartoon_gpu(
object surface_,
int sobel_threshold_ = *,
int median_kernel_ = *,
unsigned char color_ = *,
bint contour_ = *,
unsigned char flag_ = *
)
blending_gpu(object source_, object destination_, float percentage_)
sharpen_gpu(object surface_)
sharpen1_gpu(object surfaace_, grid_, block_)
ripple_effect_gpu(
object grid,
object block,
int w, int h,
previous,
current,
texture_array,
background_array
)
mirroring_gpu(
object surface_,
object grid_,
object block_,
bint format_ = *
)
saturation_gpu(
object surface_,
object grid_,
object block_,
float val_ = *
)
bilateral_gpu(surface_, unsigned int kernel_size_)
emboss5x5_gpu(surface_)
area24_gpu(int x, int y,
object background_rgb,
object mask_alpha,
float intensity=*,
color=*)
brightness_gpu(
object surface_,
float val_,
object grid_ = *,
object block_ = *
)
hsl_gpu(
object surface_,
float val_,
object grid_ = *,
object block_ = *
)
fisheye_gpu(object surface_, float focal, float focal_texture, object grid_, object block_)
swirl_gpu(
object surface_,
float rad,
object grid_,
object block_,
unsigned int centre_x,
unsigned int centre_y
)
wave_gpu(object surface_, float rad_, int size_, object grid_, object block_)
rgb_split_gpu(
object surface_,
float delta_x,
float delta_y,
object grid_,
object block_
)
chromatic_gpu(
object surface_,
unsigned int delta_x,
unsigned int delta_y,
object grid_,
object block_,
float zoom = *,
float fx = *
)
zoom_gpu(
object surface_,
unsigned int delta_x,
unsigned int delta_y,
object grid_,
object block_,
float zoom = *
)
***