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

a question about the ViewportInfo in shader #2

Open
philxusblueberry opened this issue Dec 12, 2023 · 1 comment
Open

a question about the ViewportInfo in shader #2

philxusblueberry opened this issue Dec 12, 2023 · 1 comment

Comments

@philxusblueberry
Copy link

how to choose the best parameter to set ViewportInfo for gsr?

@gabware
Copy link

gabware commented Feb 11, 2024

If I read the code properly, ViewportInfo should be a vec4 in the form of {1.0/original_tex_w, 1.0/original_tex_h, original_tex_w, original_tex_h}.
I'll let the original authors confirm but from my tests it works when I use those values.

Explanation (based on the glsl code) for the curious (others can stop reading here):

l.85 highp vec2 imgCoord = ((in_TEXCOORD0.xy*ViewportInfo[0].zw)+vec2(-0.5,0.5));
The multiply here is used to transform from the current texture UV space to the "Viewport" space (i.e. the original low res texture). This basically maps the current uv to a pixel in the original texture and shifts this pixel coordinate by (-0.5, 0.5) to get the center of the pixel.

l.96 vec4 right = textureGather(ps0,coord + highp vec2(ViewportInfo[0].x, 0.0), mode);
The coord + vec2(ViewportInfo[0].x, 0.0 shifts the pixel coordinate coord to the right by adding 1/width.
Because we're sampling ps0 (the original low res texture) the width used as to be the width of that texture.

The rest of the code makes sense when you take those 4 variables and the code seems to work.
Hope this helps.

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

2 participants