🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Move fog plane to desired location?

Started by
1 comment, last by terrysworkstations 3 years, 6 months ago

Doing fog in shader. If I want to see fog on other side of plane and not see any fog on other side of plane because im doing a mountain scene or something. How can i adjust the plane to a specific location? Right now the plane stays at origin on the x axis.

if (gFogEnabled)

{

float fogDensity = 0.0001;

float kFogEpsilon = 0.0001;

float3 F = float3(1, 0, 0); //Plane

float3 C = gEyePosW; // Camera Position

float3 P = pin.PosW; //Pixel Position

float3 V = C - P; // To Eye Vector

float FV = dot(F, V);

float m;

if (dot(F, C) < 0)

{

m = 1;

}

else

{

m = 0;

}

float u1 = m * (dot(F, C) + dot(F, P));

float u2 = dot(F, P) * sign(dot(F, C));

float x = min(u2, 0.0);

x = 0.5 * fogDensity * -length(V) * (u1 - x * x / (abs(FV) + kFogEpsilon));

float f = saturate(exp2(-x));

litColor.rgb = litColor.rgb * f + gFogColor * (1 - f);

}

Advertisement

Nevermind, i fixed it by making the plane 4D instead of 3D.

This topic is closed to new replies.

Advertisement