Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Model Renderer: Added fog to the model shaders
The fog start/end depths and the near/far clipping planes are passed to the model shaders, which are expected to use "include/fog.glsl" in their fragment shader. The fog GL parameters were slightly refactored by moving them into a single struct.
- Loading branch information
Showing
12 changed files
with
145 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/fog.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* The Doomsday Engine Project | ||
* Common OpenGL Shaders: Fog (fragment shader) | ||
* | ||
* Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* LGPL: http://www.gnu.org/licenses/lgpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
* General Public License for more details. You should have received a copy of | ||
* the GNU Lesser General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
uniform highp vec4 uFogRange; // startDepth, fogDepth, nearclip, farclip | ||
uniform highp vec4 uFogColor; // set alpha to zero to disable fog | ||
|
||
void applyFog() | ||
{ | ||
if(uFogColor.a > 0.0) | ||
{ | ||
highp float near = uFogRange.z; | ||
highp float far = uFogRange.w; | ||
|
||
// First convert the fragment Z back to view space. | ||
highp float zNorm = gl_FragCoord.z * 2.0 - 1.0; | ||
highp float zEye = -2.0 * far * near / (zNorm * (far - near) - (far + near)); | ||
|
||
highp float fogAmount = clamp((zEye - uFogRange.x) / uFogRange.y, 0.0, 1.0); | ||
gl_FragColor.rgb = mix(gl_FragColor.rgb, uFogColor.rgb, fogAmount); | ||
|
||
// gl_FragColor.rgb = vec3(zEye, 0.0, normZ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.