From bf3121125746f85efb287889b56b8a231a5d9185 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Sat, 21 Apr 2012 17:22:36 +0000 Subject: [PATCH] Calculation of transparency in lighting shaders is determined exclusively by diffuse component. --- .../opengl/src/processing/opengl/FillShaderVertFull.glsl | 9 +++++---- .../opengl/src/processing/opengl/FillShaderVertLit.glsl | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/java/libraries/opengl/src/processing/opengl/FillShaderVertFull.glsl b/java/libraries/opengl/src/processing/opengl/FillShaderVertFull.glsl index edbcb78fb..ab78dfa28 100644 --- a/java/libraries/opengl/src/processing/opengl/FillShaderVertFull.glsl +++ b/java/libraries/opengl/src/processing/opengl/FillShaderVertFull.glsl @@ -130,11 +130,12 @@ void main() { } } - // Calculating final color as result of all lights (plus emissive term) - vertColor = vec4(totalAmbient, 1) * inAmbient + + // Calculating final color as result of all lights (plus emissive term). + // Transparency is determined exclusively by the diffuse component. + vertColor = vec4(totalAmbient, 0) * inAmbient + vec4(totalDiffuse, 1) * inColor + - vec4(totalSpecular, 1) * inSpecular + - inEmissive; + vec4(totalSpecular, 0) * inSpecular + + vec4(inEmissive.rgb, 0); // Calculating texture coordinates, with r and q set both to one vertTexcoord = texcoordMatrix * vec4(inTexcoord, 1.0, 1.0); diff --git a/java/libraries/opengl/src/processing/opengl/FillShaderVertLit.glsl b/java/libraries/opengl/src/processing/opengl/FillShaderVertLit.glsl index 7c184a807..7fefea78d 100644 --- a/java/libraries/opengl/src/processing/opengl/FillShaderVertLit.glsl +++ b/java/libraries/opengl/src/processing/opengl/FillShaderVertLit.glsl @@ -128,9 +128,10 @@ void main() { } - // Calculating final color as result of all lights (plus emissive term) - vertColor = vec4(totalAmbient, 1) * inAmbient + + // Calculating final color as result of all lights (plus emissive term). + // Transparency is determined exclusively by the diffuse component. + vertColor = vec4(totalAmbient, 0) * inAmbient + vec4(totalDiffuse, 1) * inColor + - vec4(totalSpecular, 1) * inSpecular + - inEmissive; + vec4(totalSpecular, 0) * inSpecular + + vec4(inEmissive.rgb, 0); } \ No newline at end of file