diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-05-08 12:46:49 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-05-08 13:30:48 +0300 |
commit | ee7f5d387934c46442ece1ea17566305ada94cef (patch) | |
tree | 90dd4d95ae2f83f66e2ee42608122a393f5be46c /src/datavis3d/engine/shaders | |
parent | 161232582e7f7e7e6e991def2fe87d78e668d08f (diff) |
Directory structure reorganized
Unnecessary subdirectory levels deleted from examples and src
Change-Id: I88892b4fc92784e706be2264eeb7d6208250a50f
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src/datavis3d/engine/shaders')
-rw-r--r-- | src/datavis3d/engine/shaders/fragmentDepthTest | 7 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/fragmentShader | 38 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/fragmentShaderAmbient | 28 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/fragmentShaderColorOnY | 30 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/fragmentShaderDepth | 3 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/fragmentShaderLabel | 6 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/fragmentShaderSelection | 7 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/fragmentShaderTexture | 32 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/fragmentShadow | 70 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/vertexDepthTest | 9 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/vertexShader | 25 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/vertexShaderDepth | 8 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/vertexShaderLabel | 8 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/vertexShaderSelection | 5 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/vertexShaderTexture | 23 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/vertexShadow | 34 |
16 files changed, 0 insertions, 333 deletions
diff --git a/src/datavis3d/engine/shaders/fragmentDepthTest b/src/datavis3d/engine/shaders/fragmentDepthTest deleted file mode 100644 index d6c502e1..00000000 --- a/src/datavis3d/engine/shaders/fragmentDepthTest +++ /dev/null @@ -1,7 +0,0 @@ -uniform sampler2D textureSampler; - -varying highp vec2 UV; - -void main() { - gl_FragColor = texture2D(textureSampler, UV); -} diff --git a/src/datavis3d/engine/shaders/fragmentShader b/src/datavis3d/engine/shaders/fragmentShader deleted file mode 100644 index 45d8642f..00000000 --- a/src/datavis3d/engine/shaders/fragmentShader +++ /dev/null @@ -1,38 +0,0 @@ -varying highp vec2 UV; -varying highp vec2 coords_mdl; -varying highp vec3 position_wrld; -varying highp vec3 normal_cmr; -varying highp vec3 eyeDirection_cmr; -varying highp vec3 lightDirection_cmr; - -uniform highp vec3 lightPosition_wrld; -uniform highp vec3 color_mdl; -uniform highp float lightStrength; -uniform highp float ambientStrength; - -void main() { - highp vec3 materialDiffuseColor = color_mdl; - highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor; - highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0); - - highp float distance = length(lightPosition_wrld - position_wrld); - - highp vec3 n = normalize(normal_cmr); - highp vec3 l = normalize(lightDirection_cmr); - highp float cosTheta = dot(n, l); - if (cosTheta < 0.0) { cosTheta = 0.0; } - if (cosTheta > 1.0) { cosTheta = 1.0; } - - highp vec3 E = normalize(eyeDirection_cmr); - highp vec3 R = reflect(-l, n); - highp float cosAlpha = dot(E, R); - if (cosAlpha < 0.0) { cosAlpha = 0.0; } - if (cosAlpha > 1.0) { cosAlpha = 1.0; } - - gl_FragColor.rgb = //color_mdl + color_mdl * vec3(cosTheta * cosTheta) / (distance * distance) + vec3(cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha) / (distance * distance); - materialAmbientColor + - materialDiffuseColor * lightStrength * (cosTheta * cosTheta) / distance + - materialSpecularColor * lightStrength * (cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha) / distance;//(distance * distance); - gl_FragColor.a = 1.0; -} - diff --git a/src/datavis3d/engine/shaders/fragmentShaderAmbient b/src/datavis3d/engine/shaders/fragmentShaderAmbient deleted file mode 100644 index ccaa07e4..00000000 --- a/src/datavis3d/engine/shaders/fragmentShaderAmbient +++ /dev/null @@ -1,28 +0,0 @@ -varying highp vec3 position_wrld; -varying highp vec3 normal_cmr; -varying highp vec3 eyeDirection_cmr; -varying highp vec3 lightDirection_cmr; -uniform highp vec3 lightPosition_wrld; -uniform highp vec3 color_mdl; -void main() { - highp vec3 lightColor = vec3(1.0, 1.0, 1.0); - highp float lightPower = 10.0; - highp vec3 materialAmbientColor = vec3(0.5, 0.5, 0.5) * color_mdl; - highp vec3 materialSpecularColor = vec3(0.3, 0.3, 0.3) * color_mdl; - highp float distance = length(lightPosition_wrld - position_wrld); - highp vec3 n = normalize(normal_cmr); - highp vec3 l = normalize(lightDirection_cmr); - highp float cosTheta = dot(n, l); - if (cosTheta < 0.0) { cosTheta = 0.0; } - if (cosTheta > 1.0) { cosTheta = 1.0; } - highp vec3 E = normalize(eyeDirection_cmr); - highp vec3 R = reflect(-l, n); - highp float cosAlpha = dot(E, R); - if (cosAlpha < 0.0) { cosAlpha = 0.0; } - if (cosAlpha > 1.0) { cosAlpha = 1.0; } - gl_FragColor.rgb = - materialAmbientColor + - materialSpecularColor * lightColor * lightPower * (cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha) / (distance * distance); - gl_FragColor.a = 1.0; -} - diff --git a/src/datavis3d/engine/shaders/fragmentShaderColorOnY b/src/datavis3d/engine/shaders/fragmentShaderColorOnY deleted file mode 100644 index a7a30155..00000000 --- a/src/datavis3d/engine/shaders/fragmentShaderColorOnY +++ /dev/null @@ -1,30 +0,0 @@ -varying highp vec3 position_wrld; -varying highp vec3 normal_cmr; -varying highp vec3 eyeDirection_cmr; -varying highp vec3 lightDirection_cmr; -varying highp vec2 coords_mdl; -uniform highp vec3 lightPosition_wrld; -uniform highp vec3 color_mdl; -uniform highp float lightStrength; -uniform highp float ambientStrength; -void main() { - highp vec3 materialDiffuseColor = vec3(coords_mdl.y * color_mdl.x, coords_mdl.y * color_mdl.y, coords_mdl.y * color_mdl.z); - highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor; - highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0); - highp float distance = length(lightPosition_wrld - position_wrld); - highp vec3 n = normalize(normal_cmr); - highp vec3 l = normalize(lightDirection_cmr); - highp float cosTheta = dot(n, l); - if (cosTheta < 0.0) { cosTheta = 0.0; } - if (cosTheta > 1.0) { cosTheta = 1.0; } - highp vec3 E = normalize(eyeDirection_cmr); - highp vec3 R = reflect(-l, n); - highp float cosAlpha = dot(E, R); - if (cosAlpha < 0.0) { cosAlpha = 0.0; } - if (cosAlpha > 1.0) { cosAlpha = 1.0; } - gl_FragColor.rgb = //color_mdl + color_mdl * vec3(cosTheta * cosTheta) / (distance * distance) + vec3(cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha) / (distance * distance); - materialAmbientColor + - materialDiffuseColor * lightStrength * (cosTheta * cosTheta) / (distance * distance) + - materialSpecularColor * lightStrength * (cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha) / (distance * distance); -} - diff --git a/src/datavis3d/engine/shaders/fragmentShaderDepth b/src/datavis3d/engine/shaders/fragmentShaderDepth deleted file mode 100644 index 5cfd4b10..00000000 --- a/src/datavis3d/engine/shaders/fragmentShaderDepth +++ /dev/null @@ -1,3 +0,0 @@ -void main() { - gl_FragDepth = gl_FragCoord.z; -} diff --git a/src/datavis3d/engine/shaders/fragmentShaderLabel b/src/datavis3d/engine/shaders/fragmentShaderLabel deleted file mode 100644 index ed3f91b1..00000000 --- a/src/datavis3d/engine/shaders/fragmentShaderLabel +++ /dev/null @@ -1,6 +0,0 @@ -varying highp vec2 UV; -uniform sampler2D textureSampler; -void main() { - gl_FragColor = texture2D(textureSampler, UV); -} - diff --git a/src/datavis3d/engine/shaders/fragmentShaderSelection b/src/datavis3d/engine/shaders/fragmentShaderSelection deleted file mode 100644 index 66370224..00000000 --- a/src/datavis3d/engine/shaders/fragmentShaderSelection +++ /dev/null @@ -1,7 +0,0 @@ -uniform highp vec3 color_mdl; -//uniform highp vec4 color_mdl; -void main() { - gl_FragColor.rgb = color_mdl; - //gl_FragColor = color_mdl; -} - diff --git a/src/datavis3d/engine/shaders/fragmentShaderTexture b/src/datavis3d/engine/shaders/fragmentShaderTexture deleted file mode 100644 index 95c4f1a1..00000000 --- a/src/datavis3d/engine/shaders/fragmentShaderTexture +++ /dev/null @@ -1,32 +0,0 @@ -varying highp vec2 UV; -varying highp vec3 position_wrld; -varying highp vec3 normal_cmr; -varying highp vec3 eyeDirection_cmr; -varying highp vec3 lightDirection_cmr; -uniform highp vec3 lightPosition_wrld; -uniform highp vec3 color_mdl; -uniform highp float lightStrength; -uniform highp float ambientStrength; -uniform sampler2D textureSampler; -void main() { - highp vec3 materialDiffuseColor = texture2D(textureSampler, UV).rgb; - highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor; - highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0); - highp float distance = length(lightPosition_wrld - position_wrld); - highp vec3 n = normalize(normal_cmr); - highp vec3 l = normalize(lightDirection_cmr); - highp float cosTheta = dot(n, l); - if (cosTheta < 0.0) { cosTheta = 0.0; } - if (cosTheta > 1.0) { cosTheta = 1.0; } - highp vec3 E = normalize(eyeDirection_cmr); - highp vec3 R = reflect(-l, n); - highp float cosAlpha = dot(E, R); - if (cosAlpha < 0.0) { cosAlpha = 0.0; } - if (cosAlpha > 1.0) { cosAlpha = 1.0; } - gl_FragColor.rgb = //color_mdl + color_mdl * vec3(cosTheta * cosTheta) / (distance * distance) + vec3(cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha) / (distance * distance); - materialAmbientColor + - materialDiffuseColor * lightStrength * (cosTheta * cosTheta) / distance + - materialSpecularColor * lightStrength * (cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha) / distance;//(distance * distance); - gl_FragColor.a = 1.0; -} - diff --git a/src/datavis3d/engine/shaders/fragmentShadow b/src/datavis3d/engine/shaders/fragmentShadow deleted file mode 100644 index 2c3c2ded..00000000 --- a/src/datavis3d/engine/shaders/fragmentShadow +++ /dev/null @@ -1,70 +0,0 @@ -varying highp vec4 shadowCoord; -varying highp vec2 UV; -varying highp vec3 position_wrld; -varying highp vec3 normal_cmr; -varying highp vec3 eyeDirection_cmr; -varying highp vec3 lightDirection_cmr; - -uniform highp float lightStrength; -uniform highp float ambientStrength; -uniform sampler2D textureSampler; -//uniform sampler2DShadow shadowMap; // use with version 2 -uniform sampler2D shadowMap; // use with version 1 - -// Version 1: Use this to see the shadow map - -void main() { - float shadowFactor = 1.0; // default to '1' meaning "no shadow" - float epsilon = 0.1; // increase value to remove little artifacts - vec4 shadCoordsPD = shadowCoord / shadowCoord.w; - if (shadowCoord.w <= 0.0) { // ignore negative projection - shadowFactor = 1.0; - } else if (shadCoordsPD.x < 0.0 || shadCoordsPD.y < 0.0) { // outside light frustum, ignore - shadowFactor = 1.0; - } else if (shadCoordsPD.x >= 1.0 || shadCoordsPD.y >= 1.0) { // outside light frustum, ignore - shadowFactor = 1.0; - } else { - float shadow = texture2D(shadowMap, shadCoordsPD.xy).x; - if (shadow + epsilon < shadCoordsPD.z) { - shadowFactor = 0.0; - } - } - // shadow is dark gray, other parts bright yellow - gl_FragColor = vec4(0.8, 0.8, 0.0, 1.0) * shadowFactor + vec4(0.2, 0.2, 0.2, 1.0); -} - -// Version 2: Use this normally -/* -void main() { - highp vec3 materialDiffuseColor = vec3(0.8, 0.8, 0.0);//texture2D(textureSampler, UV).rgb; - highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor; - highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0); - - highp vec3 n = normalize(normal_cmr); - highp vec3 l = normalize(lightDirection_cmr); - highp float cosTheta = dot(n, l); - if (cosTheta < 0.0) { cosTheta = 0.0; } - if (cosTheta > 1.0) { cosTheta = 1.0; } - - highp vec3 E = normalize(eyeDirection_cmr); - highp vec3 R = reflect(-l, n); - highp float cosAlpha = dot(E, R); - if (cosAlpha < 0.0) { cosAlpha = 0.0; } - if (cosAlpha > 1.0) { cosAlpha = 1.0; } - - highp float visibility = 1.0; - highp float bias = 0.005; - - //highp float bias = 0.005 * tan(acos(cosTheta)); - //if (bias < 0.0) { bias = 0.0; } - //if (bias > 0.01) { bias = 0.01; } - - visibility -= 0.8 * (1.0 - shadow2D(shadowMap, vec3(shadowCoord.xy, (shadowCoord.z - bias) / shadowCoord.w)).r); - - gl_FragColor.rgb = - materialAmbientColor + - visibility * materialDiffuseColor * lightStrength * cosTheta + - visibility * materialSpecularColor * lightStrength * (cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha); - gl_FragColor.a = 1.0; -} -*/ diff --git a/src/datavis3d/engine/shaders/vertexDepthTest b/src/datavis3d/engine/shaders/vertexDepthTest deleted file mode 100644 index d62f1aa7..00000000 --- a/src/datavis3d/engine/shaders/vertexDepthTest +++ /dev/null @@ -1,9 +0,0 @@ -attribute highp vec3 vertexPosition_mdl; - -varying highp vec2 UV; - -void main() { - gl_Position = vec4(vertexPosition_mdl, 1.0); - UV = (vertexPosition_mdl.xy + vec2(1.0, 1.0)) / 2.0; -} - diff --git a/src/datavis3d/engine/shaders/vertexShader b/src/datavis3d/engine/shaders/vertexShader deleted file mode 100644 index de03714b..00000000 --- a/src/datavis3d/engine/shaders/vertexShader +++ /dev/null @@ -1,25 +0,0 @@ -attribute highp vec3 vertexPosition_mdl; -attribute highp vec2 vertexUV; -attribute highp vec3 vertexNormal_mdl; -uniform highp mat4 MVP; -uniform highp mat4 V; -uniform highp mat4 M; -uniform highp mat4 itM; -uniform highp vec3 lightPosition_wrld; -//varying highp vec2 UV; -varying highp vec3 position_wrld; -varying highp vec3 normal_cmr; -varying highp vec3 eyeDirection_cmr; -varying highp vec3 lightDirection_cmr; -varying highp vec2 coords_mdl; -void main() { - gl_Position = MVP * vec4(vertexPosition_mdl, 1.0); - coords_mdl = vertexPosition_mdl.xy; - position_wrld = (M * vec4(vertexPosition_mdl, 1.0)).xyz; - vec3 vertexPosition_cmr = (V * M * vec4(vertexPosition_mdl, 1.0)).xyz; - eyeDirection_cmr = vec3(0.0, 0.0, 0.0) - vertexPosition_cmr; - vec3 lightPosition_cmr = (V * vec4(lightPosition_wrld, 1.0)).xyz; - lightDirection_cmr = lightPosition_cmr + eyeDirection_cmr; - normal_cmr = (V * itM * vec4(vertexNormal_mdl, 0.0)).xyz; // Use modelMatrix's transposed inverse, as it's scaled - //UV = vertexUV; -} diff --git a/src/datavis3d/engine/shaders/vertexShaderDepth b/src/datavis3d/engine/shaders/vertexShaderDepth deleted file mode 100644 index 69521267..00000000 --- a/src/datavis3d/engine/shaders/vertexShaderDepth +++ /dev/null @@ -1,8 +0,0 @@ -attribute highp vec3 vertexPosition_mdl; - -uniform highp mat4 MVP; - -void main() { - gl_Position = MVP * vec4(vertexPosition_mdl, 1.0); -} - diff --git a/src/datavis3d/engine/shaders/vertexShaderLabel b/src/datavis3d/engine/shaders/vertexShaderLabel deleted file mode 100644 index 5959b47b..00000000 --- a/src/datavis3d/engine/shaders/vertexShaderLabel +++ /dev/null @@ -1,8 +0,0 @@ -attribute highp vec3 vertexPosition_mdl; -attribute highp vec2 vertexUV; -uniform highp mat4 MVP; -varying highp vec2 UV; -void main() { - gl_Position = MVP * vec4(vertexPosition_mdl, 1.0); - UV = vertexUV; -} diff --git a/src/datavis3d/engine/shaders/vertexShaderSelection b/src/datavis3d/engine/shaders/vertexShaderSelection deleted file mode 100644 index 70082663..00000000 --- a/src/datavis3d/engine/shaders/vertexShaderSelection +++ /dev/null @@ -1,5 +0,0 @@ -attribute highp vec3 vertexPosition_mdl; -uniform highp mat4 MVP; -void main() { - gl_Position = MVP * vec4(vertexPosition_mdl, 1.0); -} diff --git a/src/datavis3d/engine/shaders/vertexShaderTexture b/src/datavis3d/engine/shaders/vertexShaderTexture deleted file mode 100644 index fb23b252..00000000 --- a/src/datavis3d/engine/shaders/vertexShaderTexture +++ /dev/null @@ -1,23 +0,0 @@ -attribute highp vec3 vertexPosition_mdl; -attribute highp vec2 vertexUV; -attribute highp vec3 vertexNormal_mdl; -uniform highp mat4 MVP; -uniform highp mat4 V; -uniform highp mat4 M; -uniform highp mat4 itM; -uniform highp vec3 lightPosition_wrld; -varying highp vec2 UV; -varying highp vec3 position_wrld; -varying highp vec3 normal_cmr; -varying highp vec3 eyeDirection_cmr; -varying highp vec3 lightDirection_cmr; -void main() { - gl_Position = MVP * vec4(vertexPosition_mdl, 1.0); - position_wrld = (M * vec4(vertexPosition_mdl, 1.0)).xyz; - vec3 vertexPosition_cmr = (V * M * vec4(vertexPosition_mdl, 1.0)).xyz; - eyeDirection_cmr = vec3(0.0, 0.0, 0.0) - vertexPosition_cmr; - vec3 lightPosition_cmr = (V * vec4(lightPosition_wrld, 1.0)).xyz; - lightDirection_cmr = lightPosition_cmr + eyeDirection_cmr; - normal_cmr = (V * itM * vec4(vertexNormal_mdl, 0.0)).xyz; // Use modelMatrix's transposed inverse, as it's scaled - UV = vertexUV; -} diff --git a/src/datavis3d/engine/shaders/vertexShadow b/src/datavis3d/engine/shaders/vertexShadow deleted file mode 100644 index 24184376..00000000 --- a/src/datavis3d/engine/shaders/vertexShadow +++ /dev/null @@ -1,34 +0,0 @@ -attribute highp vec3 vertexPosition_mdl; -attribute highp vec2 vertexUV; -attribute highp vec3 vertexNormal_mdl; - -uniform highp mat4 MVP; -uniform highp mat4 V; -uniform highp mat4 M; -uniform highp mat4 itM; -uniform highp vec3 lightPosition_wrld; // this is for inverted light direction, not position (we are just reusing uniform) -uniform highp mat4 depthMVP; - -varying highp vec2 UV; -varying highp vec3 position_wrld; -varying highp vec3 normal_cmr; -varying highp vec3 eyeDirection_cmr; -varying highp vec3 lightDirection_cmr; -varying highp vec4 shadowCoord; - -const highp mat4 bias = mat4(0.5, 0.0, 0.0, 0.0, - 0.0, 0.5, 0.0, 0.0, - 0.0, 0.0, 0.5, 0.0, - 0.5, 0.5, 0.5, 1.0); - -void main() { - gl_Position = MVP * vec4(vertexPosition_mdl, 1.0); - shadowCoord = bias * depthMVP * vec4(vertexPosition_mdl, 1.0); - position_wrld = (M * vec4(vertexPosition_mdl, 1.0)).xyz; - vec3 vertexPosition_cmr = (V * M * vec4(vertexPosition_mdl, 1.0)).xyz; - eyeDirection_cmr = vec3(0.0, 0.0, 0.0) - vertexPosition_cmr; - lightDirection_cmr = (V * vec4(lightPosition_wrld, 0.0)).xyz; - normal_cmr = (V * itM * vec4(vertexNormal_mdl, 0.0)).xyz; // Use modelMatrix's transposed inverse, as it's scaled - //normal_cmr = (V * M * vec4(vertexNormal_mdl, 0.0)).xyz; // Use modelMatrix's transposed inverse, as it's scaled - UV = vertexUV; -} |