-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gfx: make shaders compatible with GLSL 1.20
- Loading branch information
Showing
5 changed files
with
18 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
#version 130 | ||
#extension GL_ARB_explicit_attrib_location: enable | ||
#version 120 | ||
|
||
in vec2 vertTexCoords; | ||
|
||
layout(location = 0) out vec4 fragColor; | ||
varying vec2 vertTexCoords; | ||
|
||
uniform sampler2D tex0; | ||
|
||
void main(void) { | ||
fragColor = texture(tex0, vertTexCoords); | ||
gl_FragColor = texture2D(tex0, vertTexCoords); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,35 @@ | ||
#version 130 | ||
#extension GL_ARB_explicit_attrib_location: enable | ||
#version 120 | ||
#extension GL_EXT_gpu_shader4: enable | ||
|
||
in vec4 vertColor; | ||
in vec3 vertTexCoords; | ||
|
||
layout(location = 0) out vec4 fragColor; | ||
varying vec4 vertColor; | ||
varying vec3 vertTexCoords; | ||
|
||
uniform sampler2D tex0; | ||
uniform bool texturingEnabled; | ||
uniform bool smoothingEnabled; | ||
|
||
void main(void) { | ||
fragColor = vertColor; | ||
gl_FragColor = vertColor; | ||
|
||
if (texturingEnabled) { | ||
#ifdef GL_EXT_gpu_shader4 | ||
if (smoothingEnabled) { | ||
// do not use smoothing for chroma key | ||
ivec2 size = textureSize2D(tex0, 0); | ||
int tx = int((vertTexCoords.x / vertTexCoords.z) * size.x) % size.x; | ||
int ty = int((vertTexCoords.y / vertTexCoords.z) * size.y) % size.y; | ||
vec4 texel = texelFetch(tex0, ivec2(tx, ty), 0); | ||
vec4 texel = texelFetch2D(tex0, ivec2(tx, ty), 0); | ||
if (texel.a == 0.0) { | ||
discard; | ||
} | ||
} | ||
#endif | ||
|
||
vec4 texColor = texture(tex0, vertTexCoords.xy / vertTexCoords.z); | ||
vec4 texColor = texture2D(tex0, vertTexCoords.xy / vertTexCoords.z); | ||
if (texColor.a == 0.0) { | ||
discard; | ||
} | ||
|
||
fragColor = vec4(fragColor.rgb * texColor.rgb, texColor.a); | ||
gl_FragColor = vec4(gl_FragColor.rgb * texColor.rgb, texColor.a); | ||
} | ||
} |
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