Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,310 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
fog with shaders #61877
01/12/06 23:13
01/12/06 23:13
Joined: Mar 2002
Posts: 221
USA
zefor Offline OP
Member
zefor  Offline OP
Member

Joined: Mar 2002
Posts: 221
USA
Is there a way to have the shader objects react better with fog. Have them blend into the fog instead of stick out when you are far away from them?

Re: fog with shaders [Re: zefor] #61878
01/13/06 06:04
01/13/06 06:04
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Sure there is, but it takes a bit of trickery. First of all, this only occurs when you use blend mode like mulitply or additive, and mulitple passes.

Say you have a two pass shader, and the second pass is added to the first. Becasue each pass is fogged seperately, the second pass wi9ll also add the fog color to the first, giving you a lighter overall fog color. The way to deal with this in this case is chnage the fog color for the second pass only, to black.

This is done like this--in your technique, in the second pass, put this line:
fogcolor={0.0,0.0,0.0,0.0};

If that second pass is multiplied, you want the fog color to be white:
fogcolor={1.0,1.0,1.0,1.0};

This may not work if you are using other, non-standard blending modes, but additive and multiply are the ones used in nearly all multi-pass shaders, in whcih the first pass is not blended normally... so this work for nealry all cases where you need normal fogging (such as in multi-pass per-pixel lighting).


Sphere Engine--the premier A6 graphics plugin.
Re: fog with shaders [Re: Matt_Aufderheide] #61879
01/13/06 15:18
01/13/06 15:18
Joined: Mar 2002
Posts: 221
USA
zefor Offline OP
Member
zefor  Offline OP
Member

Joined: Mar 2002
Posts: 221
USA
So This cant be incoporated into your "bump specular with sun" script?

P.S. How did you get to be so knowledgeable of shaders?

Re: fog with shaders [Re: zefor] #61880
01/13/06 16:08
01/13/06 16:08
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
hmm.. you dont need to use this mehtod with a single pass shader. Simply calculate the normal fog values in that shader...to do this simpoly find this block of code in the vertex shader:
// float ofog = 1 - (distance(PosWorld, vecViewPos) - vecFog.x)*(vecFog.z);
// Out.Fog = ofog;
Out.Fog = 10000;

and just uncomment the first two lines, and comment out this one:
Out.Fog = 10000;

then you should have correct fogging.

About how i learned about shaders: just a lot of work converting other shaders, reading theory, and asking questions. I am by no means an expert, however.


Sphere Engine--the premier A6 graphics plugin.

Moderated by  Blink, Hummel, Superku 

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