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

[Linux/Wine] Special effects (particles?) are visible only in a portion of the screen. #462

Closed
uralets opened this issue Jan 28, 2021 · 11 comments · Fixed by #498
Closed

Comments

@uralets
Copy link

uralets commented Jan 28, 2021

Hello, it's me again.
Don't mean to spam the bugtracker, just reporting bugs as I go (and this seems the place with any activity for T+).

This particular one is very frustrating...
I've found that various special effects (spells such as sleep/grease/MM/web/etc, chimney smoke, blood, will-o-wisps, bugs(?) around trees in Nulb, even flames in the main menu) are visible (get rendered?) only in a portion of the screen.

Now, I have a 4k monitor running at 3840x2160, and have render{width,height} set to eg 1280x720 fullscreen. And all the special FX would only show up in a small rectangle (or a square) in the lower right corner of the screen.

I think T+ doesn't change the physical resolution to render{width,height}, but rather scales to whatever the desktop res is? At least it is so with Wine. Probably a smart thing to do (however, the fonts get blurry, they have to be rendered at the actual resolution).

All three w-o-w's are visible:
3wow

After scrolling the screen, only one (the rightmost) is visible:
2wow

Scrolling the screen even further, none are visible:
0wow

Also notice the green glow from the Bless spell around the chars (not very pronounced on the screenshot) behaves the same.

If I set the resolution to say 1920x1080 this area gets bigger.

I've set debugPartSys=true, but all I see is that the blue rectangles with labels like sp_Bless (which is I presume for the green glow) or sp_Sleep (for the corresponding spell) are somewhere off-screen in a diagonally opposite corner to which has the effects actually visible:
spdebug

Thanks again for helping to get T+ even working for me in Wine.

@uralets
Copy link
Author

uralets commented Jan 30, 2021

On larger maps like towns, the symptoms are different. In some parts of the map, particles render everywhere on the screen, on other parts it's as described.

@dolio
Copy link
Contributor

dolio commented May 12, 2021

Is this actually a wine-only problem, by the way? It occurred to me that most people might just be running at their monitor's native resolution, in which case you'd never encounter this problem.

@uralets
Copy link
Author

uralets commented May 12, 2021

no idea since I only run Linux, but I positively have to set the resolution to that I run T+ in to avoid this.

anyway. what's the relationship between the res you run T+ in and the ToEE viewport? At 1600x900 it's already too zoomed out ('small') for my taste

@dolio
Copy link
Contributor

dolio commented May 13, 2021

Yeah, I'm unable to check for the same reason (and I also experience this bug). I brought it up since it occurred to me that it might be that no one on Windows is actually running the game in a way that they'd notice this. If they're using a 1920x1080 monitor, then 1600x900 covers most of the screen, and even 1280x720 covers the center, where you might be looking most of the time.

I also noticed that mirror images render normally all over the screen. TemplePlus seems to draw that itself, so maybe that's the reason. Maybe that could give some hint about why other particles don't work, though.

@DudeMcDude
Copy link
Contributor

DudeMcDude commented May 13, 2021

Ho, looks like you're right. I looked into this previously and didn't see anything of the sort, so I chalked it off as a Linux issue, but it must have been because I was running the game in windowed mode (since there the issue does not manifest itself).
Also I guess running at 4K greatly exacerbates this.
@shartte

@shartte
Copy link
Contributor

shartte commented May 14, 2021

I usually run it scaled, because there's a limit to the resolution ToEE can render at (mostly due to the shitty fog of war implementation using a pre-determined fixed-size buffer that has to fit every rendered pixel).
We render to a texure of that size and then scale that to the actual window/screen size.
It's quite surprising that windowed vs. fullscreen makes any difference at all since we only support "borderless fullscreen" which isn't really fullscreen anyway.

Can you give me a simple step-by-step list on how to repro this?

@dolio
Copy link
Contributor

dolio commented May 14, 2021

For me, here are two ways to notice it:

  1. Stand outside the Welcome Wench. Most particle effects will be invisible except on the bottom-right portion of the screen that (seemingly) physically has the resolution that Temple+ is set to run at. For 1280x720 on a 4K screen, that's pretty noticeable, but it'll be less so if the Temple+ resolution is closer to the resolution your monitor is running at.

  2. On the title screen, the flames become invisible on a similar portion of the screen. However, around the point that the camera starts moving past the candles, this changes, and the larger flames stay visible across the entire screen.

Based on the second example, it seems like the camera's coordinates within the scene also have something to do with it. Maybe it's a translation problem rather than a scaling problem.

Also, it seems like the whole effect gets rendered or doesn't based on whether the center (the particle, I guess) is in the right area. It's not like the effect gets clipped to look rectangular at the edges.

@DudeMcDude
Copy link
Contributor

DudeMcDude commented May 14, 2021

I usually run it scaled, because there's a limit to the resolution ToEE can render at (mostly due to the shitty fog of war implementation using a pre-determined fixed-size buffer that has to fit every rendered pixel).
We render to a texure of that size and then scale that to the actual window/screen size.
It's quite surprising that windowed vs. fullscreen makes any difference at all since we only support "borderless fullscreen" which isn't really fullscreen anyway.

Can you give me a simple step-by-step list on how to repro this?

I think I've traced it to here:

https://github.com/GrognardsFromHell/TemplePlus/blob/master/TemplePlus/gamesystems/particlesystems.cpp#L398

Compare the result when running fullscreen vs windowed. Attached save with convenient single static particle system.
ParticleSystemDebug.zip

WorldToScreenUi seems to be ok.

BTW I saw the WorldCamera::mScale is always 1.0. Maybe that's why?
Edit: guess not.

@shartte
Copy link
Contributor

shartte commented May 14, 2021

mScale is only used for the main menu (fuck that thing :D)

I'll take a look. I also think it sounds a lot like the culling using the wrong screen size.

@dolio
Copy link
Contributor

dolio commented May 14, 2021

Oh, I don't know if this helps any, but if you set the resolution to something more square (e.g. 1280x1024) on a widescreen monitor, then the area the effects are clipped to is still as if the 'physical' bounding box is placed at the lower right of the widescreen window. So the region where effects show up will be tall in the actual game area, because of the pillarboxing.

@shartte
Copy link
Contributor

shartte commented May 14, 2021

Working on a fix, this is a general issue that is a bit harder to fix "properly" than it initially seems.
Directly after rendering a frame, we switch back to "normal resolution", which also changes back the camera size to normal resolution until the next frame is rendered.

The problem in this issue comes from particle systems computing their own screen location while they're being simulated, which happens after rendering. This means they do this calculation using a camera that is at "native resolution" which is wrong.

I am changing this internally so we no longer mix the rendering device's camera with the camera we use for the game view, which is a bit more involved, but is cleaner anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants