Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fragment shaderz #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

okcomput3
Copy link
Contributor

Include the addition of a single-pass fragment shader below is the original transcript, I merged the changes from ammen99 experimental repo. All base effects have been transitioned to this fragment shader, with the enhancements of the fire and ice effects.

Additionally, I have introduced new compute shaders for fast smoke, fumes, and flame with increased performance using less buffers once transitioning over to fragment shaders for render source for each of the new additions we will see extra performance, it is currently upto 30% faster than original smoke implementation in specific scenarios.

Ammen99;
This PR aims to make it possible to optimize most of the effects which can be rendered with a single fragment shader pass. The old pipeline uses 3 passes:

Compute pass for the effect
Compute pass for the overlay engine
Fragment shader pass for rendering

The new render code combines all three together in a single fragment shader pass, allowing us to also make efficient use of GL scissor. By reducing the passes, we also reduce the CPU usage.

The idea of how the shaders work:

All of them share the same headers and the same uniforms, width, height, current_time
Each effect needs to provide a function, vec4 effect_color(vec2 pos) which gives the color from the effect.
Each overlay engine provides a function, vec4 overlay_effect(vec2 pos). It may call effect_color() to get the color of the effect, or set a color on its own. For example the none overlay effect simply returns effect_color(pos).
The main function is the same for all combinations, it just calls overlay_effect(pos).

The headers, effect, overlay and main function code are simply concatenated together to form a single shader which is then executed.

@soreau
Copy link
Owner

soreau commented May 1, 2024

AFAICT, this is based on very old pixdecor. Please rebase ontop of master and uncrustify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants