diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-03-07 12:28:15 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-03-07 12:28:15 +0200 |
commit | fe21dc562504ccb87f8a1b01ea96cc7865064b72 (patch) | |
tree | c4e444662a03ee0b3383eeeb09ccbdc313b4f753 /src/datavis3d/engine/shaders/vertexShader | |
parent | a1c579f4e9eb94488550b329a9e1c27a461bfd2e (diff) |
Initial version of QtDataVis3D
Includes:
- initial version of q3dbars
- an example using it
Diffstat (limited to 'src/datavis3d/engine/shaders/vertexShader')
-rw-r--r-- | src/datavis3d/engine/shaders/vertexShader | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/datavis3d/engine/shaders/vertexShader b/src/datavis3d/engine/shaders/vertexShader new file mode 100644 index 00000000..19f9d617 --- /dev/null +++ b/src/datavis3d/engine/shaders/vertexShader @@ -0,0 +1,25 @@ +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; +} |