Gamma Ramp Correction DLL for FULLSCREEN mode

Posted By: Lion_Ts

Gamma Ramp Correction DLL for FULLSCREEN mode - 08/16/05 14:07

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);
}


Posted By: Asse

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/16/05 14:17

Can you explain what it's doing??
Posted By: Lion_Ts

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/16/05 14:42

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.
Posted By: bupaje

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/16/05 17:39

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.
Posted By: Christoph_B

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/16/05 19:56

reminds of the one from the new GEMS 4. anyway thanks.
Posted By: Anonymous

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/17/05 01:19

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!
Posted By: Olzii

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/17/05 01:29

Hey Lion_Ts,

Do you know how to do camera effects like GTA ?
/Mirage in hot weather, blur, high speed drving effect/
Posted By: Lion_Ts

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/17/05 12:37

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...
Posted By: Pappenheimer

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/17/05 21:11

Great to have an option now for the player for overall brightness control!
Posted By: William

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/18/05 00:38

Thanks for the contribution.
Posted By: Lion_Ts

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/18/05 08:37

TripleX has plan to add my code to BIG.DLL. Check showcase thread.
Posted By: Lion_Ts

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/18/05 08:45

Quote:

Hey Lion_Ts,

Do you know how to do camera effects like GTA ?
/Mirage in hot weather, blur, high speed drving effect/




Mirage in hot weather... Check Rhuarc posts. It seems to me he has one shader for that.
Posted By: Lion_Ts

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 08/18/05 09:39

Quote:

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!



You understand correctly
My code is a color managment, overall brightness is a one small piece of it.
Try to play with different variant of gamma computation, in start is a linear function, as described in DX SDK, at finish You can have awesome effects, like 'zombie' or 'predator' vision
Posted By: Lion_Ts

EXAMPLES for Gamma Ramp Correction DLL - 08/31/05 17:04

Hi!
At first, look at screens from my game project, where I'm using gammaramp.dll: SCREENSHOTS
To KoH request (sepia effect).
In Photoshop, sepia can be done with two methods:
  • 1) desaturate, add colorized adjustment layer
  • 2) with channel mixer

You can do sepia effect with post-process shader applied for whole rendered view, that calculate RGB by formula (2-nd method):

R=1.3*R+1.68*G+1.08*B+0.08
G=1.24*R+1.74*G+1.08*B+0.04
B=1.24*R+1.68*G+1.14*B-0.02

Try to talk on shaders thread about it with shaders gurus.
Or You can drop colors in all level entities for b&w view and apply gamma correction over it (1-st method).
Quick and dirty example for pseudo-sepia with this dll:
Code:

...
gr_red[i] = min(65535.0, pow(i/256.0, 1/br_gamma)*65536+10000.0);
gr_green[i] = pow(i/256.0, 1/br_gamma)*65536;
gr_blue[i] = max(0.0, pow(i/256.0, 1/br_gamma)*65536-10000.0);
...


Some examples to let you start.

more bluish (night/frosted view):
Code:

...
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] = min(65535.0, pow(i/256.0, 1/br_gamma)*65536*2);
...


or mute blue colors:
Code:

...
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)*10000;
...


or some color quantizing (not optimized for clarify idea):
Code:

...
if(i<32){
gr_red[i] = pow(32/256.0, 1/br_gamma)*65536;
gr_green[i] = pow(32/256.0, 1/br_gamma)*65536;
gr_blue[i] = pow(32/256.0, 1/br_gamma)*65536;
}else{
if(i<64){
gr_red[i] = pow(64/256.0, 1/br_gamma)*65536;
gr_green[i] = pow(64/256.0, 1/br_gamma)*65536;
gr_blue[i] = pow(64/256.0, 1/br_gamma)*65536;
}else{
if(i<96){
gr_red[i] = pow(96/256.0, 1/br_gamma)*65536;
gr_green[i] = pow(96/256.0, 1/br_gamma)*65536;
gr_blue[i] = pow(96/256.0, 1/br_gamma)*65536;
}else{
if(i<128){
gr_red[i] = pow(128/256.0, 1/br_gamma)*65536;
gr_green[i] = pow(128/256.0, 1/br_gamma)*65536;
gr_blue[i] = pow(128/256.0, 1/br_gamma)*65536;
}else{
if(i<160){
gr_red[i] = pow(160/256.0, 1/br_gamma)*65536;
gr_green[i] = pow(160/256.0, 1/br_gamma)*65536;
gr_blue[i] = pow(160/256.0, 1/br_gamma)*65536;
}else{
if(i<192){
gr_red[i] = pow(192/256.0, 1/br_gamma)*65536;
gr_green[i] = pow(192/256.0, 1/br_gamma)*65536;
gr_blue[i] = pow(192/256.0, 1/br_gamma)*65536;
}else{
if(i<224){
gr_red[i] = pow(224/256.0, 1/br_gamma)*65536;
gr_green[i] = pow(224/256.0, 1/br_gamma)*65536;
gr_blue[i] = pow(224/256.0, 1/br_gamma)*65536;
}else{
if(i<256){
gr_red[i] = pow(256/256.0, 1/br_gamma)*65536;
gr_green[i] = pow(256/256.0, 1/br_gamma)*65536;
gr_blue[i] = pow(256/256.0, 1/br_gamma)*65536;
}}}}}}}}
...


