Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gloom: Vertex flags control texture coordinate generation
- Loading branch information
Showing
5 changed files
with
59 additions
and
20 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
8 changes: 8 additions & 0 deletions
8
doomsday/tests/test_gloom/net.dengine.gloom.pack/shaders/flags.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,8 @@ | ||
#ifndef GLOOM_FLAGS_H | ||
#define GLOOM_FLAGS_H | ||
|
||
const uint Surface_WorldSpaceXZToTexCoords = 1u; | ||
|
||
#define testFlag(flags, f) (((flags) & (f)) != 0u) | ||
|
||
#endif // GLOOM_FLAGS_H |
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
23 changes: 16 additions & 7 deletions
23
doomsday/tests/test_gloom/net.dengine.gloom.pack/shaders/surface.vsh
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 |
---|---|---|
@@ -1,17 +1,26 @@ | ||
#include 'flags.glsl' | ||
|
||
uniform mat4 uMvpMatrix; | ||
|
||
DENG_ATTRIB vec4 aVertex; | ||
DENG_ATTRIB vec2 aUV; | ||
DENG_ATTRIB vec3 aNormal; | ||
DENG_ATTRIB uint aTexture; | ||
DENG_ATTRIB vec4 aVertex; | ||
DENG_ATTRIB vec2 aUV; | ||
DENG_ATTRIB vec3 aNormal; | ||
DENG_ATTRIB float aTexture; | ||
DENG_ATTRIB float aFlags; | ||
|
||
DENG_VAR vec2 vUV; | ||
DENG_VAR vec3 vNormal; | ||
flat DENG_VAR uint vTexture; | ||
DENG_VAR vec2 vUV; | ||
DENG_VAR vec3 vNormal; | ||
flat DENG_VAR float vTexture; | ||
flat DENG_VAR uint vFlags; | ||
|
||
void main(void) { | ||
gl_Position = uMvpMatrix * aVertex; | ||
vUV = aUV; | ||
vNormal = aNormal; | ||
vTexture = aTexture; | ||
vFlags = floatBitsToUint(aFlags); | ||
|
||
if (testFlag(vFlags, Surface_WorldSpaceXZToTexCoords)) { | ||
vUV += aVertex.xz; | ||
} | ||
} |