aboutsummaryrefslogtreecommitdiff
path: root/src/library_gl.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-06-14 14:58:02 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-06-14 14:58:02 -0700
commit4729a321a9be339e33318b0852b1bab7592b1e48 (patch)
tree88d09b55b4a2d12ca84c6523b69f2668b350008d /src/library_gl.js
parent1bdb3a5e9f3521dfd856a3a4363557eab4968bd8 (diff)
some fog work
Diffstat (limited to 'src/library_gl.js')
-rw-r--r--src/library_gl.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 25309616..9dd29bb7 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1054,9 +1054,10 @@ var LibraryGL = {
source = 'attribute vec3 a_normal; \n' +
source.replace(/gl_Normal/g, 'a_normal');
}
+ // fog
if (source.indexOf('gl_FogFragCoord') >= 0) {
- source = 'varying float v_fogCoord; \n' +
- source.replace(/gl_FogFragCoord/g, 'v_fogCoord');
+ source = 'varying float v_fogFragCoord; \n' +
+ source.replace(/gl_FogFragCoord/g, 'v_fogFragCoord');
}
} else { // Fragment shader
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
@@ -1069,7 +1070,22 @@ var LibraryGL = {
if (source.indexOf('gl_Color') >= 0) {
source = 'varying vec4 v_color; \n' + source.replace(/gl_Color/g, 'v_color');
}
- source = source.replace(/gl_Fog.color/g, 'vec4(0.0)'); // XXX TODO
+ if (source.indexOf('gl_Fog.color') >= 0) {
+ source = 'uniform vec4 a_fogColor; \n' +
+ source.replace(/gl_Fog.color/g, 'a_fogColor');
+ }
+ if (source.indexOf('gl_Fog.end') >= 0) {
+ source = 'uniform float a_fogEnd; \n' +
+ source.replace(/gl_Fog.end/g, 'a_fogEnd');
+ }
+ if (source.indexOf('gl_Fog.scale') >= 0) {
+ source = 'uniform float a_fogScale; \n' +
+ source.replace(/gl_Fog.scale/g, 'a_fogScale');
+ }
+ if (source.indexOf('gl_FogFragCoord') >= 0) {
+ source = 'varying float v_fogFragCoord; \n' +
+ source.replace(/gl_FogFragCoord/g, 'v_fogFragCoord');
+ }
source = 'precision mediump float;\n' + source;
}
#if GL_DEBUG