Speed line shader/effect when boosting
#3
(Yesterday, 04:00 PM)stbdev Wrote: While I still need to profile on some weaker hardware, the shader should be really cheap to run on most hardware. On my machine it was close to 30us (7900xt). The effect works with sampling a noise texture at 2 samples per pixel, which is really modest in my experience.

A 7900XT is still a pretty good discrete GPU. The vast majority of STK players have much weaker cards, and many people play the game on integrated GPUs or on phones. 30µs is fine, but if it's something like 300µs or 500µs on a weaker machine, that's significant.

The effect looks pretty good, but it probably should come with a toggle in the graphics settings and be only enabled at some presets to-be-determined through testing. Probably level 4 (within the current levels).

(Yesterday, 04:00 PM)stbdev Wrote: Should it come in mainly based on current velocity ratio with maximum velocity?

Maximum speed is variable, which makes it a poor reference. More on that below.

(Yesterday, 04:00 PM)stbdev Wrote: Should it be on impulse/activation of a SpeedIncrease?

All speeds that are genuinely high require collecting at least one source of max speed boost, but:
  • There are many speed boost sources, and trying to come up with a list of combinations that should or should not trigger the effect would lead to a messy and unsatisfying result.
  • There are many situations in which a speed boost can be triggered while going at a fairly low speed. Displaying the speed lines in that situation, but not at a higher speed obtained with less boost sources, would simply be odd.
  • When you mix in sources of SpeedDecrease, it becomes even messier.

There is a much simpler and more elegant solution: make both the trigger threshold and the intensity depend on the ratio to the generic max speed.

Generic max speed is currently used in the speed formula for basketballs, but it also works very well here because unlike a kart's own max speed, it is constant throughout the race.

This gives us some very good properties:
  • Lower difficulties will have lower requirements to activate the speed lines (generic-max-speed is difficulty-dependent), so the speed lines will be available at all difficulties. They would trigger more often and more intensely for players that drift, which is more common at higher difficulties, but I think that's fine.
  • The speed lines would be a reliable indicator that players can use as a complement to the speedometer, instead of a potential source of confusion.
  • It's much easier to fine-tune two values (activation threshold and intensity ramp curve) than a plethora of if-else tests combined with parameters. If we set the activation threshold at say 25% above generic max speed, we might not know which speed boosts exactly went in there to reach the threshold - but we know for sure there had to be some boost sources, and that they more than compensated any potential penalty. It also makes it easier to tune how often and how intensely the effect appears.
  • It removes the need for most of the machinery to check if the effect should keep going or not, the speed itself is the judge.

The kart's speed itself may have significant discrete frame-to-frame changes, particularly when driving on zipper pads, so a mechanism to avoid intensity increasing too suddenly may still be used if required to make the visuals smoother, although I'm not sure if it's actually needed.

The concept loses the idea you mentioned of having the speed lines stronger just after the activation of a boost to emphasize it, but I think the overall trade-off is reasonable.

(Yesterday, 04:00 PM)stbdev Wrote: If this feature/effect looks of interest to you and would be a good fit for the game, let me know and I can clean up my code and start the PR. From there we can discuss further and iterate on feedback/suggestions.

Yes, it would certainly interest us. SuperTuxKart is in need of more/better shaders, so help here is welcome.

I suppose we can start discussing some specific details once we can test your code locally.

Sven mentioned the Evolution branch (BalanceSTK2) for a PR. Currently, the main branch receives mainly bugfixes and most features are directed to the Evolution branch, but there are some things we do directly in the main branch when there is no extra cost to it.

I suppose like Sven do that your code currently targets the master branch, I would say don't bother porting your code to the Evolution branch for now. It won't cost anything more to do it later if need be, and perhaps this visual effect would make sense to integrate for 1.5.1.

Of note: there is also the motion blur shader that's supposed to fill a similar role. I can't remember off the top of my head what issue it has (I think there was something making it look not so good), but I remember distinctly that activation conditions for the motion blur effect are bad, and much of what I suggested for your speed lines goes back to thoughts I had regarding activation conditions for motion blur.

Personally, I prefer the visual style of speedlines, and there is a reason why blur effects are not part of the main graphics slider, but any integration of your effect into SuperTuxKart should give some consideration to how the two effects interact, and motion blur's activation conditions should be revised too (although in a separate commit/PR).

(Yesterday, 04:00 PM)stbdev Wrote: PS: I did only notice at the posting of this post that there might be a related thread to another implementation of speed lines, my apologies there, but I do think we can work out a way to combine our efforts. https://forum.supertuxkart.net/thread-200.html

I remember that thread. I had it on my list of things to get to for a while before letting it go.

The problem is that the visual effect didn't look so great and the code quality was poor (I think a bunch of it was AI-generated and ended up very verbose, making a proper code review too time-consuming for what it was).

Your shader is more visually appealing, so that makes any effort required to tune it and integrate it easier to justify.
Reply


Messages In This Thread
RE: Speed line shader/effect when boosting - by Alayan - Today, 03:04 AM

Forum Jump: