Skip to content

renderer/image: add interruptible transition rendering with custom sh… - #105

Open
markg85 wants to merge 1 commit into
hyprwm:mainfrom
markg85:wallpaper_shader_transition
Open

markg85 wants to merge 1 commit into
hyprwm:mainfrom
markg85:wallpaper_shader_transition

Conversation

@markg85

@markg85 markg85 commented Jul 7, 2026 •

Copy link
Copy Markdown

Companion to: hyprwm/hyprpaper#371

Note: This is written against tag v0.5.4. Consider this a draft!

@markg85
markg85 force-pushed the wallpaper_shader_transition branch from e8edd92 to 0004bf2 Compare July 19, 2026 22:12
@markg85
markg85 marked this pull request as ready for review July 19, 2026 22:20
Comment thread include/hyprtoolkit/element/Image.hpp Resolved
Comment thread include/hyprtoolkit/element/Image.hpp Resolved
@markg85
markg85 force-pushed the wallpaper_shader_transition branch from 0004bf2 to a13cbc7 Compare July 22, 2026 15:32
@markg85

markg85 commented Jul 24, 2026

Copy link
Copy Markdown
Author

Please re-review. The double duration (intended to mimic the config) is resolved to just one time. And the shader path now is it's raw data instead.

I updated the code with force push to keep 1 commit and keep things clean. Let me know if you like that or if you rather have individual commits from now on. To me either way works so just let me know your preference here.

@vaxerski

Copy link
Copy Markdown
Member

@codex review please

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a13cbc762b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/renderer/gl/OpenGL.cpp Resolved
Comment thread src/element/image/Image.cpp Resolved
Comment thread src/element/image/Image.cpp Resolved
Comment thread src/renderer/gl/OpenGL.cpp Resolved
@markg85
markg85 force-pushed the wallpaper_shader_transition branch 2 times, most recently from 635af4f to bdb4c04 Compare August 16, 2026 00:53
@markg85

markg85 commented Aug 16, 2026

Copy link
Copy Markdown
Author

@codex review please

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@markg85

markg85 commented Aug 16, 2026

Copy link
Copy Markdown
Author

Ahh, that doesn't work if i do it :)

So i spend a good day getting this in a working state again. Not just the changes here but also the companion changes. This should be good to go now. Can you re-review?

@markg85

markg85 commented Aug 28, 2026

Copy link
Copy Markdown
Author

It's becoming hard to keep this working, please review! I want to merge this for the next release if possible. @vaxerski

@vaxerski

Copy link
Copy Markdown
Member

I can't review this when it has conflicts

@markg85

markg85 commented Aug 30, 2026 •

Copy link
Copy Markdown
Author

I can't review this when it has conflicts

Yeah, this sings a little. There were no conflicts 2 weeks ago. They did start 2 weeks ago around the same time. Which i completely missed.

Please, review within a day or so after i fix this one (I'll let you know when it's fixed) as it's annoying to resolve merge conflicts when there were none and i think this one has been here long enough by now.

Any particular reason for the two companion PRs to not be merged yet? That's hyprwm/Hyprland#15347 and hyprwm/hyprpaper#371 nether has merge conflicts at the moment.

@vaxerski

Copy link
Copy Markdown
Member

because they rely on this API? This needs to be merged + in a release first

@markg85

markg85 commented Aug 30, 2026

Copy link
Copy Markdown
Author

because they rely on this API? This needs to be merged + in a release first

Depends, they rely on a message format change that is introduced in this one: hyprwm/Hyprland#15347 which i think needs to land first. Nothing breaks with it, but it prepares the message format for the change.

Obviously only if you approve of the idea conceptually.

The sensible way to me is:

@vaxerski

vaxerski commented Sep 1, 2026

Copy link
Copy Markdown
Member

there is no point in landing the message format before this. Adding a feature that doesn't work is pointless IMO

@markg85
markg85 force-pushed the wallpaper_shader_transition branch from bdb4c04 to 9319696 Compare September 8, 2026 15:05
…aders

Adds an animated wallpaper transition path to CImageElement: a two-texture
blend (start -> end) driven by fadeLayersIn/Out durations, with an optional
custom GLSL fragment shader supplied by path.

- CImageElement::transitionTo captures the in-flight blend to an FBO when a
  transition is interrupted mid-way, using that as the new start texture so a
  fresh transition can begin to the new target (no flicker, no black flash).
- IRenderer gains renderTransition / captureTransitionState / ensureTransitionShader.
  Custom shaders are stat()-checked once at transition start and recompiled only
  on mtime change; the per-frame render path is a single cache lookup + draw,
  with no filesystem or compile work.
- CFramebuffer sets m_tex->m_size after glTexImage2D so captured textures report
  the right size to the shader's tex1Size/tex2Size uniforms.
- A captured texture keeps its owning CFramebuffer alive via m_tempFramebuffer.
- All fit modes (stretch/cover/contain/tile) are honoured; the host pushes the
  config duration to u_duration each frame (GLES cannot initialize uniforms).
@markg85
markg85 force-pushed the wallpaper_shader_transition branch from 9319696 to bf7e306 Compare September 8, 2026 15:12
@markg85

markg85 commented Sep 8, 2026

Copy link
Copy Markdown
Author

@vaxerski Enjoy the review :) Rebased against current master.

If you want to try it out then you need the two companion PRs (also rebased where needed).

Now say you want to have a circle reveal you can use this shader:

#version 300 es

precision highp float;

in vec2 v_texcoord;

uniform sampler2D tex1;      // Start frame (fit pre-resolved in C++)
uniform sampler2D tex2;      // End frame (fit pre-resolved in C++)
uniform float progress;      // 0.0 = fully start, 1.0 = fully end
uniform float alpha;

uniform vec2 fullSize;       // Output size in pixels
uniform vec2 randomPixel;    // Circle center (0-1 normalized)
uniform float u_duration;    // Host transition duration in seconds (from hyprland config)

// Shader-defined visual duration override: the circle effect completes in 0.5s
// regardless of the host's transition duration. The host's u_duration is used
// to remap progress so the effect fits within this window.
const float SHADER_DURATION = 0.5;

layout(location = 0) out vec4 fragColor;

void main() {
    // Remap progress so the effect completes in SHADER_DURATION seconds.
    float p = (u_duration > 0.0)
        ? clamp(progress * (u_duration / SHADER_DURATION), 0.0, 1.0)
        : progress;

    vec4 startColor = texture(tex1, v_texcoord);
    vec4 endColor   = texture(tex2, v_texcoord);

    // Circle reveal: a radial mask expanding from randomPixel.
    vec2 pixelPos    = v_texcoord * fullSize;
    vec2 centerPixel = randomPixel * fullSize;

    float dist = distance(pixelPos, centerPixel);

    // Farthest corner from the center, in pixel space (aspect-ratio correct).
    float maxDist = 0.0;
    maxDist = max(maxDist, distance(vec2(0.0, 0.0), centerPixel));
    maxDist = max(maxDist, distance(vec2(fullSize.x, 0.0), centerPixel));
    maxDist = max(maxDist, distance(vec2(0.0, fullSize.y), centerPixel));
    maxDist = max(maxDist, distance(fullSize, centerPixel));

    float normalizedDist = dist / maxDist;

    // circleMask: 0 = show start, 1 = show end.
    float edgeWidth   = 0.02;
    float circleMask  = smoothstep(p - edgeWidth, p + edgeWidth, normalizedDist);

    vec4 blended = mix(endColor, startColor, circleMask);

    fragColor = blended * alpha;
}

Do note that this PR intentionally contains a randomPixel in the shader initialization to make a circle reveal possible where that reveal point is different every time.

The following command would show it all if you applied the PRs and use the above shader.

hyprctl hyprpaper wallpaper ",<image_path>,tile,<shader_path>

@vaxerski vaxerski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also format your code with clang-format please. Those comment-related comments arent exclusive, at least half the comments here are redundant

bool isTransitioning() const;

float getTransitionProgressOut() const;
float getTransitionProgressIn() const;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are there still two?

uniform sampler2D tex1; // Start frame (fit pre-resolved in C++ via renderFitFrame)
uniform sampler2D tex2; // End frame (fit pre-resolved in C++)
uniform float progress; // 0.0 = fully start, 1.0 = fully end
uniform float alpha; // Overall opacity

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more comments doesnt mean more better, it often means more garbage someone reading has to filter through

Comment thread src/renderer/Renderer.hpp
// resolved texture. Cached; the transition shaders are pure crossfades.
virtual SP<IRendererTexture> renderFitFrame(const SP<IRendererTexture>& src, const CBox& box, eImageFitMode fitMode) = 0;
// Drop all cached fit-resolved pre-render FBOs (call when a transition starts/ends).
virtual void clearTransitionCache() = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

come on man.

// this function eats a banana
void eatBanana();

@markg85

markg85 commented Sep 28, 2026

Copy link
Copy Markdown
Author

Sorry @vaxerski but I'm gonna have to let this bitrot for a few more weeks up to a few months. I just don't have the time, unfortunately. I'll pick up where i left as soon as i can.

As for these setters, that's sloppy on my part. Will review better next time before pushing. Sorry for that.

@UncleJ4ck

Copy link
Copy Markdown
Contributor

@markg85 since you said you're short on time, i did the open review bits on top of your current head: https://github.com/UncleJ4ck/hyprtoolkit/tree/rescue-105-transition

it collapses getTransitionProgressOut() / getTransitionProgressIn() into one getTransitionProgress() (one transition, one progress), drops the comments that only restate the code, and runs clang-format. merges clean onto current main and the suite passes. merge it into your branch if you want it.

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.

3 participants