OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
Sergey Ulanov
2016/06/27 23:15:30
Do you need to put shaders in separate files? Why
Yuwei
2016/06/28 01:31:20
I feel like it is more maintainable in this way...
Sergey Ulanov
2016/06/30 00:34:52
This is great stuff, but I don't think we need it.
Yuwei
2016/07/07 22:07:45
Done. Moved shaders into GlCanvas.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Region of the texture to be used (normally the whole texture). | |
6 varying vec2 v_texCoord; | |
7 attribute vec2 a_texCoord; | |
8 | |
9 // Positions to draw the texture on the texture coordinates. | |
10 attribute vec2 a_position; | |
11 | |
12 uniform mat3 u_transform; | |
13 void main() | |
14 { | |
15 v_texCoord = a_texCoord; | |
16 | |
17 // (2D) Add projection dimension with value 1. | |
18 vec3 trans_position = u_transform * vec3(a_position, 1.0); | |
19 | |
20 // (2D) convert texture position [0, 1] to view position [-1, 1]. | |
21 trans_position = 2.0 * trans_position - 1.0; | |
22 | |
23 // (2D) Flips the texture. | |
24 trans_position.y *= -1.0; | |
25 | |
26 // (3D) Set z coordinate to 0. | |
27 trans_position.z = 0.0; | |
Sergey Ulanov
2016/06/27 23:15:30
I think all operations above can be represented as
Yuwei
2016/06/28 01:31:20
That's a good point. Everything here is just linea
| |
28 | |
29 // (3D) Add projection dimension with value 1. | |
30 gl_Position = vec4(trans_position, 1.0); | |
31 } | |
OLD | NEW |