If you apply special skins for models and do some manipulations with gamma ramp, you can do 'natural' night goggles, for example.
You can shift gamma levels dynamically, using time, for interesting effects. And so on...

And at end I proudly present the Micro$oft Help
Quote:


Gamma controls allow you to change how the system displays the contents of the surface, without affecting the contents of the surface itself. Think of these controls as very simple filters that Microsoft® Direct3D® applies to data as it leaves a surface and before it is rendered on the screen.
Gamma controls are a property of a swap chain. Gamma controls make it possible to dynamically change how a surface's red, green, and blue levels map to the actual levels that the system displays. By setting gamma levels, you can cause the user's screen to flash colors—red when the user's character is shot, green when the character picks up a new item, and so on—without copying new images to the frame buffer to achieve the effect. Or, you might adjust color levels to apply a color bias to the images in the back buffer.
...
In Direct3D, the term gamma ramp describes a set of values that map the level of a particular color component—red, green, blue—for all pixels in the frame buffer to new levels that are received by the DAC for display. The remapping is performed by way of three look-up tables, one for each color component.
Here's how it works: Direct3D takes a pixel from the frame buffer and evaluates its individual red, green, and blue color components. Each component is represented by a value from 0 to 65535. Direct3D takes the original value and uses it to index a 256-element array (the ramp), where each element contains a value that replaces the original one. Direct3D performs this look-up and replace process for each color component of each pixel in the frame buffer, thereby changing the final colors for all the on-screen pixels.
It's handy to visualize the ramp values by graphing them. The first graph of the two following graphs shows a ramp that doesn't modify colors at all. The second graph shows a ramp that imposes a negative bias to the color component to which it is applied.

Output color level
65535
|            *
|
|         *
|
|      *
|
|  *
|________ 65535
Input color level

Output color level
65535
|
|
|
|
|                 *
|         *
|  *
|___________ 65535
Input color level

The array elements for the graph on the left contain values identical to their index—0 in the element at index 0, and 65535 at index 255. This type of ramp is the default, as it doesn't change the input values before they're displayed. The right graph provides more variation; its ramp contains values that range from 0 in the first element to 32768 in the last element, with values ranging uniformly in between. The effect is that the color component that uses this ramp appears muted on the display. You are not limited to using linear graphs; if your application can assign arbitrary mapping if needed. You can even set the entries to all zeroes to remove a color component completely from the display. (if You do this to all RGB, You have nothing - pure black screen Lion Ts)




As you can see, gammaramp.dll is good for quick color effects or 'brightness control’, which theoretically causes no frame rate drop:
Quote:


...By setting gamma levels, you can cause the user's screen to flash colors...without copying new images to the frame buffer to achieve the effect...




That’s all.
Posted By: bupaje

Re: EXAMPLES for Gamma Ramp Correction DLL - 08/31/05 17:21

Thanks for the screenshots. This looks like a very cool and useful dll. Three thumbs up.
Posted By: Lion_Ts

Re: EXAMPLES for Gamma Ramp Correction DLL - 08/31/05 17:38

Bupaje, You are fast as a bullet
I see your replies evrywhere, how you did that ?
Posted By: Anonymous

Re: EXAMPLES for Gamma Ramp Correction DLL - 08/31/05 18:09

have you tested how the framerates with this compared to if you're using a simple four-vertex plane in front of the camera that is transparent and can change colors? I'm wondering how it affects the framerates and whether the plane method is faster.

Also, apprently you're just changing the overall color, can you change the color of each pixel differently (depending on what color is there)?
Posted By: Lion_Ts

