Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renderer|Refactor: Added tangentspace.glsl; moved lighting functions
Doomsday will now define the symbols DENG_VERTEX_SHADER or DENG_FRAGMENT_SHADER when it compiles vertex and fragment shaders. This allows the included GLSL files to adapt their behavior accordingly.
- Loading branch information
Showing
4 changed files
with
75 additions
and
28 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
36 changes: 36 additions & 0 deletions
36
doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/tangentspace.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,36 @@ | ||
/* | ||
* The Doomsday Engine Project | ||
* Common OpenGL Shaders: Tangent space | ||
* | ||
* 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> | ||
*/ | ||
|
||
attribute highp vec3 aNormal; | ||
attribute highp vec3 aTangent; | ||
attribute highp vec3 aBitangent; | ||
|
||
highp vec3 transformVector(highp vec3 dir, highp mat4 matrix) | ||
{ | ||
return (matrix * vec4(dir, 0.0)).xyz; | ||
} | ||
|
||
highp mat3 tangentSpace(highp mat4 modelSpace) | ||
{ | ||
highp vec3 normal = transformVector(aNormal, modelSpace); | ||
highp vec3 tangent = transformVector(aTangent, modelSpace); | ||
highp vec3 bitangent = transformVector(aBitangent, modelSpace); | ||
return mat3(tangent, bitangent, normal); | ||
} |
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