- Home /
Curve/Bend Global fog
Any information on how to bend a global fog in a shape of parabola , because I use a shader which bends the world , but global fog goes straight ?
Answer by tanoshimi · Nov 21, 2016 at 10:23 PM
If you look at the GlobalFog.shader file, you'll see the functions fairly well-commented.
Distance-based fog is calculated in the pixel shader by calling ComputeDistance(). This method returns a float based on the length of the world space vector from the camera towards the screen pixel (if using radial distance), or just the simple depth of the pixel if not using radial distance.
Height-based fog is calculated in linear half-space, using the technique described at https://www.terathon.com/lengyel/Lengyel-UnifiedFog.pdf. The value of note here is
_HeightParams.y
, which is F · C - the difference between the camera height and the fog height. To create a parabolic fog line, you'll need to adjust this value to account for the absolute difference in the x axis between the pixel being rendered and the camera's x position (in the camera's local space).
Thank a lot for the information ! I found FdotC variable in both shader & c# files , however as I am complete shader noob , I cannot imagine how to find pixel.x and camera.x coordinates. seems to be an easy task , but I feel lost , so some help would be appreciated.
Answer by AurimasBlazulionis · Nov 21, 2016 at 08:17 PM
You can define curves using AnimationCurve class. Once you make the curve look what you like, at any time call theCurve.Evaluate(point)
to get the value.