Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, degenerate_762, AndrewAMD, ozgur), 774 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 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