Jump to content


Photo

Soft r_gamma


87 replies to this topic

#51 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 03 September 2018 - 09:46 AM

Are there other opinions on the problem?

 

I guess trying to avoid color banding was the reason to tweak ambient light.

Such tweak itself may be OK, but I think it cannot replace gamma correction.

IMHO users only use gamma correction when there is no other way to crank the lower-range colors up. So they wouldn't care how exactly we brighten up the darker surfaces.



#52 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1144 posts

Posted 03 September 2018 - 10:55 AM

IMHO users only use gamma correction when there is no other way to crank the lower-range colors up. So they wouldn't care how exactly we brighten up the darker surfaces.

It does not explain why there are both gamma and brightness in settings.

If no one cares how image is brightened, one of them would be enough.



#53 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37455 posts

Posted 03 September 2018 - 11:17 AM

If no one cares how image is brightened, one of them would be enough.

 

 

Gamma increases contrast, not brightness.  That's why I don't understand replacing it with a different system that seems to be another type of brightness.  If there's no way to increase contrast, scenes will just get washed out.


TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#54 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 03 September 2018 - 01:43 PM

 

Gamma increases contrast, not brightness.  That's why I don't understand replacing it with a different system that seems to be another type of brightness.  If there's no way to increase contrast, scenes will just get washed out.

I disagree. What is the gamma formula and how does it relate to contrast?



#55 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37455 posts

Posted 03 September 2018 - 02:30 PM

I don't mean that it works exactly like contrast, but that the effect is to create a greater range of value in dark areas so that there is greater contrast between a dark object and a somewhat dark object.  High brightness washes out scenes.  High gamma maintains contrast between light and darks.  I don't understand how this new 'gamma' can do that if it's just brightening ambient lights on a linear scale. 

 

YQ9I95H.jpg


TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#56 New Horizon

New Horizon

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 13855 posts

Posted 03 September 2018 - 02:40 PM

Also, if it's literally brightening the ambient lights, then that is going to affect gameplay.

#57 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37455 posts

Posted 03 September 2018 - 03:16 PM

Also, if it's literally brightening the ambient lights, then that is going to affect gameplay.

 

 

I think that part has been dealt with already: http://forums.thedar...gamma/?p=416478


TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#58 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 03 September 2018 - 03:53 PM

I don't mean that it works exactly like contrast, but that the effect is to create a greater range of value in dark areas so that there is greater contrast between a dark object and a somewhat dark object.  High brightness washes out scenes.  High gamma maintains contrast between light and darks.  I don't understand how this new 'gamma' can do that if it's just brightening ambient lights on a linear scale. 

 

YQ9I95H.jpg

Right. No, I think the current ambient tweak does exactly what you described, even if it only does it to ambient and does not use a pow() or a lookup table.

It makes dark stuff less dark, without bleaching out the light stuff. And, it does not affect other open windows or cause color banding.

 

@stgatilov

I'm afraid doing this in a postprocessing stage will cause some color banding to return. It's best done before precision loss, i.e. before writing pixels to framebuffer.



#59 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1144 posts

Posted 03 September 2018 - 10:33 PM

@stgatilov

I'm afraid doing this in a postprocessing stage will cause some color banding to return. It's best done before precision loss, i.e. before writing pixels to framebuffer.

Yes, if we use 8-bit colors, then banding is inevitable when gamma correction is used.

But hacks around ambient shaders cannot replace gamma correction.



#60 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 05 September 2018 - 02:57 AM

Technically, gamma doesn't increase contrast. Increasing contrast equals stretching the histogram, so the darks get darker, lights are lighter, and colors get more saturated. Don't remember how gamma worked in 2.05, but in 2.07/beta VBO update 10, r_gamma works similar to output levels black point.

 

obraz.png


  • Bikerdude likes this

#61 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1144 posts

Posted 05 September 2018 - 09:35 AM

Technically, gamma doesn't increase contrast. Increasing contrast equals stretching the histogram, so the darks get darker, lights are lighter, and colors get more saturated. Don't remember how gamma worked in 2.05, but in 2.07/beta VBO update 10, r_gamma works similar to output levels black point.

The current "gamma correction" does not influence interactions.

 

Note that in a proper rendering engine lighting is computed in linear space, and gamma correction is done as the last step. This gamma correction converts the colors from linear space into gamma space. Then the physical monitor has the built in gamma transformation (left over from CRT times), so it transforms colors back from gamma space into linear space, and shows linear intensities. As the result, light sources with quadratic falloff look on the monitor as they look in the real world.

Now with TDM I have no idea what convention is followed. But since all the math is done in additive way (i.e. impacts of lights are added), the whole thing can only be correct if all the colors are in linear space during rendering. It means that someone has to convert them to gamma space at the very end, otherwise monitor will apply gamma transformation to gamma space, and the picture will be over-contracted. As the result, light sources with quadratic falloff will look unrealistically concentrated (since they will actually have falloff with power 4.5): they light close things too bright, but have too small effect on things farther away.

 

The new way gives absolutely no way to correct gamma curve of the actual light sources, while the old way did.

Moreover, the old way was right on the conceptual level, although this correctness gives no benefit if everyone tweaks media using gamma = 1.2.

The serious problem with the old way is that color banding appears on dark colors, because all intermediate rendering results (in linear space) are stored with 8-bit precision. And the common way of fixing it is simply using more precision, e.g. 16-bit floats for colors. This approach is called "High Dynamic Range", and it is necessarily used for physically correct lighting.


  • RPGista and Abusimplea like this

#62 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 05 September 2018 - 09:47 AM

I made my textures and materials with default settings, so with gamma 1.2. Not sure what to do now. Better lighting precision would be very welcome, since e.g. light textures on flat surfaces (without or with mild normalmaps) look like they're from Thief 2.

 

