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/engine/shaders/fragmentShaderAmbient | |
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/engine/shaders/fragmentShaderAmbient')
-rw-r--r-- | src/engine/shaders/fragmentShaderAmbient | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/engine/shaders/fragmentShaderAmbient b/src/engine/shaders/fragmentShaderAmbient new file mode 100644 index 00000000..ccaa07e4 --- /dev/null +++ b/src/engine/shaders/fragmentShaderAmbient @@ -0,0 +1,28 @@ +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; +} + |