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

Add shader-based smooth transitions between presets #741

Conversation

kblaschke
Copy link
Member

New Preset Transitions

This changeset implements a new transition method using fragment shaders to smoothly blend from one preset to another. Currently, there are six different, randomly chosen transitions, most having some varation to make the transitions less repetitive:

  1. A simple crossfade blend.
  2. A sweeping effect with a random direction and slightly differing width of the blend edge smoothing.
  3. A circular inside-out or outside-in blend, again with a random edge width.
  4. A radial blur/zoom effect.
  5. A sweeping "warp" effect, either horizontally or vertically with a random direction.
  6. A plasma dissolve effect with a randomized pattern and scale.

More shaders can be added quite easily. Documentation to write the shaders is available as a Gist here, will move it to the Wiki after merging the PR. I've implemented them in a way that makes it really easy to test them on Shadertoy and use them with minimal or even no changes in projectM.

Other Changes

While the main focus was implementing the transitions, a few other changes were done either to aid in the implementation or to improve smaller things which I've stumbled upon during the implementation and didn't find big enough to create a separate PR:

  • Moved some classes from the MilkdropPreset dir into the Renderer dir and generalized them to be reusable outside of Milkdrop-specific code.
  • Updated the projectm-eval submodule. This will now prevent the static lib and header from the internal target to be installed with libprojectM.
  • Removed some dead code, specifically the "Renderer" class, which once was the main workhorse and is now completely gone, wrapping up the renderer rewrite.

Also cleaned up the code a bit, the version string format is well-defined by the standard - we just have to cut off anything after the space if there is any.
It's only referenced from within TextureManager, plus we can reuse the noise generator for other things.
Also added the required shader files. Still need to pack them as resources into the library.
Also added a "sweep" transition.
The TimeKeeper-based "smoothing" code still needs to be cleaned up, same with the threading stuff which never really worked.
Also removed the use of MilkdropPreset's PresetState class and add a class-specific copy shader.
This makes hard transitions a bit "smoother", as they won't always start from a black screen. Not really noticeable with fast presets, but some slow-warping ones will now gently dissolve the previous image.
This avoids two fullscreen draw calls during transitions, and should also be slightly faster than using glBlitFramebuffer().

As with all drawing operations, we currently don't really care about the target framebuffer size or aspect ratio and just draw a quad over the whole viewport.
@kblaschke kblaschke added this to the 4.1 milestone Nov 7, 2023
@kblaschke kblaschke self-assigned this Nov 7, 2023
@kblaschke kblaschke linked an issue Nov 7, 2023 that may be closed by this pull request
@kblaschke kblaschke linked an issue Nov 7, 2023 that may be closed by this pull request
@kblaschke kblaschke force-pushed the feature/shader-based-smooth-transitions branch from 43dbf9d to 9a73a88 Compare November 11, 2023 16:41
@kblaschke
Copy link
Member Author

Updated projectm-eval submodule to contain the yyerror function signature fix.

@kblaschke
Copy link
Member Author

Added a fix for blur textures. Was using the wrong input texture, and the blur textures weren't properly flipped to align with the main texture.

…gher resolutions.

Now we don't add the half texel offset to the vertex coordinates, but to the calculated u/v, which will prevent the texture wrapping (happens mostly with "nearest" interpolation lookups) mentioned in Milkdrop's code from happening, but make the mesh exactly fill the screen.
@kblaschke
Copy link
Member Author

The last commits should also wrap up all known rendering issues, except for some preset shaders rendering blackness due to NaN/Inf values in the calculations. These aren't easy to fix (if at all), but not affecting too many presets.

Will then merge this branch shortly.

@kblaschke kblaschke merged commit e2617da into projectM-visualizer:master Nov 16, 2023
9 checks passed
@kblaschke kblaschke deleted the feature/shader-based-smooth-transitions branch November 16, 2023 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Shader-based smooth transitions between presets
2 participants