Skip to content

Commit

Permalink
Fixed extra WorldVertex shader var
Browse files Browse the repository at this point in the history
Fixed specularity
  • Loading branch information
xeolabs committed Nov 15, 2011
1 parent c60d34f commit f845aa3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/scenejs/drawList/drawList.js
Original file line number Diff line number Diff line change
Expand Up @@ -1665,11 +1665,7 @@ var SceneJS_DrawList = new (function() {
src.push(" vec4 res = fract(depth * bit_shift);");
src.push(" res -= res.xxyz * bit_mask;");
src.push(" return res;");
src.push("}");

if (clipping || fragmentHooks.worldPosClip) {
src.push("varying vec4 SCENEJS_vWorldVertex;"); // World-space vertex
}
src.push("}");

src.push("varying vec4 SCENEJS_vModelVertex;");
src.push("varying vec4 SCENEJS_vWorldVertex;");
Expand Down Expand Up @@ -2109,6 +2105,8 @@ var SceneJS_DrawList = new (function() {
src.push("uniform bool SCENEJS_uBackfaceTexturing;");
src.push("uniform bool SCENEJS_uBackfaceLighting;");

src.push("uniform bool SCENEJS_uSpecularLighting;");

/* True when rendering transparency
*/
src.push("uniform bool SCENEJS_uTransparent;");
Expand Down Expand Up @@ -2357,7 +2355,7 @@ var SceneJS_DrawList = new (function() {
src.push(" lightValue += dotN * SCENEJS_uLightColor" + i + " * attenuation;");
}
if (light.specular) {
src.push("specularValue += attenuation * specularColor * SCENEJS_uLightColor" + i +
src.push("if (SCENEJS_uSpecularLighting) specularValue += attenuation * specularColor * SCENEJS_uLightColor" + i +
" * specular * pow(max(dot(reflect(lightVec, normalVec), SCENEJS_vEyeVec),0.0), shine);");
}
//src.push("}");
Expand All @@ -2370,7 +2368,7 @@ var SceneJS_DrawList = new (function() {
src.push("lightValue += dotN * SCENEJS_uLightColor" + i + ";");
}
if (light.specular) {
src.push("specularValue += specularColor * SCENEJS_uLightColor" + i +
src.push("if (SCENEJS_uSpecularLighting) specularValue += specularColor * SCENEJS_uLightColor" + i +
" * specular * pow(max(dot(reflect(lightVec, normalVec),SCENEJS_vEyeVec),0.0), shine);");
}
// src.push("}");
Expand Down
1 change: 1 addition & 0 deletions src/scenejs/drawList/drawListRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@ var SceneJS_DrawListRenderer = function(cfg) {

program.setUniform("SCENEJS_uBackfaceTexturing", newFlags.backfaceTexturing == undefined ? true : !!newFlags.backfaceTexturing);
program.setUniform("SCENEJS_uBackfaceLighting", newFlags.backfaceLighting == undefined ? true : !!newFlags.backfaceLighting);
program.setUniform("SCENEJS_uSpecularLighting", newFlags.specular == undefined ? true : !!newFlags.specular);

// var mask = newFlags.colorMask;
//
Expand Down

0 comments on commit f845aa3

Please sign in to comment.