-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reverted expirimental shaders, left them in incase you wanted to test
- Loading branch information
1 parent
a9f2319
commit dc1c8d9
Showing
5 changed files
with
95 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#version 120 | ||
|
||
uniform sampler2D Texture; | ||
uniform sampler2D LightMap; | ||
varying vec2 p_TexCoord; | ||
varying vec4 p_Color; | ||
varying vec4 p_LightCoord; | ||
uniform vec4 u_LightCoord; | ||
|
||
void main() { | ||
float scale = 256; | ||
float bias = 0.5; | ||
|
||
// required state: | ||
// LightMap GL_TEXTURE_MIN_FILTER GL_LINEAR | ||
// GL_TEXTURE_MAG_FILTER GL_LINEAR | ||
// GL_TEXTURE_WRAP_S GL_CLAMP_TO_EDGE | ||
// GL_TEXTURE_WRAP_T GL_CLAMP_TO_EDGE | ||
|
||
// exploit separability of *-linear interpolation: | ||
|
||
// hardware does the bilinear interpolation for the zw channels | ||
vec4 texel00 = texture2D(LightMap, (floor(p_LightCoord.xy + vec2(0, 0)) * 16 + p_LightCoord.zw) / scale); | ||
vec4 texel01 = texture2D(LightMap, (floor(p_LightCoord.xy + vec2(0, 1)) * 16 + p_LightCoord.zw) / scale); | ||
vec4 texel10 = texture2D(LightMap, (floor(p_LightCoord.xy + vec2(1, 0)) * 16 + p_LightCoord.zw) / scale); | ||
vec4 texel11 = texture2D(LightMap, (floor(p_LightCoord.xy + vec2(1, 1)) * 16 + p_LightCoord.zw) / scale); | ||
|
||
vec2 factors = fract(p_LightCoord.xy); | ||
|
||
// do the y interpolation steps ourselves | ||
vec4 y0 = mix(texel00, texel01, factors.y); | ||
vec4 y1 = mix(texel10, texel11, factors.y); | ||
|
||
// finally do the x step between the y results | ||
vec4 lightColor = mix(y0, y1, factors.x); | ||
|
||
gl_FragColor = texture2D(Texture, p_TexCoord) * p_Color * lightColor; | ||
} |
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,21 @@ | ||
#version 120 | ||
|
||
uniform sampler2D Texture; | ||
uniform sampler2D LightMap; | ||
uniform vec4 u_LightCoord; | ||
attribute vec2 TexCoord; | ||
varying vec2 p_TexCoord; | ||
attribute vec4 LightCoord; | ||
varying vec4 p_LightCoord; | ||
varying vec4 p_Color; | ||
|
||
void main() { | ||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
p_TexCoord = TexCoord; | ||
p_Color = gl_Color; | ||
if (u_LightCoord == vec4(0.0, 0.0, 0.0, 0.0)) { | ||
p_LightCoord = LightCoord; | ||
} else { | ||
p_LightCoord = u_LightCoord; | ||
} | ||
} |