Re: EXAMPLES for Gamma Ramp Correction DLL - 08/31/05 18:32

Quote:

have you tested how the framerates with this compared to if you're using a simple four-vertex plane in front of the camera that is transparent and can change colors? I'm wondering how it affects the framerates and whether the plane method is faster.



I didn't compare. But when you place plane in front of camera, this need extra copy operation to frame buffer. Gamma correction method did it without copying. May be it faster (it just a lookup tables for RGB)...
Quote:


Also, apprently you're just changing the overall color, can you change the color of each pixel differently (depending on what color is there)?



Look at Help from Micro$oft above ! The remapping is performed by way of three look-up tables, one for each color component.
Here's how it works: Direct3D takes a pixel from the frame buffer and evaluates its individual red, green, and blue color components. Each component is represented by a value from 0 to 65535. Direct3D takes the original value and uses it to index a 256-element array (the ramp), where each element contains a value that replaces the original one. Direct3D performs this look-up and replace process for each color component of each pixel in the frame buffer, thereby changing the final colors for all the on-screen pixels.
Posted By: Anonymous

Re: EXAMPLES for Gamma Ramp Correction DLL - 08/31/05 20:48

It works good now that I tried it, here's some animated effects for the colors:
Code:


gr_red[i]=pow(((fcos(total_ticks*5-i,125)+125))/256,1/br_gamma)*65536;//transition to inversion and back over time
gr_green[i]=pow(((fcos(total_ticks*5-i,125)+125))/256,1/br_gamma)*65536;
gr_blue[i]=pow(((fcos(total_ticks*5-i,125)+125))/256,1/br_gamma)*65536;




Code:

gr_red[i]=pow(((fcos(total_ticks*5-i,125)+125))/256,1/br_gamma)*65536;//transition through hue over time
gr_green[i]=pow(((fcos(total_ticks*5-i-120,125)+125))/256,1/br_gamma)*65536;
gr_blue[i]=pow(((fcos(total_ticks*5-i-240,125)+125))/256,1/br_gamma)*65536;





Code:

gr_red[i]=pow((i)/256,((1/br_gamma)/2)+fcos(total_ticks*10,1/3))*65536;//transition from bright to dark over time
gr_green[i]=pow((i)/256,((1/br_gamma)/2)+fcos(total_ticks*10,1/3))*65536;
gr_blue[i]=pow((i)/256,((1/br_gamma)/2)+fcos(total_ticks*10,1/3))*65536;





Code:

gr_red[i]=pow((i)/256,1/br_gamma)*fcos(total_ticks*5,65530)+65536;//hue shifter with sudden effects on colors that have 0 values
gr_green[i]=pow((i)/256,1/br_gamma)*fcos(total_ticks*5-120,65530)+65536;
gr_blue[i]=pow((i)/256,1/br_gamma)*fcos(total_ticks*5-240,65530)+65536;


each set of gr_red,gr_green,gr_blue is a different effect, you have to replace that with the one that is already in your wdl (starter gamma_correct). No C++ editing necessary for these.


It only works on fullscreen for me. I also noticed that your formulas do not work well with colors that have 0 values (like if there was 255 red, 0 green, 0 blue), I assume you must be using a multiplication in your formula to cause this problem instead of an addition because you can't brighten a 0 with multiplication but you can with addition. You might also be able to clamp (limit) the values to 1 instead of 0 to correct this.
Posted By: Lion_Ts

Re: EXAMPLES for Gamma Ramp Correction DLL - 08/31/05 21:15

Thank you, WING for your replies.
Yes, it works in fullscreen only, this is piece of thread name
In windowed mode there is other technique.
About formulas: I'll try it.
Posted By: Anonymous

Re: EXAMPLES for Gamma Ramp Correction DLL - 09/01/05 05:17

How do you find out the values of the colors that are already there? For example, I wanna desaturate the screen (make it black and white) but I need to know all 3 color values before I can do this, I will then take the 3 values, average them and then apply the average to all 3 brightnesses of rgb.
Posted By: Orange Brat

Re: EXAMPLES for Gamma Ramp Correction DLL - 09/01/05 08:50

Thanks for the contrib. The other one was DirectX8.1, so it's nice to have an up to date one. Plus, it has been tested. If there is a way to get it to work in Windowed mode, that would be great, but if it's impossible or too much trouble, then no big deal, I suppose.
Posted By: TripleX

