New fog shader
Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
This commit is contained in:
parent
f43a9e45e6
commit
1abc5624fb
2 changed files with 30 additions and 0 deletions
19
Shaders/include_fog.frag
Normal file
19
Shaders/include_fog.frag
Normal file
|
@ -0,0 +1,19 @@
|
|||
//#define FOG_FUNCTION
|
||||
//default fog
|
||||
//varying float fogCoord;
|
||||
varying vec3 PointPos;
|
||||
//varying vec4 EyePos;
|
||||
|
||||
vec3 fog_Func(vec3 color, int type)
|
||||
{
|
||||
//if (type == 0){
|
||||
const float LOG2 = 1.442695;
|
||||
//vec3 EyePos = vec3(0.0);
|
||||
float fogCoord =length(PointPos);
|
||||
float fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2);
|
||||
|
||||
if(gl_Fog.density == 1.0)
|
||||
fogFactor=1.0;
|
||||
|
||||
return mix(gl_Fog.color.rgb, color, fogFactor);
|
||||
}
|
11
Shaders/include_fog.vert
Normal file
11
Shaders/include_fog.vert
Normal file
|
@ -0,0 +1,11 @@
|
|||
//varying float fogCoord;
|
||||
varying vec3 PointPos;
|
||||
//varying vec4 EyePos;
|
||||
|
||||
void fog_func(int type)
|
||||
{
|
||||
PointPos = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
//PointPos = gl_Vertex;
|
||||
//EyePos = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0);
|
||||
//fogCoord = abs(ecPosition.z);
|
||||
}
|
Loading…
Add table
Reference in a new issue