Also, while looking at misc r_ variables, I noticed that default for r_lightscale is not 1 but 2. Was that deliberate, and if so, why?



#63 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 05 September 2018 - 12:58 PM

I made my textures and materials with default settings, so with gamma 1.2. Not sure what to do now. Better lighting precision would be very welcome, since e.g. light textures on flat surfaces (without or with mild normalmaps) look like they're from Thief 2.

 

Also, while looking at misc r_ variables, I noticed that default for r_lightscale is not 1 but 2. Was that deliberate, and if so, why?

It's just an arbitrary value that someone chose at some point in the past. All materials, lights and maps after that were designed against it. No idea who and why, probably just to brighten up the inherently dark materials like wood.



#64 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 05 September 2018 - 01:00 PM

The current "gamma correction" does not influence interactions.

 

Note that in a proper rendering engine lighting is computed in linear space, and gamma correction is done as the last step. This gamma correction converts the colors from linear space into gamma space. Then the physical monitor has the built in gamma transformation (left over from CRT times), so it transforms colors back from gamma space into linear space, and shows linear intensities. As the result, light sources with quadratic falloff look on the monitor as they look in the real world.

Now with TDM I have no idea what convention is followed. But since all the math is done in additive way (i.e. impacts of lights are added), the whole thing can only be correct if all the colors are in linear space during rendering. It means that someone has to convert them to gamma space at the very end, otherwise monitor will apply gamma transformation to gamma space, and the picture will be over-contracted. As the result, light sources with quadratic falloff will look unrealistically concentrated (since they will actually have falloff with power 4.5): they light close things too bright, but have too small effect on things farther away.

 

The new way gives absolutely no way to correct gamma curve of the actual light sources, while the old way did.

Moreover, the old way was right on the conceptual level, although this correctness gives no benefit if everyone tweaks media using gamma = 1.2.

The serious problem with the old way is that color banding appears on dark colors, because all intermediate rendering results (in linear space) are stored with 8-bit precision. And the common way of fixing it is simply using more precision, e.g. 16-bit floats for colors. This approach is called "High Dynamic Range", and it is necessarily used for physically correct lighting.

Wow that's deep. Personally I doubt the gamma table was used for anything other than brightening the picture.



#65 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37455 posts

Posted 05 September 2018 - 03:48 PM

I think the most useful thing would be to see some comparison screenshots like Judith did above, showing what the original gamma correction did to a particular scene, and what the new one does.  Otherwise all of this is rather abstract.   It may turn out that the new system is different, but in a way people prefer.


TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#66 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 06 September 2018 - 12:50 AM

It's just an arbitrary value that someone chose at some point in the past. All materials, lights and maps after that were designed against it. No idea who and why, probably just to brighten up the inherently dark materials like wood.

 

It also helps with postprocess settings and getting that burned highlights. But I'm not sure that was a good idea, it seems like one of the core values that shouldn't be changed, as it affects everything else. Kind of too late for that.



#67 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 06 September 2018 - 03:53 AM

Wow that's deep. Personally I doubt the gamma table was used for anything other than brightening the picture.

By "brightening" I mean adding "contrast" to the low-range colors only, I guess it's what that post was about http://forums.thedar...e-3#entry426872



#68 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 07 September 2018 - 04:39 AM

I made my textures and materials with default settings, so with gamma 1.2. Not sure what to do now. Better lighting precision would be very welcome, since e.g. light textures on flat surfaces (without or with mild normalmaps) look like they're from Thief 2.

 

Also, while looking at misc r_ variables, I noticed that default for r_lightscale is not 1 but 2. Was that deliberate, and if so, why?

BTW the new multi-light shader WIP is not using light textures at all.



#69 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 07 September 2018 - 05:16 AM

That would be interesting. Although the only problem with current light textures is that the engine renders them poorly. Using all 256 gradient steps and less color banding would be a great improvement.



#70 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 14 September 2018 - 09:45 AM

Switched to two gamma modes: exponential (1.0 - 3.0) and hyperbolic  (0.1-1.0)

The cvar value inherited from 2.06 should result in more or less the same look after update.

I assume nobody actually used r_gamma<1 or else they are for a surprise LOL

Attached are screenshots with soft r_gamma 2.0 and 0.2 for comparison.

Attached Thumbnails

  • Untitled.jpg

  • Judith likes this

#71 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 14 September 2018 - 11:36 AM

Exponential is the effect you see in games most often IMO, but I like how hyperbolic maintains contrast.



#72 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 14 September 2018 - 03:30 PM

Exponential is the effect you see in games most often IMO, but I like how hyperbolic maintains contrast.

Which is why I'll be using it myself. @stgatilov is the one who wants exponential (but in a different place)



#73 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37455 posts

Posted 14 September 2018 - 03:50 PM

I assume nobody actually used r_gamma<1 or else they are for a surprise LOL

 

 

What does this mean?  My gamma has traditionally been set to .9.  What kind of a "surprise" am I in for?


TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#74 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1831 posts

Posted 15 September 2018 - 12:03 AM

 

What does this mean?  My gamma has traditionally been set to .9.  What kind of a "surprise" am I in for?

Ambient would have been brighter for you.

Why so low? Are you trying to add contrast this way? Can you see the ambient at all?



#75 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1731 posts

Posted 15 September 2018 - 02:13 AM

IMO you need that initial lack of contrast in your scenes to account for many monitor setups and configurations players may have. If you want to bump contrast a little bit, you can turn postprocessing on and off to see how it looks like (it adds some contrast, apart from the bloom effect).


Edited by Judith, 15 September 2018 - 02:13 AM.




Reply to this topic



  


1 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


    Google (1)