Re: EXAMPLES for Gamma Ramp Correction DLL - 09/01/05 10:12

Thank you very much for the examples.. Didn't thought that you can do so nice things with the gamma ramp correction!

Thanks

Triple-X

PS:
Quote:

TripleX has plan to add my code to BIG.DLL. Check showcase thread.





I'll add it within the next big dll update
Posted By: Michael_Schwarz

Re: EXAMPLES for Gamma Ramp Correction DLL - 09/01/05 10:37

Very cool dll from what i see from the screens! Is it A5 compatible or do i have to wait for my A6 to come?
Posted By: Anonymous

Re: EXAMPLES for Gamma Ramp Correction DLL - 09/02/05 02:06

Hey, I published a little example where you can choose different color effects I made with this dll. Click here to download the Thermal Colors examples.......

I couldn't get a screenshot but it looks something like this:

Posted By: Lion_Ts

Re: EXAMPLES for Gamma Ramp Correction DLL - 09/09/05 17:04

Hi, all !
All of you make me happy...
Sorry for long pauses in posting - I don't have instant access to internet. I'm going to internet-cafe, when needed.
TO WING:
When I'm thinking about effect with gamma, I try it in photoshop first Then I try to reproduce that correction in my formulas.
TO ORANGE BRAT:
It's possible, but with other technique, I think about it.
TO TRIPLEX:
YES, all screenshots made from my live game project with gammaramping.
TO MICHAEL SCHWARZ:
I made it with A6 SDK, sorry. Download A6 update...
TO WING again:
Thank you for your little example.
P.S.
When I'm coding, RAMMSTEIN is playing...

Posted By: Lion_Ts

Re: EXAMPLES for Gamma Ramp Correction DLL - 09/10/05 18:05

Quote:

Hey, I published a little example where you can choose different color effects I made with this dll. Click here to download the Thermal Colors examples.......




I'm playing with your 'little' example at last night. Thank you for contribution.
With guys like you world seems better...
Posted By: Lion_Ts

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 09/16/05 11:08

What says Micro$oft about gamma correction in windowed mode:
Quote:


Starting with version DirectX 8.x, setting a gamma ramp has no effect unless the swap chain is full-screen. To change the gamma ramp in windowed mode, use the Microsoft Windows® Graphics Device Interface (GDI) function SetDeviceGammaRamp, which will impact the entire screen(not just the active window). SetDeviceGammaRamp will not allow "extreme" gamma ramps, such as an all red gamma ramp. In contrast, IDirect3DDevice9::SetGammaRamp will clean up the gamma ramp when the application is minimized or exits, and then restore it again when the application is restored.




As you can see, gamma ramp correcting in windowed mode is'nt good idea, you have to use other technique (may be camera.ambient for brightness, but it don't work with some shaders, applied to whole level). Or write fullscreen games !
And disable task swiching. And disable all system keys. And no exit item in menu. And...
Posted By: MASH

Re: EXAMPLES for Gamma Ramp Correction DLL - 11/30/05 04:42

Lion TS,

Is it possible to create a Grayscale effect with this dll, and if possible could you explain how? Would I need to use a shader or can it be done completely through your dll? Thanks for any answer from anybody that might know!
Posted By: Daedelus

Re: EXAMPLES for Gamma Ramp Correction DLL - 11/30/05 05:40

@Wing:
That demo project will not run on my laptop. Keeps crashing after opening.
@LionTS: Are there any known stability issues with this .DLL on some laptops?

Posted By: Lion_Ts

Re: EXAMPLES for Gamma Ramp Correction DLL - 12/04/05 00:35

Daedelus, I don't know. Do you have any problem with other dll (sphere or sylex, for example) on your laptop ?
MASH, real grayscale not for this dll.
Posted By: AAM

Re: EXAMPLES for Gamma Ramp Correction DLL - 12/04/05 23:25

Hi Lion Ts,
Its greate what you did,but when i try it i recieve this error - after the splash window that displays the owner of the product - :-

" dllfunction get_gammaramp not find in DLL "

What i did is :
1- Copied the gammaramp.dll to my acknex plugin directory.
2- Copied the script you put in your thread with out the C++ part in my script.

Im realy not good with dlls , so please help me.
Posted By: PrenceOfDarkness

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/05/05 06:56

great contribution dude!
Posted By: PrenceOfDarkness

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/05/05 07:23

