space-wizards / space-station-14

A multiplayer game about paranoia and chaos on a space station. Remake of the cult-classic Space Station 13.
https://spacestation14.io
MIT License
2.71k stars 3.43k forks source link

Whole screen shaders/overlays sometimes get drawn incorrectly. #9657

Closed Nuxssss closed 2 years ago

Nuxssss commented 2 years ago

Artix linux, nouveau (NVIDIA GeForce 9600 GT), sway + XWayland

https://youtu.be/qNlsBWjcLB0

ElectroJr commented 2 years ago

For whatever reason the drunk effect seems to be breaking. Does the same thing happen with the drug-shader or when you are near the singularity? Are there any errors in the console when you connect to a server?

Nuxssss commented 2 years ago

Does the same thing happen with the drug-shader or when you are near the singularity?

Yes

ElectroJr commented 2 years ago

Yes

Then it just has something to do with whole-screen shaders that somehow get drawn to the screen wrong, causing it to seemingly zoom in on the lower left corner.

Its hard to fix without being able to reproduce it locally, cause I have NFI what causes it and AFAIK no one else has ever reported this issue. Unless others manage to reproduce it, fixing it might just require using you as a guinea pig at some point, which would require you to do basic dev setup.

This should also maybe be an issue in engine/RobustToolbox if its a rendering issue, instead of content/ss14. But again I have no idea what causes it and maybe the problem lies with the shaders or overlays and not the rendering.

Nuxssss commented 2 years ago

The problem is still relevant for me. How can I help fix it?

Nuxssss commented 2 years ago

I tried to change the settings of graphics and: https://youtu.be/6riuenlMmCs

ElectroJr commented 2 years ago

I still can't figure out what's wrong, other than that that it looks like the SCREEN_PIXEL_SIZE shader uniform probably has the wrong value, but I have no idea how that happens. I don't even know how best to debug this.

@PJB3005 help.

ElectroJr commented 2 years ago

After some discussion on discord, unless other people start reporting similar issues with different hardware this might just be a case where your card/driver/setup is too old and/or cursed to fix.

rene-descartes2021 commented 2 years ago

@Zuzuk-null I had minimal problems on Debian, nouveau (or proprietary, I've used both) (NVIDIA GeForce 9800 GT) and X11 not wayland. 8+ months ago. I bought a ryzen minipc since then.

Singulo shader worked then. Also flashbang. Viewport had something odd on startup, iirc view scaling setting in options was broken (game super slow iirc), had to jimmy it (set to far left and restart iirc) to get the game functional. I didn't have the weird effect you show in the YouTube video. I think the drunk and drug shaders were new since then, so maybe they wouldn't work for me either. Iirc sometimes the game would slow down in the same way (with no obvious cause) and I just rejoined to get around that.

Aside from setting up Dev environment you could try using a tool like apitrace and see if you notice anything odd, but this would take a lot of time. I've been able to fix other games shader problems on the 9800 GT using just apitrace and editing shaders. Other suitable tools may exist.

Edit: Actually I think my above experience was using proprietary NVIDIA driver. I switched to nouveau later but I don't think I ever tried SS14 with nouveau. Sorry poor memory.

Edit2: This card really couldn't handle more than 1 fragment per pixel in programmable shader pipeline (e.g. in fragment shader for each pixel average/blend nearby pixels). Non-fixed (programmable) pipeline was kinda new back then so the non-fixed pipeline implementation was situationally poor even though it's a very high end card for its time (9800GT or GTX or whatever) (lasted >10 years for me due to performance but doesn't implement newer opengl or vulkan specs). For Sprite outlines in a different game with 9 fragments per pixel on the ~3 pixel wide outline of a single Sprite (BG2 enhanced edition) I'd get 1-4fps. So... could be part of what is going on here. I fixed such problems by just making the fragment shader essentially a pass though shader or sticking to one fragment per pixel. I have no explanation for the YouTube video though... maybe nouveau decides to not fall back to software rendering or whatever the proprietary driver does and somehow engages in undefined behaviour? (Stab in the dark guess). I don't remember any shader compile errors in this context (NVIDIA proprietary >1 fragment per pixel), just 1-4 fps or worse. IIRC the card could easily handle such functionality were the fixed function pipeline equivalent (or other alternative means-to-and-end) used (usually the case in games back then or their fallback or "low" shaders option would work around issue), but the card really couldn't cope with these >1 fragment per pixel fragment shaders.

mirrorcult commented 2 years ago

sounds like a nouveau thing tbh

rene-descartes2021 commented 2 years ago

@Zuzuk-null Some ideas if the devs don't want to support your card, and I'm right about fragment shader a being the issue: Out of curiousity I looked for what tool can be used to modify the Shader used by the application when using nouveau. gDEBugger doesn't support new enough OpenGL. CodeXL or GPU PerfStudio might work. Using such a tool to edit the fragment shaders in use. Such tools sees the shaders used by the application by tracing the API and has a front end to map those shaders in use to custom ones. Another idea is to set __GL_SHADER_DISK_CACHE=1 and __GL_SHADER_DISK_CACHE_PATH=/tmp/nv and see if it is as simple as replacing the shader files with ones that work on your card in that path. Might work with nouveau, you could ask on their IRC for tips. One horrible thing I noticed is the default shader cache is on disk for the proprietary driver and it really slows down the fps or causes stuttering for some games on linux in my experience. Horrible oversight, is ~/.nv/ by default. NVIDIA probably has a similar tool but IIRC it didn't support Linux and probably wouldn't support nouveau. Edit: Or just set up SS14 Dev environment and edit shaders there. Edit2: I think I may have butchered fragment shader terminology it's been years. I had to get rid of the nested for loop (both loops) in a fragment shader filter like this: https://stackoverflow.com/a/64845819/1185900 in order to get more than one game to get its programmable pipeline functional on the 9800 GT. I had tried loop unrolling for improvement but didn't think it worth the slowdown (even for ~3 elements).

PJB3005 commented 2 years ago

Renderdoc is the tool to use, but it doesn't make it easy to recompile shaders like something like NSight does.