Ren'Py How to have brighness preference/setting in renpy?

Celestial Novel

I Gave My Life To My Game
Game Developer
Jun 3, 2022
606
2,150
Hey I'm the developer of this game https://f95zone.to/threads/fate-and-life-the-mystery-of-vaulinhorn-ch-1-celestial-novel.127932/
Some people that have played my game gave feedback about the brightness in my game is too high. So I want to create brighness preference/setting for people that find my game's renders too bright. How to do that in renpy? I could create textbox opacity setting with this tutorial because there is step to step how to create it I'm so new to this renpy coding or coding in general so I appreciate so much if anyone could provide step to step how to create brighness preference/setting in renpy.

I searched in the internet and everything point out at this but I can't seem to figure out how apply it in preference/setting

Or maybe someone could point out a renpy game that uses brighness preference/setting?
 

noping123

Well-Known Member
Game Developer
Jun 24, 2021
1,715
2,719
I played around with this a bit. The only way I could find to do it, is annoying as FUCK.

So basically you'd need a few things. First I did this:

Code:
default persistent.brightvar = 0.0

transform bright:
    matrixcolor BrightnessMatrix((persistent.brightvar))

Then in my preferences screen, I added this:

Code:
                vbox:
                    xsize 525
                    label _("Brightness")
                    bar value FieldValue(persistent, "brightvar", range=2.0, offset=-1, style="slider")


That provides the baseline for it. After that though, you'd need to be adding "at bright" to the end of every scene command.

the full code in my test script was:

Code:
default persistent.brightvar = 0.0

transform bright:
    matrixcolor BrightnessMatrix((persistent.brightvar))



label start:

scene ball10 at bright

"Hi"

scene ball50 at bright


"test"

return
(plus the slider in preferences from above).

That allowed me to adjust the brightness with 2 caveats:

#1 It will not adjust the CURRENT image - it will only adjust the next image going forward, so you can't instantly see the effect of the change.

#2: you need to add the "at bright" (or whatever you call it) to the end of *every* image, otherwise the setting won't apply.



I haven't found an easier way to do it, that's all I could come up with. Fwiw, I did test it, and it worked. Also note: Brightness has a value of -1.0 to 1.0. -1.0 is pure black, 1.0 is pure white, 0.0 is default.
 
  • Heart
Reactions: Celestial Novel

Celestial Novel

I Gave My Life To My Game
Game Developer
Jun 3, 2022
606
2,150
I played around with this a bit. The only way I could find to do it, is annoying as FUCK.

So basically you'd need a few things. First I did this:

Code:
default persistent.brightvar = 0.0

transform bright:
    matrixcolor BrightnessMatrix((persistent.brightvar))

Then in my preferences screen, I added this:

Code:
                vbox:
                    xsize 525
                    label _("Brightness")
                    bar value FieldValue(persistent, "brightvar", range=2.0, offset=-1, style="slider")


That provides the baseline for it. After that though, you'd need to be adding "at bright" to the end of every scene command.

the full code in my test script was:

Code:
default persistent.brightvar = 0.0

transform bright:
    matrixcolor BrightnessMatrix((persistent.brightvar))



label start:

scene ball10 at bright

"Hi"

scene ball50 at bright


"test"

return
(plus the slider in preferences from above).

That allowed me to adjust the brightness with 2 caveats:

#1 It will not adjust the CURRENT image - it will only adjust the next image going forward, so you can't instantly see the effect of the change.

#2: you need to add the "at bright" (or whatever you call it) to the end of *every* image, otherwise the setting won't apply.



I haven't found an easier way to do it, that's all I could come up with. Fwiw, I did test it, and it worked. Also note: Brightness has a value of -1.0 to 1.0. -1.0 is pure black, 1.0 is pure white, 0.0 is default.
It works like a charm! Thanks friend. I don't mind giving "at bright" to the end of every image but not adjusting the current image I think kinda a bit annoying for people who play the game. Anyway thanks once again!
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,963
16,197
That provides the baseline for it. After that though, you'd need to be adding "at bright" to the end of every scene command.
There's an easy way to deal with this issue, it's to rely on .

Code:
init python:
   def myShow( *args, **kwargs ):
        if not "at" in kwargs: kwargs["at_list"] = []
        kwargs["at_list"].append( bright )
        renpy.show( *args, **kwargs )

   config.show = myShow
I wrote it on the fly, so I don't guaranty at 100% that it works. But normally this should be enough and add the "bright" transform to every single image shown in the game, whatever through the show statement or the scene one.

Edit: Corrected an error in the code.
 
Last edited:

Celestial Novel

I Gave My Life To My Game
Game Developer
Jun 3, 2022
606
2,150
There's an easy way to deal with this issue, it's to rely on .

Code:
init python:
   def myShow( *args, **kwargs ):
        if not "at" in kwargs: kwargs["at"] = []
        kwargs["at"].append( "bright" )
        renpy.show( *args, **kwargs )

   config.show = myShow
I wrote it on the fly, so I don't guaranty at 100% that it works. But normally this should be enough and add the "bright" transform to every single image shown in the game, whatever through the show statement or the scene one.
Where should I put that? Because if I put it on screen.rpy it gives me this error:

Code:
[code]
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 207, in script
    scene black
  File "game/screens.rpy", line 13, in myShow
    renpy.show( *args, **kwargs )
TypeError: show() got an unexpected keyword argument 'at'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/00start.rpy", line 207, in script
    scene black
  File "E:\renpy-8.0.2-sdk\renpy\ast.py", line 1542, in execute
    show_imspec(self.imspec, atl=getattr(self, "atl", None))
  File "E:\renpy-8.0.2-sdk\renpy\ast.py", line 1371, in show_imspec
    renpy.config.show(name,
  File "game/screens.rpy", line 13, in myShow
    renpy.show( *args, **kwargs )
TypeError: show() got an unexpected keyword argument 'at'

Windows-10-10.0.19044 AMD64
Ren'Py 8.0.2.22081402
Fate and Life The Mystery of Vaulinhorn 1.0
Wed Aug 24 20:32:23 2022
[/CODE]
 

Celestial Novel

I Gave My Life To My Game
Game Developer
Jun 3, 2022
606
2,150
It still gives me this error

Code:
[code]
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 207, in script
    scene black
  File "game/screens.rpy", line 13, in myShow
    renpy.show( *args, **kwargs )
TypeError: 'str' object is not callable

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/00start.rpy", line 207, in script
    scene black
  File "E:\renpy-8.0.2-sdk\renpy\ast.py", line 1542, in execute
    show_imspec(self.imspec, atl=getattr(self, "atl", None))
  File "E:\renpy-8.0.2-sdk\renpy\ast.py", line 1371, in show_imspec
    renpy.config.show(name,
  File "game/screens.rpy", line 13, in myShow
    renpy.show( *args, **kwargs )
  File "E:\renpy-8.0.2-sdk\renpy\exports.py", line 698, in show
    img = i(img)
TypeError: 'str' object is not callable

Windows-10-10.0.19044 AMD64
Ren'Py 8.0.2.22081402
Fate and Life The Mystery of Vaulinhorn 1.0
Wed Aug 24 22:01:47 2022
[/CODE]
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,963
16,197
Code:
  File "E:\renpy-8.0.2-sdk\renpy\exports.py", line 698, in show
    img = i(img)
TypeError: 'str' object is not callable
Hmm hmm...
Oh, ok, I see, it expect the transform directly, not their names... Pfff...

kwargs["at_list"].append( bright )
 
  • Heart
Reactions: Celestial Novel