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 (AndrewAMD, Quad), 755 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 2 of 6 1 2 3 4 5 6
Re: Gamma Ramp Correction DLL for FULLSCREEN mode [Re: William] #51958
08/18/05 08:37
08/18/05 08: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
TripleX has plan to add my code to BIG.DLL. Check showcase thread.

Re: Gamma Ramp Correction DLL for FULLSCREEN mode [Re: Olzii] #51959
08/18/05 08:45
08/18/05 08:45
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
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.

Re: Gamma Ramp Correction DLL for FULLSCREEN mode [Re: ] #51960
08/18/05 09:39
08/18/05 09:39
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
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

EXAMPLES for Gamma Ramp Correction DLL [Re: Lion_Ts] #51961
08/31/05 17:04
08/31/05 17:04
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
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.

Re: EXAMPLES for Gamma Ramp Correction DLL [Re: Lion_Ts] #51962
08/31/05 17:21
08/31/05 17:21
Joined: Aug 2002
Posts: 2,692
California, USA
bupaje Offline
Expert
bupaje  Offline
Expert

Joined: Aug 2002
Posts: 2,692
California, USA
Thanks for the screenshots. This looks like a very cool and useful dll. Three thumbs up.


Find me at: |Stormvisions| Twitter|
Re: EXAMPLES for Gamma Ramp Correction DLL [Re: bupaje] #51963
08/31/05 17:38
08/31/05 17:38
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
Bupaje, You are fast as a bullet
I see your replies evrywhere, how you did that ?

Re: EXAMPLES for Gamma Ramp Correction DLL [Re: bupaje] #51964
08/31/05 18:09
08/31/05 18:09

A
Anonymous
Unregistered
Anonymous
Unregistered
A



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)?

Re: EXAMPLES for Gamma Ramp Correction DLL [Re: ] #51965
08/31/05 18:32
08/31/05 18:32
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
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.

Re: EXAMPLES for Gamma Ramp Correction DLL [Re: Lion_Ts] #51966
08/31/05 20:48
08/31/05 20:48

A
Anonymous
Unregistered
Anonymous
Unregistered
A



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.

Re: EXAMPLES for Gamma Ramp Correction DLL [Re: ] #51967
08/31/05 21:15
08/31/05 21:15
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
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.

Last edited by Lion_Ts; 08/31/05 21:16.
Page 2 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