how ever i am getting a problem... On run time it says "get_gamma_ramp not found in dll" and "set_gamma_ramp not found in DLL"... can someone help me?
Posted By: Anonymous

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/05/05 13:32

Daedalus,
Thanks for trying it, I suspect it is because its on a laptop, as their monitor viewing drivers are usually different. If it doesn't work for anyone else though, it must be a mistake I made....

PrenceOfDarkness,
Make sure you're loading the right dll in your script and that you're loading it a second before you start calling functions from it, that could possibly be your problem.

AAM,
You need the dll in the main directory of the WED and SED files (or the .exe if its been published). I don't believe you can even provide a path to it through scripting.
Posted By: Lion_Ts

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/05/05 21:41

Quote:


...dllfunction ... not find in DLL...




dll not in memory, i think.
-check where you placed it (plugin folder / your root folder of published game);
-check c-script (correct names, etc.);
-check last update of DX9.0c;
Posted By: PrenceOfDarkness

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/06/05 04:36

well this is how i have it set up.. and it wont work.. I have directx 9c and here is my script it's called gammaramp.wdl and it's called from my main WDL after I include all my other WDLs

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
function gamma_correct
{
while(player == null){wait(1);}
var i=0;
get_gamma_ramp(gr_red,gr_green,gr_blue); //fill arrays with current gamma ramp
while(1)
{
if (key_any)
{
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()



well what is wrong here?
Posted By: Anonymous

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/06/05 11:45

I put this near the included wdls (not in an action or function):
var_nsave gam_dll;//variable that is not saved, but used on runtime


then this in the first part of the main() function (at the top of the script):

gam_dll=dll_open("gammaramp.dll");
Posted By: PrenceOfDarkness

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/06/05 14:13

okay i finally got it to work lol, thanx alot wing... Hey Lion Ts this would be a million times more useful if you could write a small tutorial for it so alot of newbies (sadly including me ) could get it to work and even to use it to do different things.. Just explain what the variable "i" is for and other things...
Posted By: Lion_Ts

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/06/05 23:05

Sorry, PrenceOfDarkness
I don't know english well to write tutorials...
About i. It's a cycle counter to fill gamma array. I use it in formula to provide 'linear' or 'normal' gamma ramp (try to read DX SDK help for more).
Take a look at all post in this thread and try. Try to write your own formulas to provide gamma correction.
Posted By: PrenceOfDarkness

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/07/05 06:04

okay will do, thanks for the great contribution lion ts
Posted By: ello

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/20/05 08:24

hello lion_ts

can you give me some information how i need to det up my dev-c++ to get your source compiled?
Posted By: AAM

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/20/05 10:37

PrenceOfDarkness , can you please tell how you got it to work cause i have the same error that you got.
Posted By: PrenceOfDarkness

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/21/05 12:35

AAM, i went back to it now, to try and help you out, but I just can't seem to have it working right, It's to bad, it's a great plugin, but with no real help file it's almost useless to us less experienced users...
Posted By: Lion_Ts

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 12/22/05 11:09

Sorry, ello, I haven't dev-c++ (I'm using MSVC6) and never worked with it
Posted By: Anonymous

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 01/29/06 17:05

I made some new gamma correction color effects:
Code:

//gr_red[i]=i*i;//increased color contrast
//gr_green[i]=i*i;
//gr_blue[i]=i*i;

Code:



//gr_red[i]=(120*cos(i*.39)+130)*250;//still hue (SLIGHT DIFFERENCE IN COLORS)
//gr_green[i]=(120*cos(i*.39-120)+130)*250;
//gr_blue[i]=(120*cos(i*.39-240)+130)*250;}


Code:

//gr_red[i]=(120*cos(i*.39-total_ticks*5)+130)*250;//hue shift over time (SLIGHT DIFFERENCE IN COLORS)
//gr_green[i]=(120*cos(i*.39-120-total_ticks*5)+130)*250;
//gr_blue[i]=(120*cos(i*.39-240-total_ticks*5)+130)*250;}

Code:


//gr_red[i]=((fcos((-i*1.41),80)+160)*240);//still hue (BIG DIFFERENCE BETWEEN COLORS)
//gr_green[i]=((fcos((-i*1.41)-120,80)+160)*240);
//gr_blue[i]=((fcos((-i*1.41)-240,80)+160)*240);}


Code:

//gr_red[i]=((fcos((-i*1.41)-total_ticks*5,80)+160)*240);//hue shift over time (BIG DIFFERENCE BETWEEN COLORS)
//gr_green[i]=((fcos((-i*1.41)-120-total_ticks*5,80)+160)*240);
//gr_blue[i]=((fcos((-i*1.41)-240-total_ticks*5,80)+160)*240);}


Code:


//gr_red[i]=((fcos(total_ticks*5-(i*1.41),75)+175)*i);//transition hue over time with contrast!
//gr_green[i]=((fcos(total_ticks*5-(i*1.41)-120,75)+175)*i);
//gr_blue[i]=((fcos(total_ticks*5-(i*1.41)-240,75)+175)*i);}


Code:


//gr_red[i]=(fcos(total_ticks*5-(i*1.41),i)+i)*256;//wacky colors
//gr_green[i]=(fcos(total_ticks*5-(i*1.41)-120,i)+i)*256;
//gr_blue[i]=(fcos(total_ticks*5-(i*1.41)-240,i)+i)*256;}



Code:

//gr_red[i]=(((fcos(total_ticks*5-(i*1.41),75)+175)*256)+(i*256))/2;//slight transition through hue over time
//gr_green[i]=(((fcos(total_ticks*5-(i*1.41)-120,75)+175)*256)+(i*256))/2;
//gr_blue[i]=(((fcos(total_ticks*5-(i*1.41)-240,75)+175)*256)+(i*256))/2;}


Code:


//gr_red[i]=(fcos(total_ticks/5-(i*1.41),i)+i)*i*10;//really wacky colors
//gr_green[i]=(fcos(total_ticks/5-(i*1.41)-120,i)+i)*i*10;
//gr_blue[i]=(fcos(total_ticks/5-(i*1.41)-240,i)+i)*i*10;}


Code:


//gr_red[i]=(80*cos(total_ticks*5)+170)*i;//rainbow hue shifting filter (colors somewhat preserved)
//gr_green[i]=(80*cos(total_ticks*5-120)+170)*i;
//gr_blue[i]=(80*cos(total_ticks*5-240)+170)*i;}


Code:


//gr_red[i]=(fcos(total_ticks*5,i*i)+256);//flashes to different colors and some transition
//gr_green[i]=(fcos(total_ticks*5-120,i*i)+256);
//gr_blue[i]=(fcos(total_ticks*5-240,i*i)+256);}



just put the one you want inside the while(i<256) loop
Posted By: ello

Re: EXAMPLES for Gamma Ramp Correction DLL - 02/08/06 08:16

hi, how is the developement for the window version going? and i have another question. when i compile your source it creates a dll, but that dll gives me error, saying those commands (get_gamma_ramp, ...) are not known.. what could cause this behaviour? the size of the dll is smaller, too

[edit] got it working.
Posted By: Lion_Ts

Re: EXAMPLES for Gamma Ramp Correction DLL - 02/09/06 23:48

hi
development for the window version stopped for now because of luck of free time.

http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/554175/page/0/fpart/3/vc/1#568788
Posted By: ello

Re: EXAMPLES for Gamma Ramp Correction DLL - 02/10/06 07:23

to bad. if only i knew where to start... i still dont know nothing about c++
i hope you'll find some free time:)
Posted By: Michael_Schwarz

Re: EXAMPLES for Gamma Ramp Correction DLL - 03/16/06 16:51

sorry for bumping this up, but after i got my A6 yesterday, i wanted to try this DLL now, but somehow it keeps telling me that "gammaramp.dll" is no valid acknex dll. Can someone help me here?
Posted By: hahn51

Re: EXAMPLES for Gamma Ramp Correction DLL - 09/30/06 22:42

to me it doesn't work! I've includet the wdl script there isn't an error message oder something like that! And when i start (publish or run button) can i see nothing everything is like it was before i've insert the dll! can you help me?

sry for my realy bad english
Posted By: hahn51

Re: EXAMPLES for Gamma Ramp Correction DLL - 11/19/06 12:57

Hi!

I've tested it all the day but it dont work what have i to do?? Can somebody help me??
Posted By: Lion_Ts

Re: EXAMPLES for Gamma Ramp Correction DLL - 11/19/06 13:46

try to recompile it with latest sdk (source code is in the first post in this thread). I can't do it right now (working on compression plugin). I'll do it later, when finish my 'main' task.
Posted By: Anonymous

Re: Gamma Ramp Correction DLL for FULLSCREEN mode - 01/11/07 11:26

Very, very useful!

Thanx, mercuryus
© 2024 lite-C Forums