diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-04-15 10:32:03 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-04-15 10:40:38 +0300 |
commit | a30c0c304e55ffe30545ab0838e4dbe11a99b8da (patch) | |
tree | ce6ccc0e4de8e350aebec466ff0a70c0fd7710bc /src/datavisualization/engine/shaders/texture_ES2.frag | |
parent | 79646ac9664745701667104c19bbae8cba8fd2e3 (diff) |
Add custom item support, part 1
Task-number: QTRD-2866
+ Added API for adding and removing custom items
+ Added custom data and custom render items
+ Added shaders for textured objects
+ Added custom item rendering draft to scatter
+ Fixed some shaders
- to be continued in part 2
Change-Id: I9735fd02fc9e86ae486cca4c06f6d7f2a4b0b7da
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src/datavisualization/engine/shaders/texture_ES2.frag')
-rw-r--r-- | src/datavisualization/engine/shaders/texture_ES2.frag | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/datavisualization/engine/shaders/texture_ES2.frag b/src/datavisualization/engine/shaders/texture_ES2.frag new file mode 100644 index 00000000..e749d763 --- /dev/null +++ b/src/datavisualization/engine/shaders/texture_ES2.frag @@ -0,0 +1,40 @@ +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 sampler2D textureSampler; +uniform highp float lightStrength; +uniform highp float ambientStrength; +uniform highp vec3 lightColor; + +void main() { + highp vec3 materialDiffuseColor = texture2D(textureSampler, UV).rgb; + highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor; + highp vec3 materialSpecularColor = lightColor; + + 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; + else 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; + else if (cosAlpha > 1.0) cosAlpha = 1.0; + + gl_FragColor.rgb = + materialAmbientColor + + materialDiffuseColor * lightStrength * (cosTheta * cosTheta) / distance + + materialSpecularColor * lightStrength * (cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha * cosAlpha) / distance; + gl_FragColor.a = texture2D(textureSampler, UV).a; + gl_FragColor.rgb = clamp(gl_FragColor.rgb, 0.0, 1.0); +} + |