summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/engine')
-rw-r--r--src/datavisualization/engine/shaders/shadow.frag22
-rw-r--r--src/datavisualization/engine/shaders/shadowNoTex.frag39
-rw-r--r--src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag21
-rw-r--r--src/datavisualization/engine/shaders/surfaceShadowFlat.frag3
-rw-r--r--src/datavisualization/engine/shaders/surfaceShadowNoTex.frag3
5 files changed, 13 insertions, 75 deletions
diff --git a/src/datavisualization/engine/shaders/shadow.frag b/src/datavisualization/engine/shaders/shadow.frag
index 6d212c08..e2286dc5 100644
--- a/src/datavisualization/engine/shaders/shadow.frag
+++ b/src/datavisualization/engine/shaders/shadow.frag
@@ -31,12 +31,6 @@ 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 = lightColor * ambientStrength * materialDiffuseColor;
@@ -55,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;
@@ -66,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 12e86cb3..d54efea9 100644
--- a/src/datavisualization/engine/shaders/shadowNoTex.frag
+++ b/src/datavisualization/engine/shaders/shadowNoTex.frag
@@ -30,29 +30,6 @@ 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 = lightColor * ambientStrength * materialDiffuseColor;
@@ -71,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;
@@ -82,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 5da1afc1..e986a52a 100644
--- a/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
+++ b/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
@@ -33,12 +33,6 @@ 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;
@@ -58,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;
@@ -69,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/surfaceShadowFlat.frag b/src/datavisualization/engine/shaders/surfaceShadowFlat.frag
index b2f2af74..9b9305ab 100644
--- a/src/datavisualization/engine/shaders/surfaceShadowFlat.frag
+++ b/src/datavisualization/engine/shaders/surfaceShadowFlat.frag
@@ -63,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 004208bf..3427fbae 100644
--- a/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag
+++ b/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag
@@ -61,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);
}