1 registered members (tomaslolo),
1,542
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Gamma Ramp Correction DLL for FULLSCREEN mode
#51948
08/16/05 14:07
08/16/05 14:07
|
Joined: Aug 2005
Posts: 1,185 Ukraine
Lion_Ts
OP
Serious User
|
OP
Serious User
Joined: Aug 2005
Posts: 1,185
Ukraine
|
compiled gammaramp.dll Code:
//-------------------------- WDL code ----------------------------- //2005 by LionTs. //Free for all 3DGS community. Just send me $1000 per one game start. //Ok, it's my another stupid joke :) //Correct gamma ramp for FULLSCREEN mode. // I'm trying to implement gammaramp in windowed mode thru GetDeviceGammaRamp, // but I think it's useless. //It's just an example, try to modify formula for gamma ramp arrays, //You'll see intresting usefull effects.
//////////all code is working, I'm using this stuff in my game project
//function for simple gamma manipulation like overall brightness or color splash dllfunction set_gamma(var,var,var); //red green blue: 0 - ~3.5, change overall brightness if all are equal //functions for advansed effects like color inverted vision dllfunction get_gamma_ramp(&var,&var,&var); //arrays of gamma ramp values: 0-65536 dllfunction set_gamma_ramp(&var,&var,&var); //arrays of gamma ramp values: 0-65536 var gr_red[256]; var gr_green[256]; var gr_blue[256]; var br_gamma=1.0; //example for overall brightness correction //PGUP & PGDN change it ingame starter gamma_correct{ var i=0; get_gamma_ramp(gr_red,gr_green,gr_blue); //fill arrays with current gamma ramp while(1){ if (key_any){ if(key_pgup){ br_gamma+=time*0.1; br_gamma=min(br_gamma,2.0); }else{ if(key_pgdn){ br_gamma-=time*0.1; br_gamma=max(br_gamma,0.5); } } i=0; while(i<256){ //calculate values for gamma ramp gr_red[i]=pow(i/256.0,1/br_gamma)*65536; gr_green[i]=pow(i/256.0,1/br_gamma)*65536; gr_blue[i]=pow(i/256.0,1/br_gamma)*65536; /* //try this, for example gr_red[i]=pow((256.0-i)/256.0,1/br_gamma)*65536; gr_green[i]=pow((256.0-i)/256.0,1/br_gamma)*65536; gr_blue[i]=pow((256.0-i)/256.0,1/br_gamma)*65536; */ i+=1; } set_gamma_ramp(gr_red,gr_green,gr_blue); //commit new gamma ramp } wait(1); } }//END of GAMMA_CORRECT() //------------------------ CUT ----------------------------------------- //////////////////////////////////////////////////////////////////////// //This is the C++ code, if You want to play with it, //compiled with DX9.0 SDK and 3DGS SDK. typedef struct _tgamma_ramp{ var value[256]; } tgamma_ramp;
DLLFUNC void set_gamma(var ingamma_red,var ingamma_green,var ingamma_blue) { HRESULT hr; double gamma_red; double gamma_green; double gamma_blue; D3DGAMMARAMP gamma_ramp;
LPDIRECT3DDEVICE9 pd3ddev=(LPDIRECT3DDEVICE9)draw_begin(); if (FAILED(hr=pd3ddev->TestCooperativeLevel())) return; gamma_red = max(_FLOAT(ingamma_red), 0.01); gamma_green = max(_FLOAT(ingamma_green), 0.01); gamma_blue = max(_FLOAT(ingamma_blue), 0.01); for(int i=0; i<256; i++) { gamma_ramp.red[i] = (unsigned short)(pow(i/256.0, 1/gamma_red)*65536); gamma_ramp.green[i] = (unsigned short)(pow(i/256.0, 1/gamma_green)*65536); gamma_ramp.blue[i] = (unsigned short)(pow(i/256.0, 1/gamma_blue)*65536); } pd3ddev->SetGammaRamp(0,D3DSGR_CALIBRATE, &gamma_ramp);//D3DSGR_NO_CALIBRATION } DLLFUNC void get_gamma_ramp(tgamma_ramp* gamma_ramp_red,tgamma_ramp* gamma_ramp_green,tgamma_ramp* gamma_ramp_blue) { HRESULT hr; D3DGAMMARAMP gamma_ramp; LPDIRECT3DDEVICE9 pd3ddev=(LPDIRECT3DDEVICE9)draw_begin(); if (FAILED(hr=pd3ddev->TestCooperativeLevel())) return; pd3ddev->GetGammaRamp(0,&gamma_ramp); for(int i=0; i<256; i++){ gamma_ramp_red->value[i]=_VAR(gamma_ramp.red[i]); gamma_ramp_green->value[i]=_VAR(gamma_ramp.green[i]); gamma_ramp_blue->value[i]=_VAR(gamma_ramp.blue[i]); } } DLLFUNC void set_gamma_ramp(tgamma_ramp* gamma_ramp_red,tgamma_ramp* gamma_ramp_green,tgamma_ramp* gamma_ramp_blue) { HRESULT hr; D3DGAMMARAMP gamma_ramp; LPDIRECT3DDEVICE9 pd3ddev=(LPDIRECT3DDEVICE9)draw_begin(); if (FAILED(hr=pd3ddev->TestCooperativeLevel())) return; for(int i=0; i<256; i++){ gamma_ramp.red[i]=(unsigned short)_INT(gamma_ramp_red->value[i]); gamma_ramp.green[i]=(unsigned short)_INT(gamma_ramp_green->value[i]); gamma_ramp.blue[i]=(unsigned short)_INT(gamma_ramp_blue->value[i]); } pd3ddev->SetGammaRamp(0,D3DSGR_CALIBRATE,&gamma_ramp); }
Last edited by Lion_Ts; 08/16/05 14:32.
|
|
|
Re: Gamma Ramp Correction DLL for FULLSCREEN mode
[Re: Lion_Ts]
#51949
08/16/05 14:17
08/16/05 14:17
|
Joined: Feb 2005
Posts: 728 Germany, Berlin
Asse
Developer
|
Developer
Joined: Feb 2005
Posts: 728
Germany, Berlin
|
Can you explain what it's doing??
A6.31.4 Commercial
AMD Athlon XP 2400+
Radeon 9800Pro
512MB DDR-Ram
Windows XP Professional SP2
3D GameStudio Magazin
|
|
|
Re: Gamma Ramp Correction DLL for FULLSCREEN mode
[Re: Asse]
#51950
08/16/05 14:42
08/16/05 14:42
|
Joined: Aug 2005
Posts: 1,185 Ukraine
Lion_Ts
OP
Serious User
|
OP
Serious User
Joined: Aug 2005
Posts: 1,185
Ukraine
|
Change gamma ramp You can change overall ingame brightness with slider or buttons. Or apply special fullscreen effects... Try it and You'll see. Place DLL in your plugins dir, cut WDL code and write it down to your 'main.wdl'. Make shure your game started in fullscreen or press ALT+ENTER, then play with PG_UP and PG_DN keys. It's hard to explain - my english vocabulary is about 5 words Sorry.
|
|
|
Re: Gamma Ramp Correction DLL for FULLSCREEN mode
[Re: bupaje]
#51952
08/16/05 19:56
08/16/05 19:56
|
Joined: Nov 2003
Posts: 1,267 ef
Christoph_B
Serious User
|
Serious User
Joined: Nov 2003
Posts: 1,267
ef
|
reminds of the one from the new GEMS 4. anyway thanks.
sef
|
|
|
Re: Gamma Ramp Correction DLL for FULLSCREEN mode
[Re: Christoph_B]
#51953
08/17/05 01:19
08/17/05 01:19
|
Anonymous
Unregistered
|
Anonymous
Unregistered
|
wow, this is awesome! thanks, Lion_ts, I think I can tweak it to change hue and saturation as well, then be able to color shift the screen through the spectrum!
|
|
|
Re: Gamma Ramp Correction DLL for FULLSCREEN mode
[Re: ]
#51954
08/17/05 01:29
08/17/05 01:29
|
Joined: Sep 2004
Posts: 260 UB,Mongolia
Olzii
Member
|
Member
Joined: Sep 2004
Posts: 260
UB,Mongolia
|
Hey Lion_Ts,
Do you know how to do camera effects like GTA ? /Mirage in hot weather, blur, high speed drving effect/
Last edited by Olzii; 08/17/05 01:31.
The Empire of the Mongols comprised the largest continuous land empire ever, reaching from Korea to Poland
|
|
|
|