Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (SBGuy, Quad), 768 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 3
Page 1 of 6 1 2 3 4 5 6
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 Offline OP
Serious User
Lion_Ts  Offline 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 Offline
Developer
Asse  Offline
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 Offline OP
Serious User
Lion_Ts  Offline 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: Lion_Ts] #51951
08/16/05 17:39
08/16/05 17:39
Joined: Aug 2002
Posts: 2,692
California, USA
bupaje Offline
Expert
bupaje  Offline
Expert

Joined: Aug 2002
Posts: 2,692
California, USA
Thanks for this contribution. I saw on some site it mentioned this as a way to flash the screen red for example when a player was hit, or blue for lightning etc and for overall brightness control as well. Cool.


Find me at: |Stormvisions| Twitter|
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
C
Christoph_B Offline
Serious User
Christoph_B  Offline
Serious User
C

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

A
Anonymous
Unregistered
Anonymous
Unregistered
A



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 Offline
Member
Olzii  Offline
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
Re: Gamma Ramp Correction DLL for FULLSCREEN mode [Re: Olzii] #51955
08/17/05 12:37
08/17/05 12:37
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline OP
Serious User
Lion_Ts  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
I'm newbie, but i think, that effects are postprocessed fullscreen image effects with some shader technique. I just readed some code in DX SDK, where motion blur is implemented.
Try to check shader forum. If You have 3DGS Pro, this effects isn't a problem. I haven't...

Re: Gamma Ramp Correction DLL for FULLSCREEN mode [Re: Lion_Ts] #51956
08/17/05 21:11
08/17/05 21:11
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Great to have an option now for the player for overall brightness control!

Re: Gamma Ramp Correction DLL for FULLSCREEN mode [Re: Pappenheimer] #51957
08/18/05 00:38
08/18/05 00:38
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline
Expert
William  Offline
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
Thanks for the contribution.


Check out Silas. www.kartsilas.com

Hear my band Finding Fire - www.myspace.com/findingfire

Daily dev updates - http://kartsilas.blogspot.com/
Page 1 of 6 1 2 3 4 5 6

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1