yoyoberenguer / PygameShader

2D Game texture special effects
GNU General Public License v3.0
24 stars 0 forks source link

ImportError: cannot import name 'shader_bloom_effect_array24' from 'PygameShader' #2

Closed f1refa11 closed 2 years ago

f1refa11 commented 2 years ago

I tried to launch the "demo_bloom.py" script, but it gave me this error: ImportError: cannot import name 'shader_bloom_effect_array24' from 'PygameShader'

yoyoberenguer commented 2 years ago

Hi and thank you for letting me know,

Please rename shader_bloom_effect_array24 --> bloom instead

Here

import PygameShader
from PygameShader import bloom

and here


    if keys[pygame.K_ESCAPE]:
                    GAME = False
                    break

            bloom(image, BPF, fast_=True)

            SCREEN.blit(image, (0, 0))
            pygame.display.flip()

This demo version got the previous name of the bloom algorithm Note : I renamed all the methods at version 1.0.3 and uploaded the project without changing the demos script Thank you for reporting this, I will update the demo script to match the new version 1.0.3 to avoid this issue in the future

Let me know if this solved your issue.

PS If you are using python version != 3.8, you would have to compile the source code for your environment.

python setup_shader.py build_ext --inplace --force


This is True if you have downloaded the project from Github website. 
Otherwise please use `pip` to download the right version of the project for your system. 

`pip install PygameShader==1.0.3`
yoyoberenguer commented 2 years ago

You can also found out the methods name in the file shader.pxd

cpdef void saturation(object surface_, float shift_)
cpdef void heatwave_vertical(
        object surface_, unsigned char [:, :] mask, float factor_, float center_,
        float sigma_, float mu_)
cpdef void horizontal_glitch(object surface_, float rad1_, float frequency_,
                                              float amplitude_)
cpdef void bpf(object surface_, int threshold = *)

cpdef void bloom(object surface, int threshold, bint fast_=*)

cpdef fisheye_footprint(int w, int h)
cpdef void fisheye(object surface_, unsigned int [:, :, :] fisheye_model)
yoyoberenguer commented 2 years ago

Bug corrected in version 1.0.4 pip install PygameShader==1.0.4

I have also corrected a bug with demo_fire.py that was not showing the fire effect as intended.

f1refa11 commented 2 years ago

Thanks, it now works!