shaders.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "tango-gl/shaders.h"
17 
18 namespace tango_gl {
19 namespace shaders {
20 std::string GetBasicVertexShader() {
21  return "precision mediump float;\n"
22  "precision mediump int;\n"
23  "attribute vec4 vertex;\n"
24  "uniform mat4 mvp;\n"
25  "uniform vec4 color;\n"
26  "varying vec4 v_color;\n"
27  "void main() {\n"
28  " gl_Position = mvp*vertex;\n"
29  " v_color = color;\n"
30  "}\n";
31 }
32 
33 std::string GetBasicFragmentShader() {
34  return "precision mediump float;\n"
35  "varying vec4 v_color;\n"
36  "void main() {\n"
37  " gl_FragColor = v_color;\n"
38  "}\n";
39 }
40 
41 std::string GetColorVertexShader() {
42  return "precision mediump float;\n"
43  "precision mediump int;\n"
44  "attribute vec4 vertex;\n"
45  "attribute vec4 color;\n"
46  "uniform mat4 mvp;\n"
47  "varying vec4 v_color;\n"
48  "void main() {\n"
49  " gl_Position = mvp*vertex;\n"
50  " v_color = color;\n"
51  "}\n";
52 }
53 
55  return "precision highp float;\n"
56  "precision highp int;\n"
57  "attribute vec4 vertex;\n"
58  "attribute vec2 textureCoords;\n"
59  "varying vec2 f_textureCoords;\n"
60  "uniform mat4 mvp;\n"
61  "void main() {\n"
62  " f_textureCoords = textureCoords;\n"
63  " gl_Position = mvp * vertex;\n"
64  "}\n";
65 }
66 
68  return "#extension GL_OES_EGL_image_external : require\n"
69  "precision highp float;\n"
70  "precision highp int;\n"
71  "uniform samplerExternalOES texture;\n"
72  "varying vec2 f_textureCoords;\n"
73  "void main() {\n"
74  " gl_FragColor = texture2D(texture, f_textureCoords);\n"
75  "}\n";
76 }
77 
78 std::string GetShadedVertexShader() {
79  return "attribute vec4 vertex;\n"
80  "attribute vec3 normal;\n"
81  "uniform mat4 mvp;\n"
82  "uniform mat4 mv;\n"
83  "uniform vec4 color;\n"
84  "uniform vec3 lightVec;\n"
85  "varying vec4 v_color;\n"
86  "void main() {\n"
87  " vec3 mvNormal = vec3(mv * vec4(normal, 0.0));\n"
88  " float diffuse = max(-dot(mvNormal, lightVec), 0.0);\n"
89  " v_color.a = color.a;\n"
90  " v_color.xyz = color.xyz * diffuse + color.xyz * 0.3;\n"
91  " gl_Position = mvp*vertex;\n"
92  "}\n";
93 }
94 } // namespace shaders
95 } // namespace tango_gl
std::string GetColorVertexShader()
Definition: shaders.cpp:41
std::string GetBasicFragmentShader()
Definition: shaders.cpp:33
std::string GetBasicVertexShader()
Definition: shaders.cpp:20
std::string GetVideoOverlayVertexShader()
Definition: shaders.cpp:54
std::string GetVideoOverlayFragmentShader()
Definition: shaders.cpp:67
std::string GetShadedVertexShader()
Definition: shaders.cpp:78


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:41:32