Gamma / brightness control?

Previous topic - Next topic

r0ber7

Hi everyone. Currently I'm working on expanding my game menu. I've started work on sliders, and I thought, hey, is there a command that adjusts gamma or brightness of the program? And if there isn't, what way would I go about to code something that can do that? All I can think of is the RGB() option with POLYs, but I'd rather not use that since I hear some systems run poorly when it is used. Any suggestions will contribute to my game being more awesome. ;)

Thanks!  :good:

mentalthink

Hi rOber7, you can do a simple trick, it´s a garbage... you can use a black image and adjust the alpha mode... perhaps can runs a bit more slowly, I´m not sure.

I suppose, for touch the Brightnnes and Contrast, you have to pick something in C++ whit the inline Command.

r0ber7

Quote from: mentalthink on 2012-Aug-23
Hi rOber7, you can do a simple trick, it´s a garbage... you can use a black image and adjust the alpha mode... perhaps can runs a bit more slowly, I´m not sure.

I suppose, for touch the Brightnnes and Contrast, you have to pick something in C++ whit the inline Command.

Thanks for the suggestion. What I'm looking for is a way to increase brightness too. Perhaps a white drawrect with a transparency could work, but as you say, it's kind of a quick-fix solution. I'd rather use something else. :)

Wampus

This thread might offer another possibility: http://www.glbasic.com/forum/index.php?topic=5624.msg44139#msg44139

The way the above could work is in taking your sprites and applying the colour transformation to another sprite sheet, then using that sheet instead of the original. Adding a contrast slider could be possible too, if you can find a nice RGB algorithm for it.

mentalthink

I think if you put a White image can be very confused the image... I think the only way for do well, It´s something whit the C++, I try to search something very quickly, but I don´t find nothing interesting...

This about apply black and white images... like spaninsh people says it´s "un apaño" but very bad  :D

I found this rOber7, don´t look too much but it´s C++
http://www.youtube.com/watch?v=DUsZgTLvA9A

Perhaps cab be usefull

r0ber7

Thanks for the help guys. :)

Quote from: Wampus on 2012-Aug-23
This thread might offer another possibility: http://www.glbasic.com/forum/index.php?topic=5624.msg44139#msg44139

The way the above could work is in taking your sprites and applying the colour transformation to another sprite sheet, then using that sheet instead of the original. Adding a contrast slider could be possible too, if you can find a nice RGB algorithm for it.

That's a good code snippet to have lying around! I can imagine all sorts of things it could be used for. Customization of characters, effects, and so on. Reminds me of the Copper effects on the Amiga. I'll give this a try with the brightness. If it works, I might use it in other ways as well. Awesome.  :good:

fuzzy70

I can't say I have seen a 2D game that has had options to adjust Gamma/Brightness (not saying there are not any, just none I have seen  ;) ), might be due to the content being pre-made. Practically every 3D game I have played has those options but 3D is generated dynamically per frame so it might be easier to implement those adjustments in 3D by just modifying a variable when the scene is generated (might be wrong but that's the way I picture it in my head).

I would say use Wampus's code & suggestion  :good:

On a side note, and this needs to be confirmed by someone who knows the internals of GLBasic, there is the "SDL_SetGamma" function which states the following

Code (glbasic) Select

SDL_SetGamma
Name
SDL_SetGamma -- Sets the color gamma function for the display
Synopsis

#include "SDL.h"
int SDL_SetGamma(float redgamma, float greengamma, float bluegamma);


Description
Sets the "gamma function" for the display of each color component. Gamma controls the brightness/contrast of colors displayed on the screen. A gamma value of 1.0 is identity (i.e., no adjustment is made).

This function adjusts the gamma based on the "gamma function" parameter, you can directly specify lookup tables for gamma adjustment with SDL_SetGammaRamp.

Not all display hardware is able to change gamma.

Return Value
Returns -1 on error (or if gamma adjustment is not supported).



How much/if at all GLBasic uses SDL & if this works for all graphics in 2D/3D I am not sure, also how you could set it I have no idea (INLINE?). Perhaps someone more knowledgeable could say  :-[

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

r0ber7

Thank you fuzzy, that was more than I'd hoped for. The reason I asked is because there have been some comments by gametesters about the darkness of the game. To be fair, they were playing on a screen with direct sunlight on it, but still. Youtube also keeps telling me it wants to brighten up my gameplay videos. XD So it's not my main priority, but it's on my "would be nice" list. I'm pretty sure it can be done, but for now level design is on top of my list. :)

However, if I do get around to this, I'll make sure to post it here.

fuzzy70

One way to sort out the Youtube videos is to use VirtualDub http://virtualdub.sourceforge.net/. Basically feed it your raw video before converting/uploading to Youtube & use the "Brighness/Contrast" filter to lighten the video.

Best of all VirtualDub is free  :good:

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

spacefractal

Yes i saw the video. Your game look cooler and cooler. Yes, its can been a quite Dark for some people. So you have the concern.

A another method could proptery load the images to array memory and do gamma your self and load that modifed sprite. Should been pretty easy, but do have something longer load time.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/