summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/engine/shaders')
-rw-r--r--src/datavisualization/engine/shaders/colorOnY.frag5
-rw-r--r--src/datavisualization/engine/shaders/colorOnY_ES2.frag5
-rw-r--r--src/datavisualization/engine/shaders/default.frag5
-rw-r--r--src/datavisualization/engine/shaders/default_ES2.frag5
-rw-r--r--src/datavisualization/engine/shaders/shadow.frag27
-rw-r--r--src/datavisualization/engine/shaders/shadowNoTex.frag44
-rw-r--r--src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag26
-rw-r--r--src/datavisualization/engine/shaders/surface.frag5
-rw-r--r--src/datavisualization/engine/shaders/surfaceFlat.frag5
-rw-r--r--src/datavisualization/engine/shaders/surfaceShadowFlat.frag8
-rw-r--r--src/datavisualization/engine/shaders/surfaceShadowNoTex.frag8
-rw-r--r--src/datavisualization/engine/shaders/surface_ES2.frag5
12 files changed, 49 insertions, 99 deletions
diff --git a/src/datavisualization/engine/shaders/colorOnY.frag b/src/datavisualization/engine/shaders/colorOnY.frag
index caea959b..8c610cd7 100644
--- a/src/datavisualization/engine/shaders/colorOnY.frag
+++ b/src/datavisualization/engine/shaders/colorOnY.frag
@@ -6,6 +6,7 @@ uniform highp float ambientStrength;
uniform sampler2D textureSampler;
uniform highp float gradMin;
uniform highp float gradHeight;
+uniform highp vec3 lightColor;
varying highp vec3 position_wrld;
varying highp vec3 normal_cmr;
@@ -16,8 +17,8 @@ varying highp vec2 coords_mdl;
void main() {
highp vec2 gradientUV = vec2(0.0, gradMin + ((coords_mdl.y + 1.0) * gradHeight));
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
highp vec3 n = normalize(normal_cmr);
diff --git a/src/datavisualization/engine/shaders/colorOnY_ES2.frag b/src/datavisualization/engine/shaders/colorOnY_ES2.frag
index bb6e28c7..5b553562 100644
--- a/src/datavisualization/engine/shaders/colorOnY_ES2.frag
+++ b/src/datavisualization/engine/shaders/colorOnY_ES2.frag
@@ -4,6 +4,7 @@ uniform highp float ambientStrength;
uniform sampler2D textureSampler;
uniform highp float gradMin;
uniform highp float gradHeight;
+uniform highp vec3 lightColor;
varying highp vec3 position_wrld;
varying highp vec3 normal_cmr;
@@ -14,8 +15,8 @@ varying highp vec2 coords_mdl;
void main() {
highp vec2 gradientUV = vec2(0.0, gradMin + ((coords_mdl.y + 1.0) * gradHeight));
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
highp vec3 n = normalize(normal_cmr);
diff --git a/src/datavisualization/engine/shaders/default.frag b/src/datavisualization/engine/shaders/default.frag
index fba1ce4a..ca6fefb9 100644
--- a/src/datavisualization/engine/shaders/default.frag
+++ b/src/datavisualization/engine/shaders/default.frag
@@ -11,11 +11,12 @@ uniform highp vec3 lightPosition_wrld;
uniform highp vec3 color_mdl;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec3 materialDiffuseColor = color_mdl.rgb;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
diff --git a/src/datavisualization/engine/shaders/default_ES2.frag b/src/datavisualization/engine/shaders/default_ES2.frag
index 7d6214b2..bc5c18b6 100644
--- a/src/datavisualization/engine/shaders/default_ES2.frag
+++ b/src/datavisualization/engine/shaders/default_ES2.frag
@@ -9,11 +9,12 @@ uniform highp vec3 lightPosition_wrld;
uniform highp vec3 color_mdl;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec3 materialDiffuseColor = color_mdl.rgb;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
diff --git a/src/datavisualization/engine/shaders/shadow.frag b/src/datavisualization/engine/shaders/shadow.frag
index 5309b5bb..e2286dc5 100644
--- a/src/datavisualization/engine/shaders/shadow.frag
+++ b/src/datavisualization/engine/shaders/shadow.frag
@@ -5,6 +5,7 @@ uniform highp float ambientStrength;
uniform highp float shadowQuality;
uniform highp sampler2D textureSampler;
uniform highp sampler2DShadow shadowMap;
+uniform highp vec3 lightColor;
varying highp vec4 shadowCoord;
varying highp vec2 UV;
@@ -30,16 +31,10 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
vec2(0.19984126, 0.78641367),
vec2(0.14383161, -0.14100790));
-/*float random(vec3 seed, int i) {
- vec4 seed4 = vec4(seed, i);
- float dot_product = dot(seed4, vec4(12.9898, 78.233, 45.164, 94.673));
- return fract(sin(dot_product) * 43758.5453);
-}*/
-
void main() {
highp vec3 materialDiffuseColor = texture2D(textureSampler, UV).rgb;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(0.2, 0.2, 0.2);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor * 0.2;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
@@ -54,10 +49,7 @@ void main() {
vec4 shadCoords = shadowCoord;
shadCoords.z -= bias;
- // adjust shadow strength by increasing the multiplier and lowering the addition (their sum must be 1)
- // direct method; needs large shadow texture to look good
- //highp float visibility = 0.75 * shadow2DProj(shadowMap, shadCoords).r + 0.25;
- // poisson disk sampling; smoothes edges
+
highp float visibility = 0.6;
for (int i = 0; i < 15; i++) {
vec4 shadCoordsPD = shadCoords;
@@ -65,18 +57,11 @@ void main() {
shadCoordsPD.y += sin(poissonDisk[i].y) / shadowQuality;
visibility += 0.025 * shadow2DProj(shadowMap, shadCoordsPD).r;
}
- // stratified poisson; produces noise but hides pixel edges well
- /*for (int i = 0; i < 15; i++) {
- vec4 shadCoordsPD = shadCoords;
- int index = int(16.0 * random(gl_FragCoord.xyy, i));
- shadCoordsPD.xy += poissonDisk[index] / 150.0;
- visibility += 0.05 * shadow2DProj(shadowMap, shadCoordsPD).r;
- }
- */
gl_FragColor.rgb =
- visibility * (materialAmbientColor +
+ (materialAmbientColor +
materialDiffuseColor * lightStrength * cosTheta +
materialSpecularColor * lightStrength * pow(cosAlpha, 10));
gl_FragColor.a = texture2D(textureSampler, UV).a;
+ gl_FragColor.rgb = visibility * clamp(gl_FragColor.rgb, 0.0, 1.0);
}
diff --git a/src/datavisualization/engine/shaders/shadowNoTex.frag b/src/datavisualization/engine/shaders/shadowNoTex.frag
index 0252ba49..d54efea9 100644
--- a/src/datavisualization/engine/shaders/shadowNoTex.frag
+++ b/src/datavisualization/engine/shaders/shadowNoTex.frag
@@ -5,6 +5,7 @@ uniform highp float ambientStrength;
uniform highp float shadowQuality;
uniform highp vec3 color_mdl;
uniform highp sampler2DShadow shadowMap;
+uniform highp vec3 lightColor;
varying highp vec4 shadowCoord;
varying highp vec3 position_wrld;
@@ -29,33 +30,10 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
vec2(0.19984126, 0.78641367),
vec2(0.14383161, -0.14100790));
-/*highp vec2 poissonDisk[16] = vec2[16](vec2(-0.25, -0.25),
- vec2(0.25, -0.25),
- vec2(-0.25, 0.25),
- vec2(0.25, 0.25),
- vec2(-0.5, -0.5),
- vec2(0.5, -0.5),
- vec2(-0.5, 0.5),
- vec2(0.5, 0.5),
- vec2(-0.75, -0.75),
- vec2(0.75, -0.75),
- vec2(-0.75, 0.75),
- vec2(0.75, 0.75),
- vec2(-1.0, -1.0),
- vec2(1.0, -1.0),
- vec2(-1.0, 1.0),
- vec2(1.0, 1.0));*/
-
-/*float random(vec3 seed, int i) {
- vec4 seed4 = vec4(seed, i);
- float dot_product = dot(seed4, vec4(12.9898, 78.233, 45.164, 94.673));
- return fract(sin(dot_product) * 43758.5453);
-}*/
-
void main() {
highp vec3 materialDiffuseColor = color_mdl.rgb;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
@@ -70,10 +48,7 @@ void main() {
vec4 shadCoords = shadowCoord;
shadCoords.z -= bias;
- // adjust shadow strength by increasing the multiplier and lowering the addition (their sum must be 1)
- // direct method; needs large shadow texture to look good
- //highp float visibility = 0.75 * shadow2DProj(shadowMap, shadCoords).r + 0.25;
- // poisson disk sampling; smoothes edges
+
highp float visibility = 0.6;
for (int i = 0; i < 15; i++) {
vec4 shadCoordsPD = shadCoords;
@@ -81,18 +56,11 @@ void main() {
shadCoordsPD.y += sin(poissonDisk[i].y) / shadowQuality;
visibility += 0.025 * shadow2DProj(shadowMap, shadCoordsPD).r;
}
- // stratified poisson; produces noise but hides pixel edges well
- /*for (int i = 0; i < 15; i++) {
- vec4 shadCoordsPD = shadCoords;
- int index = int(16.0 * random(gl_FragCoord.xyy, i));
- shadCoordsPD.xy += poissonDisk[index] / 150.0;
- visibility += 0.05 * shadow2DProj(shadowMap, shadCoordsPD).r;
- }
- */
gl_FragColor.rgb =
- visibility * (materialAmbientColor +
+ (materialAmbientColor +
materialDiffuseColor * lightStrength * cosTheta +
materialSpecularColor * lightStrength * pow(cosAlpha, 10));
gl_FragColor.a = 1.0;
+ gl_FragColor.rgb = visibility * clamp(gl_FragColor.rgb, 0.0, 1.0);
}
diff --git a/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag b/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
index 9882cd92..e986a52a 100644
--- a/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
+++ b/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
@@ -7,6 +7,7 @@ uniform highp sampler2DShadow shadowMap;
uniform sampler2D textureSampler;
uniform highp float gradMin;
uniform highp float gradHeight;
+uniform highp vec3 lightColor;
varying highp vec4 shadowCoord;
varying highp vec3 position_wrld;
@@ -32,17 +33,11 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
vec2(0.19984126, 0.78641367),
vec2(0.14383161, -0.14100790));
-/*float random(vec3 seed, int i) {
- vec4 seed4 = vec4(seed, i);
- float dot_product = dot(seed4, vec4(12.9898, 78.233, 45.164, 94.673));
- return fract(sin(dot_product) * 43758.5453);
-}*/
-
void main() {
highp vec2 gradientUV = vec2(0.0, gradMin + ((coords_mdl.y + 1.0) * gradHeight));
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
@@ -57,10 +52,7 @@ void main() {
vec4 shadCoords = shadowCoord;
shadCoords.z -= bias;
- // adjust shadow strength by increasing the multiplier and lowering the addition (their sum must be 1)
- // direct method; needs large shadow texture to look good
- //highp float visibility = 0.75 * shadow2DProj(shadowMap, shadCoords).r + 0.25;
- // poisson disk sampling; smoothes edges
+
highp float visibility = 0.6;
for (int i = 0; i < 15; i++) {
vec4 shadCoordsPD = shadCoords;
@@ -68,17 +60,11 @@ void main() {
shadCoordsPD.y += sin(poissonDisk[i].y) / shadowQuality;
visibility += 0.025 * shadow2DProj(shadowMap, shadCoordsPD).r;
}
- /*for (int i = 0; i < 15; i++) {
- vec4 shadCoordsPD = shadCoords;
- int index = int(16.0 * random(gl_FragCoord.xyy, i));
- shadCoordsPD.xy += poissonDisk[index] / 150.0;
- visibility += 0.05 * shadow2DProj(shadowMap, shadCoordsPD).r;
- }*/
gl_FragColor.rgb =
- visibility * (materialAmbientColor +
+ (materialAmbientColor +
materialDiffuseColor * lightStrength * cosTheta +
materialSpecularColor * lightStrength * pow(cosAlpha, 10));
- gl_FragColor.rgb = clamp(gl_FragColor.rgb, 0.0, 1.0);
gl_FragColor.a = 1.0;
+ gl_FragColor.rgb = visibility * clamp(gl_FragColor.rgb, 0.0, 1.0);
}
diff --git a/src/datavisualization/engine/shaders/surface.frag b/src/datavisualization/engine/shaders/surface.frag
index 576cc51f..b5205d2d 100644
--- a/src/datavisualization/engine/shaders/surface.frag
+++ b/src/datavisualization/engine/shaders/surface.frag
@@ -10,12 +10,13 @@ uniform sampler2D textureSampler;
uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
diff --git a/src/datavisualization/engine/shaders/surfaceFlat.frag b/src/datavisualization/engine/shaders/surfaceFlat.frag
index fd42a289..7eaa917f 100644
--- a/src/datavisualization/engine/shaders/surfaceFlat.frag
+++ b/src/datavisualization/engine/shaders/surfaceFlat.frag
@@ -12,12 +12,13 @@ uniform sampler2D textureSampler;
uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
diff --git a/src/datavisualization/engine/shaders/surfaceShadowFlat.frag b/src/datavisualization/engine/shaders/surfaceShadowFlat.frag
index 6341136e..9b9305ab 100644
--- a/src/datavisualization/engine/shaders/surfaceShadowFlat.frag
+++ b/src/datavisualization/engine/shaders/surfaceShadowFlat.frag
@@ -15,6 +15,7 @@ uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
uniform highp float shadowQuality;
+uniform highp vec3 lightColor;
highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
vec2(0.94558609, -0.76890725),
@@ -36,8 +37,8 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
@@ -62,9 +63,10 @@ void main() {
}
gl_FragColor.rgb =
- visibility * (materialAmbientColor +
+ (materialAmbientColor +
materialDiffuseColor * lightStrength * cosTheta +
materialSpecularColor * lightStrength * pow(cosAlpha, 10));
gl_FragColor.a = 1.0;
+ gl_FragColor.rgb = visibility * clamp(gl_FragColor.rgb, 0.0, 1.0);
}
diff --git a/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag b/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag
index 755be3f1..3427fbae 100644
--- a/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag
+++ b/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag
@@ -13,6 +13,7 @@ uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
uniform highp float shadowQuality;
+uniform highp vec3 lightColor;
highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
vec2(0.94558609, -0.76890725),
@@ -34,8 +35,8 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
@@ -60,9 +61,10 @@ void main() {
}
gl_FragColor.rgb =
- visibility * (materialAmbientColor +
+ (materialAmbientColor +
materialDiffuseColor * lightStrength * cosTheta +
materialSpecularColor * lightStrength * pow(cosAlpha, 10));
gl_FragColor.a = 1.0;
+ gl_FragColor.rgb = visibility * clamp(gl_FragColor.rgb, 0.0, 1.0);
}
diff --git a/src/datavisualization/engine/shaders/surface_ES2.frag b/src/datavisualization/engine/shaders/surface_ES2.frag
index c7e75594..0e17cacd 100644
--- a/src/datavisualization/engine/shaders/surface_ES2.frag
+++ b/src/datavisualization/engine/shaders/surface_ES2.frag
@@ -9,12 +9,13 @@ uniform sampler2D textureSampler;
uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);