Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (2 invisible), 672 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to implement fog in a hlsl shader? #213360
06/27/08 10:35
06/27/08 10:35
Joined: Dec 2007
Posts: 17
Mare Offline OP
Newbie
Mare  Offline OP
Newbie

Joined: Dec 2007
Posts: 17
I have made some simple shaders for use in my game, actualy I modified those shaders from the "Introduction to shader programming" by Taco Cohen, and now I added some fog to my level and I noticed that no model that has a shader attached is affected by the fog. The question is simple: How do I implement the fog in the shader?

Thank you

Re: How to implement fog in a hlsl shader? [Re: Mare] #213368
06/27/08 11:23
06/27/08 11:23
Joined: Jun 2004
Posts: 655
to your left
BoH_Havoc Offline
User
BoH_Havoc  Offline
User

Joined: Jun 2004
Posts: 655
to your left
in your vertex shader output struct declare this

float Fog : FOG;

and in the vertex shader itself do something like this:

float3 PosWorld = mul(Pos, matWorld);
float ofog = 1 - (distance(PosWorld, vecViewPos) - vecFog.x) * (vecFog.z);
Out.Fog = ofog;

you also have to declare vecViewPos and vecFog of course so add this at the top of your fx file
float4 vecViewPos;
float4 vecFog;

that should be it.

You could also try to set
FogEnable = False;
in your technique. That might work for some shaders.


Shade-C EVO Lite-C Shader Framework

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