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 (Ayumi), 662 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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