GeeXLab
Current version: 0.17.x
»GeeXLab homepage

FurMark
Current version: 1.19.1
»FurMark homepage
»FurMark 1.9.x Submissions

GPU Caps Viewer
Current version: 1.37.0.0
»GPU Caps Viewer homepage
»GPU DB Submissions

GPU Shark
Current version: 0.10.0.4
»GPU Shark homepage


Blogs
»JeGX's HackLab

Geeks3D's Articles
»GPU Memory Speed Demystified

»Multi-Threading Programming Resources

»GeForce and Radeon OpenCL Overview

»How to Get your Multi-core CPU Busy at 100%

»How To Make a VGA Dummy Plug

»Night Vision Post Processing Filter


PhysX FluidMark
Current version: 1.5.2
»FluidMark homepage
»FluidMark 1.4.x Submissions

TessMark
Current version: 0.3.0
»TessMark homepage

ShaderToyMark
Current version: 0.3.0
»ShaderToyMark homepage
»ShaderToyMark Scores

Demoniak3D
Current Version: 1.23.0
»Demoniak3D
»Download
»Libraries and Plugins
»Demos
»Online Help - Reference Guide
»Codes Samples

3D Graphics Search Engine:

The Geeks Of 3D

 
Fog in GLSL

By Jerome 'JeGX' Guinot - jegx_AT_ozone3d(dot)net

Initial draft: December 21, 2007


[ Index ]

Page 1 | Page 2 | Page 3 | Page 4 | Page 5

»Next Page





2 - Fog Density Equations

These equations allow to define the way fog density behaves according to the distance between the camera and a given vertex . The aim of these equations is to compute a fog factor, (the fogFactor) that will allow to mix the fragment color (at the pixel shader level) with the fog color. With fixed pipeline, there are two ways to compute the fog factor: linear or exponential.

We will focus on the exponential method, because of its more realistic fog rendering possibilities . But keep in mind that those methods are linked to the fixed pipeline and that with the programmable pipeline we can compute totaly different calculus which shall suit better to a given scene (as an example, for each color composant we can set a different fog factor) .

The fog density equations are as follows :

Linear equation (corresponds to GL_LINEAR):

fogFactor = (end - z) / (end - start)

Exponential equations (correspond to GL_EXP and GL_EXP2):

fogFactor = e-(density * z)

and
fogFactor = e-(density * z)2

The following chart shows the fog factor evolution according to the distance :

Fog Factor - GL_LINEAR - GL_EXP - GL_EXP2





[ Index ]

Page 1 | Page 2 | Page 3 | Page 4 | Page 5

»Next Page





GeeXLab demos


GLSL - Mesh exploder


PhysX 3 cloth demo


Normal visualizer with GS


Compute Shaders test on Radeon


Raymarching in GLSL



Geeks3D latest news


Geeks3D forum news


Misc
»Texture DataPack #1
»Asus Silent Knight CPU Cooler
Page generated in 0.0068349838256836 seconds.