Post processing at 1:1 screen resolution on a pixel game
Asked Answered
V

5

0

Before I give up and call what I'm tying to do impossible I figure I should probably post here, Is it truly as inconvenient as I'm finding to apply an optional crt shader to a fixed resolution game after it has been scaled to fit the window or did I miss something?

I had an idea, but then found it got too messy without a way to turn off stretching while still being able to limit the window to a specific aspect ratio.

Vachil answered 12/10, 2023 at 7:48 Comment(0)
V
0

You're gonna need to elaborate for us to understand your issue. Is it a specific shader causing you a problem?

Viscera answered 12/10, 2023 at 8:39 Comment(0)
B
0

Any reason you don't just change your existing shader settings to match the screen resolution?

eg: # void set_shader_parameter(param: StringName, value: Variant)
$Surface.material.set_shader_parameter("width",800)
$Surface.material.set_shader_parameter("height",600)

Bijection answered 12/10, 2023 at 9:9 Comment(0)
V
0

Viscera hehe, I know, I'm sorry, very tired brain rn and I had typed up a detailed explaination, and then deleted it because of how disgustingly verbose it was.

To be specific lets say I have a project with a resolution of 320x240, I have the window set to scale that with the 'viewport' and 'keep' stretching options, in this case any post processing I do is also going to be rendered at 320x240, which is obviously not ideal for a crt shader.

So then I started to try to play with the content_scale_size of the window and the size/stretch_shrink of a viewport so that I would have more pixels to work with when I got to the crt shader, and this can get a usable result but it involves rendering at basically a 4k resolution before it looks almost acceptable downsampled back down to 1080.

So the last thing I could think of was foregoing the stretching options in the project settings and handling all of the scaling and centering myself, I've only tried going about this one way so far (this was the vervbose part) it involved using a subviewport + container fixed to 240p and anchored to the top left, I then stretch this across the entire canvas with a backbuffercopy and a texturerect...

oh. so the problem was that if at any point I correct the aspect ratio and/or center it, I now also have to compensate for the extra necessary pixels in each subsequent post processing pass.

But actually I just realized the approach that I was having a hard time imagining a second ago.


I initially dismissed it because it would mean that if for any reason I needed another pixel perfect shader between the stretched one and the aspect corrected one it would not be possible, and also there's a bit of artifacting funk if the window is too small and narrow, and I wanted to be able to turn the crt shader on and off in the editor, But nvm, I think I can live with this for now.

Though perhaps I missed a simpler solution

wait a minute...

Theres a solution with the 'canvas_items' stretch mode isnt there

Vachil answered 12/10, 2023 at 10:3 Comment(0)
V
0

hold on... I just set it to use the 'canvas_items' and my issue dissapeared, in the scene that I didn't set up for testing... i'm not sure if this is an issue with me being a serial skimmer, or if the documentation didn't make this specific difference between the 'viewport' and 'canvas_items' stretch modes incredibly clear. (also I could have sworn that I tried this before... I guess it was under different circumstances)

edit. I looked back at the documentation and I do see that the canvas item stretch mode does say exactly how it is stretched and rendered but not in a way that I understood until tonight.

Vachil answered 12/10, 2023 at 10:32 Comment(0)
W
0

Vachil If you think there is a better way to explain or word it then please open an issue in the GitHub Godot docs repository so that the manual can be improved.

Westernmost answered 12/10, 2023 at 11:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.