-
Notifications
You must be signed in to change notification settings - Fork 644
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
OpenGL: multiple custom shaders unsupported #4729
Comments
oh wait i seem to have misinterpreted the issue.
would not be the correct way to describe it. it should be something like "the output of fragment shader is not being correctly updated in the fbo backbuffer texture" or something. |
Ah, sorry. I could have been more clear. The shaders all run, but they can't access the texture from the previous shader like they (I presume) can on Metal because the output of each shader is not copied to the texture buffer. The repro is a trivial example, but if you wanted to add bloom on top of a starfield then there wouldn't be a way to do it.
I was confused about which way was up, so ignore that. I remembered running this shader (License: CC3 BY-NC-SA) and the animation was flipped (rocket came from the top of the screen) so I thought perhaps that Y was flipped on Linux. |
ah, sorry about the confusion. does my fix solve your issue? im not exactly sure if this would be a good idea because multiple shaders sampling from the default screen is important for different effects which happen to be split across many shaders. maybe this should be a toggle able feature (but even then it seems a bit niche)? |
also, have you tested the same behavior using another graphics api? if it matches your example then this wouldn't be a bug |
It's still broken, but in the opposite way. Now, it appears that all of the shaders are being rendered but only the first shader makes it to the screen (previously, the later shaders would get the original terminal texture overwriting whatever the previous shaders did). I have tried this with a number of shaders (from m-ahdal's repository and elsewhere) and only the first shader makes it to the screen, no matter how many I specify. For example, starfield and bettercrt. In the Metal side of things, there is a copy step that happens in between each custom shader to copy the output of one custom shader to the input of the next. Here are updated repros to also show the terminal text: void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord/iResolution.xy;
vec4 terminalColor = texture(iChannel0, uv);
fragColor = mix(
mix(vec4(1., uv.x * 2., uv.y, 1.), terminalColor, step(0.05, length(terminalColor.rgb))),
terminalColor,
step(0.5, uv.x)
);
} right.glsl void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord/iResolution.xy;
vec4 terminalColor = texture(iChannel0, uv);
fragColor = mix(
terminalColor,
mix(vec4(uv.y, 2. - uv.x * 2., 1., 1.), terminalColor, step(0.05, length(terminalColor.rgb))),
step(0.5, uv.x)
);
} |
ah, sorry again. before i continue, could you please tell me if #5294 works for all your tests? im getting your expected output but its not exactly the same as how the Metal one works so i just want to make sure. Thanks! |
#5294 looks good And here's one with three shaders (starfield->negative->bettercrt) working as expected |
alright cool. im slightly hesitant for the pr to be merged because im truly unsure if the way i did it was the best way. i would like to wait for someone to review it first (preferably someone who is familiar with the Metal system because i think keeping them similar is important) |
NEEDS REVIEW continuation of #5037 resolves #4729 renders all shaders to the default buffer and then copies it to the designated custom shader texture. this is a draft pr because: - it introduces a new shader "pipeline" which doesnt fit in with how the system was designed to work (which is only rendering to the fbo) - im not sure if this is the best way to achieve shaders being able to sample their output while also drawing to the screen. the cusom fbo (previous implementation) was useful in that it modularized the custom shader stage in rendering --------- Co-authored-by: Mitchell Hashimoto <m@mitchellh.com>
Discussed in #4711
Originally posted by Talljoe January 6, 2025
Issue
On Linux/OpenGL, when specifying multiple custom shaders, only the last specified shader is rendered.
Repro steps
left.glsl:
right.glsl:
Expected
Actual
Notes
Looking at the code, I don't see on the OpenGL side where the output buffer is set as the input buffer for the next shader as is done in the Metal codepath.
By the way,
uv.y
is1.0
at the top of the image and0.0
at the bottom of the image. Not sure if this in intentional, but it is counter-intuitive (would expect purple at the bottom). I suspect this is different than Metal given some other shaders I've seen.System:
(Repros on multiple Linux systems, both X11 and Wayland)
log:
The text was updated successfully, but these errors were encountered: