Skip to main content

PythonFireFx

PythonFireFx is a shader for rendering 2D realistic fire effect (procedural fire). Written in python, cython and C language, it is design for real time rendering on pygame surface with screen resolution up to 1280 x 1024 pixels.

Compatible with image format 24-32 bit with any of the following extension: BMP, GIF (non - animated), JPEG, PNG image format.

It was originally designed for 2D video games application build on the top of Pygame library, but it can also be used as a plugin for video or webcam special effect. It requires few libraries in order to work, please see the dependency section for more details.

The algorithm has numerous options to control the fire envelop/aspect. All this options can be defined as static or dynamic in order to produce a more realistic fire effect:

Some of the options :

  • Blur algorithm (to smooth and produce a warm /fluid fire effect)
  • Palette (pre-defined color wavelength's values set in a numpy array)
  • Smoothing effect to add a realistic touch
  • Fire intensity to control the fire energy at the base
  • Bloom effect to create local flickering light effect or add texture volume to the fire (depends on the bright pass filter value)
  • Brightness control (fine control that change the fire volume and intensity)
  • The palette can be disregarded, and a default palette can be used with colors defined by HSL (hue, saturation and luminescence values) that can also be set dynamically to change the colors overtime
  • Border flames (option to burn only the side of the screen/texture). This option is designed to work with symmetrical surface (same with and length)

Tested under windows x64 platform.

  • Please feel free to open a new ticket if you wish to add any suggestion(s) or if you wish to report a bug.

python method hook

shader_fire_effect(
        width_,
        height_,
        factor_,
        palette_,
        fire_
)

Optional arguments

        reduce_factor_        = 3,
        fire_intensity_       = 32,
        smooth_               = True,
        bloom_                = True,
        fast_bloom_           = True,
        bpf_threshold_        = 0,
        low_                  = 0,
        high_                 = 600,
        brightness_           = True,
        brightness_intensity_ = 0.15,
        surface_              = None,
        adjust_palette_       = False,
        hsl_                  = (10, 80, 1.8),
        transpose_            = False,
        border_               = False,
        blur_                 = True

doc

Check the folder Doc/html/index.html

fire effect image

Demo

In the main directory run the below command

(press ESC to quit the demo)

C:\>python demo_fire.py

The project is under the GNU GENERAL PUBLIC LICENSE Version 3

Installation

check the link for newest version https://pypi.org/project/PythonFireFx/

  • Available python build 3.6, 3.7, 3.8, 3.9, 3.10 and source build
pip install PythonFireFx 

Building project from source

python setup.py build
python setup.py install

Building cython code

When do you need to compile the cython code ?

Each time you are modifying any of the following files FireFx.pyx, FireFx.pxd, init.pxd or any external C code if applicable

  1. open a terminal window
  2. Go in the main project directory where (FireFx.pyx & FireFx.pxd files are located)
  3. run : C:\>python setup_FireFx.py build_ext --inplace --force

If you have to compile the code with a specific python version, make sure to reference the right python version in (python38 setup_FireFx.py build_ext --inplace)

If the compilation fail, refers to the requirement section and make sure cython and a C-compiler are correctly install on your system.

  • A compiler such visual studio, MSVC, CGYWIN setup correctly on your system.
    • a C compiler for windows (Visual Studio, MinGW etc) install on your system and linked to your windows environment. Note that some adjustment might be needed once a compiler is install on your system, refer to external documentation or tutorial in order to setup this process.e.g https://devblogs. microsoft.com/python/unable-to-find-vcvarsall-bat/

OPENMP

In the main project directory, locate the file setup_FireFx.py. The compilation flag /openmp is used by default. To override the OPENMP feature and disable the multi-processing remove the flag /openmp

setup_FireFx.py

extra_compile_args = ["/openmp", "/Qpar", "/fp:fast", "/O2", "/Oy", "/Ot"]

Save the change and build the cython code with the following instruction:

python setup_FireFx.py build_ext --inplace --force

If the project build successfully, the compilation will end up with the following lines

Generating code
Finished generating code

If you have any compilation error refer to the section Building cython code, make sure your system has the following program & libraries installed. Check also that the code is not running in a different thread.

  • Pygame version > 3
  • numpy >= 1.18
  • cython >=0.29.21 (C extension for python)
  • A C compiler for windows (Visual Studio, MinGW etc)

Credit

Yoann Berenguer

Dependencies :

numpy >= 1.18
pygame >=2.0.0
cython >=0.29.21

License :

GNU GENERAL PUBLIC LICENSE Version 3

Copyright (c) 2019 Yoann Berenguer

Copyright (C) 2007 Free Software Foundation, Inc. https://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Metadata

Release files for PythonFireFx 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PythonFireFx 1.0.0
File Size Uploaded Provenance
PythonFireFx-1.0.0.tar.gz 12.6 MB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for PythonFireFx 1.0.0
File
PythonFireFx-1.0.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
PythonFireFx-1.0.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
PythonFireFx-1.0.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
PythonFireFx-1.0.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
PythonFireFx-1.0.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details

Total release size: 79.4 MB

Release files / PythonFireFx-1.0.0.tar.gz

Download URL PythonFireFx-1.0.0.tar.gz
Size 12.6 MB
Tags Source
SHA-256 checksum
How to use checksums
52fc56fe9c23de487fa211f521907d2966b5525ce9728b08946bfbc7575318c8
BLAKE2b-256 checksum
How to use checksums
73cbd6b9f226f58dd917749344a9b65a0efb1a2bce6e2e746681e713b79608e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/60.0.3 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / PythonFireFx-1.0.0-cp310-cp310-win_amd64.whl

Download URL PythonFireFx-1.0.0-cp310-cp310-win_amd64.whl
Size 13.4 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
04d967de432217e3d9db42d36a9eb30f25a10b4893b61e68df276b449948027c
BLAKE2b-256 checksum
How to use checksums
c7d3017be9acfc1f94f87ed1f52298693d2bade10d77d9dccc0aecfe0e567f26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/60.0.3 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / PythonFireFx-1.0.0-cp39-cp39-win_amd64.whl

Download URL PythonFireFx-1.0.0-cp39-cp39-win_amd64.whl
Size 13.4 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
8f9d8bfb7dbe75c35ddcdc2f1b42b78b4ebabef5b1ace7bb2d782ee07a27e44c
BLAKE2b-256 checksum
How to use checksums
b0429d071ac570a82e011729276dc48bf0764a1af78a394ec25b042a6b26d9b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/60.0.3 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / PythonFireFx-1.0.0-cp38-cp38-win_amd64.whl

Download URL PythonFireFx-1.0.0-cp38-cp38-win_amd64.whl
Size 13.4 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
2c996b91657aac26ffe343065aade14bd7d3688cf3251f879a2a417f27086e8f
BLAKE2b-256 checksum
How to use checksums
5e738ee4801a38941153b38714fd2a7a7eee7591a7673142c62473a8a16db0e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/60.0.3 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / PythonFireFx-1.0.0-cp37-cp37m-win_amd64.whl

Download URL PythonFireFx-1.0.0-cp37-cp37m-win_amd64.whl
Size 13.4 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
eb1b5dcef0f01ca2fb4ccf6c8936623764ab3b8c51405de15ded67404010509b
BLAKE2b-256 checksum
How to use checksums
989037fe235e29f3d323f7d3922cf85f1b7fcdc32acb87fde05fd6d50d1d81cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/60.0.3 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / PythonFireFx-1.0.0-cp36-cp36m-win_amd64.whl

Download URL PythonFireFx-1.0.0-cp36-cp36m-win_amd64.whl
Size 13.4 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
c76c340eac076c42780e0ec327f3453f5815f045a6afd4a3fe0d17bd877eeb98
BLAKE2b-256 checksum
How to use checksums
9da9a03062baf1705704cd5744908d02e374e466d97af52e97585fa45df65c68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/60.0.3 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Security for PythonFireFx 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

6 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page