FunkyFr3sh / cnc-ddraw

GDI, OpenGL and Direct3D 9 re-implementation of the DirectDraw API for classic 2D games for better compatibility with Windows ME, 2000, XP, Vista, 7, 8, 10, 11, Wine (Linux/macOS/Android) and Virtual Machines
https://discord.gg/afWXJNDDF5
MIT License
2.23k stars 143 forks source link

Divine Divinity Gamma setting gets reset to 1.0 #280

Open Asdow opened 8 months ago

Asdow commented 8 months ago

Pretty much what the title says. When using cnc-ddraw with openGL renderer, adjusting gamma from the ingame settings gets immediately reset back to 1.0 after pressing OK. Does not happen if I launch the game without the wrapper.

FunkyFr3sh commented 8 months ago

Yeah, that feature isn't supported yet, only got a few stubs for it right now https://github.com/FunkyFr3sh/cnc-ddraw/blob/master/src/IDirectDraw/IDirectDrawGammaControl.c

Will have to think about a solution for it

elishacloud commented 8 months ago

Direct3D9 does have gamma controls. But as far as I can tell they only work in exclusive fullscreen mode. This might be a case where shaders are needed.

The same issue happens in d3d8to9 because Direct3D8 allows setting gamma in all modes. Whereas, setting gamma in Direct3D9 only works when in exclusive fullscreen mode.

Last time I checked, WineD3D solved this by using Windows gamma controls. However, that makes the whole screen change gamma, not just the specific window.

I am not sure about the OpenGL renderer, but it may have similar problems.

FunkyFr3sh commented 4 months ago

There's now a new shader called "image-adjustment.glsl" included - it will get the job done. Also, latest version can now combine 2 shaders, so you could upscale with one and use image-adjustments as the second shader (rename to same as upscaler and append .pass1)

Not very user friendly yet, but get's the job done. Will try to get a better solution working later

Values that can be changed in "shader-package.zip/shaders/misc/image-adjustment.glsl"


#define ia_overscan_percent_x 0.0  // crop width of image by X%; default is 0.0
#define ia_overscan_percent_y 0.0  // crop height of image by X%; default is 0.0
#define ia_ZOOM 1.0                // zoom factor; default is 1.0
#define ia_XPOS 0.0                // horizontal position modifier; default is 0.0
#define ia_YPOS 0.0                // vertical position modifier; default is 0.0
#define ia_FLIP_HORZ 0.0           // horizontal flip toggle; default is 0.0
#define ia_FLIP_VERT 0.0           // vertical flip toggle; default is 0.0
#define ia_target_gamma 2.2    // the gamma you want the image to have; CRT TVs typically have a gamma of 2.4
#define ia_monitor_gamma 2.2   // gamma setting of your current display; LCD monitors typically have a gamma of 2.2
#define ia_saturation 1.0      // color saturation; default 1.0
#define ia_contrast 1.0        // image contrast; default 1.0
#define ia_luminance 1.0       // image luminance; default 1.0
#define ia_black_level 0.0     // black level; default 0.0
#define ia_bright_boost 0.0    // adds to the total brightness. Negative values decrease it; Use values between 1.0 (totally white) and -1.0 (totally black); default is 0.0
#define ia_R 1.0               // red level; default 1.0
#define ia_G 1.0               // green level; default 1.0
#define ia_B 1.0               // red level; default 1.0
#define ia_TOPMASK 0.0         // mask top of image by X%; default is 0.0
#define ia_BOTMASK 0.0         // mask bottom of image by X%; default is 0.0
#define ia_LMASK 0.0           // mask left of image by X%; default is 0.0
#define ia_RMASK 0.0           // mask right of image by X%; default is 0.0
#define ia_GRAIN_STR 0.0       // grain filter strength; default is 0.0
#define ia_SHARPEN 0.0         // sharpen filter strength; default is 0.0

Latest build: cnc-ddraw.zip

SilentMRG commented 3 months ago

Pretty much what the title says. When using cnc-ddraw with openGL renderer, adjusting gamma from the ingame settings gets immediately reset back to 1.0 after pressing OK. Does not happen if I launch the game without the wrapper.

Have you tried this (?): https://www.gog.com/forum/divinity_series/divine_divinity_improve_performance