392ac980 |
1 | // Created on: 2013-10-10 |
2 | // Created by: Denis BOGOLEPOV |
3 | // Copyright (c) 2013 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
12381341 |
20 | varying vec3 View; //!< Direction to the viewer |
21 | varying vec3 Normal; //!< Vertex normal in view space |
22 | varying vec4 Position; //!< Vertex position in view space |
392ac980 |
23 | |
12381341 |
24 | //! Computes the normal in view space |
392ac980 |
25 | vec3 TransformNormal (in vec3 theNormal) |
26 | { |
12381341 |
27 | vec4 aResult = occWorldViewMatrixInverseTranspose |
28 | * occModelWorldMatrixInverseTranspose |
29 | * vec4 (theNormal, 0.0); |
392ac980 |
30 | return normalize (aResult.xyz); |
31 | } |
32 | |
12381341 |
33 | //! Entry point to the Vertex Shader |
392ac980 |
34 | void main() |
35 | { |
12381341 |
36 | Position = occWorldViewMatrix * occModelWorldMatrix * occVertex; // position in the view space |
37 | Normal = TransformNormal (occNormal); // normal in the view space |
38 | |
39 | // Note: The specified view vector is absolutely correct only for the orthogonal projection. |
40 | // For perspective projection it will be approximate, but it is in good agreement with the OpenGL calculations. |
392ac980 |
41 | View = vec3 (0.0, 0.0, 1.0); |
42 | |
43 | // Do fixed functionality vertex transform |
44 | gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex; |
45 | } |