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

Add option to disable light scattering #3662

Merged
merged 3 commits into from Dec 23, 2018

Conversation

@Partmedia
Copy link
Contributor

@Partmedia Partmedia commented Dec 23, 2018

On old (circa 2011) graphics hardware, I have the sad option of either using fast but ugly graphics with the old pipeline (graphics level 2) or nice-looking but very, very slow (a second in game takes 3 real seconds with very poor control response) render on some maps like Cocoa Temple.

For some context, on my hardware, the solid render at Cocoa Temple takes 15 ms. In the room with the spinning gear, light scatter takes up to 48 ms. That makes for a really crappy experience.

This option, currently not visible in-game, preserving existing behavior by default, adds a configuration setting that disables the light scattering shader in the pipeline. This means that you get the new pipeline, with the new point light sources, only without the later light scattering stage. This means that users running hardware like the stuff I run don't have to pick either old pipeline or unplayable graphics.

@deveee
Copy link
Member

@deveee deveee commented Dec 23, 2018

On my computer in mansion track it's 260 fps vs 250 fps (GLES renderer). I will try on my tablet later. But indeed the difference in performance between 2 and 3 graphics level is large, so I like the idea even if it helps a little. Not sure if it's possible to combine it with already existing graphics settings, because there is already a lot of graphics options.

@deveee
Copy link
Member

@deveee deveee commented Dec 23, 2018

I tried it on intel hd 4000 and it gives quite big difference in fps (disabled vs enabled):

mansion
57 37

candela
44 30

cocoa
28 27

snowmountain
61 38

I'm not sure if it should be disabled in graphics level 3 by default or if a checkbox should be available in options. But having a possibility to disable it to allow increase performance is certainly good.

@deveee deveee merged commit 9cec9c5 into supertuxkart:master Dec 23, 2018
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@deveee
Copy link
Member

@deveee deveee commented Dec 23, 2018

Actually you can get more fps just by using less steps in light scatter shader. Visually there is almost no difference (far lights are slightly more visible).

zrzut ekranu z 2018-12-23 21-44-48
zrzut ekranu z 2018-12-23 21-45-00
zrzut ekranu z 2018-12-23 21-47-00
zrzut ekranu z 2018-12-23 21-47-15

Are you ok with using 8 steps instead of 16? If not, then I can use it only for lower graphics levels, but more work little gain.

diff --git a/data/shaders/pointlightscatter.frag b/data/shaders/pointlightscatter.frag
index a50f68fdc..2b82125a8 100644
--- a/data/shaders/pointlightscatter.frag
+++ b/data/shaders/pointlightscatter.frag
@@ -28,14 +28,14 @@ void main()
     vec3 closestpoint = - eyedir * (dot(-eyedir, light_pos) - radius);
     if (closestpoint.z < 1.) closestpoint = vec3(0.);
 
-    float stepsize = length(farthestpoint - closestpoint) / 16.;
+    float stepsize = length(farthestpoint - closestpoint) / 8.;
     vec3 fog = vec3(0.);
     vec3 xpos = farthestpoint;
 
-    for (int i = 0; i < 16; i++)
+    for (int i = 0; i < 8; i++)
     {
         float d = distance(light_pos, xpos);
-        float l = (16. - float(i)) * stepsize;
+        float l = (8. - float(i)) * stepsize;
         float att = energy * 20. / (1. + d * d);
         att *= max((radius - d) / radius, 0.);
         fog += density * light_col * att * exp(- density * d) * exp(- density * l) * stepsize;
@Partmedia
Copy link
Contributor Author

@Partmedia Partmedia commented Dec 23, 2018

To clarify: you're suggesting to globally go from 16 to 8 steps? That definitely improves it for me, but my machine still needs light scattering disabled altogether to maintain about ~20 FPS on some maps. Maybe you'll want some comments from people who are actually able to run light scattering.

@Partmedia Partmedia deleted the Partmedia:opt_light_scatter branch Dec 23, 2018
@auriamg
Copy link
Member

@auriamg auriamg commented Dec 26, 2018

@deveee Since I am pretty much unable to tell the difference between 8 and 16, (and what little difference there is doesn't look worse, just slightly different), I would agree to use 8 by default. no use in using cycles for something that's essentially invisible

@deveee
Copy link
Member

@deveee deveee commented Dec 26, 2018

Actually I made a bit more testing and 16 steps is minimum to avoid light flickering in oldmine. Or maybe that flickering is caused by something else, but I can't tell what is the reason.

@Alayan-stk-2
Copy link
Collaborator

@Alayan-stk-2 Alayan-stk-2 commented Jan 3, 2019

I think it would be good to have this made accessible in the graphics option, and likely disabled by default at level 3, so that people just using the presets have a better middle balance available than now.

@qwertychouskie
Copy link
Contributor

@qwertychouskie qwertychouskie commented Jan 4, 2019

Agreed. Also IMO the default level should be 4 since the current version has some optimizations.

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

Successfully merging this pull request may close these issues.

None yet

5 participants