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

[feature request] pass previous frame to glsl shader #1113

Open
j7432 opened this issue Aug 13, 2023 · 0 comments
Open

[feature request] pass previous frame to glsl shader #1113

j7432 opened this issue Aug 13, 2023 · 0 comments

Comments

@j7432
Copy link

j7432 commented Aug 13, 2023

Add another texture output that is a copy of the last frame to a glsl shader.

(from /src/opengl.c, line 587)

// Get uniform addresses
#define P_GET_UNIFM_LOC(name, target)
{
pprogram->target = glGetUniformLocation(pprogram->prog, name);
if (pprogram->target < 0) {
log_error("Failed to get location of uniform '" name
"'. Might be troublesome.");
}
}
P_GET_UNIFM_LOC("opacity", unifm_opacity);
P_GET_UNIFM_LOC("invert_color", unifm_invert_color);
P_GET_UNIFM_LOC("tex", unifm_tex);
++ P_GET_UNIFM_LOC("prevtex", unifm_prevtex); ++
P_GET_UNIFM_LOC("time", unifm_time);
#undef P_GET_UNIFM_LOC

So that the frag shader can see the difference from previous frame (for fading,blending,blurring,etc.)

The process i am thinking of is

--frame 0--

current texture(frame0) -> shader
previous texture(null) to shader
--shader renders frame to fragcolor--
current texture(frame0) -> previous texture

--frame 1--

current texture(frame1) -> shader
previous texture(frame0) -> shader
--shader renders frame to fragcolor--
current texture(frame1) -> previous texture

etc.

I'm thinking that a framebuffer would have to be used as well.

Perhaps add a cmdline switch to only enable when needed.

If this isn't the right way to go about this, please lmk.
Thank you. j

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

No branches or pull requests

1 participant