Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "tango-gl/shaders.h"
00017
00018 namespace tango_gl {
00019 namespace shaders {
00020 std::string GetBasicVertexShader() {
00021 return "precision mediump float;\n"
00022 "precision mediump int;\n"
00023 "attribute vec4 vertex;\n"
00024 "uniform mat4 mvp;\n"
00025 "uniform vec4 color;\n"
00026 "varying vec4 v_color;\n"
00027 "void main() {\n"
00028 " gl_Position = mvp*vertex;\n"
00029 " v_color = color;\n"
00030 "}\n";
00031 }
00032
00033 std::string GetBasicFragmentShader() {
00034 return "precision mediump float;\n"
00035 "varying vec4 v_color;\n"
00036 "void main() {\n"
00037 " gl_FragColor = v_color;\n"
00038 "}\n";
00039 }
00040
00041 std::string GetColorVertexShader() {
00042 return "precision mediump float;\n"
00043 "precision mediump int;\n"
00044 "attribute vec4 vertex;\n"
00045 "attribute vec4 color;\n"
00046 "uniform mat4 mvp;\n"
00047 "varying vec4 v_color;\n"
00048 "void main() {\n"
00049 " gl_Position = mvp*vertex;\n"
00050 " v_color = color;\n"
00051 "}\n";
00052 }
00053
00054 std::string GetVideoOverlayVertexShader() {
00055 return "precision highp float;\n"
00056 "precision highp int;\n"
00057 "attribute vec4 vertex;\n"
00058 "attribute vec2 textureCoords;\n"
00059 "varying vec2 f_textureCoords;\n"
00060 "uniform mat4 mvp;\n"
00061 "void main() {\n"
00062 " f_textureCoords = textureCoords;\n"
00063 " gl_Position = mvp * vertex;\n"
00064 "}\n";
00065 }
00066
00067 std::string GetVideoOverlayFragmentShader() {
00068 return "#extension GL_OES_EGL_image_external : require\n"
00069 "precision highp float;\n"
00070 "precision highp int;\n"
00071 "uniform samplerExternalOES texture;\n"
00072 "varying vec2 f_textureCoords;\n"
00073 "void main() {\n"
00074 " gl_FragColor = texture2D(texture, f_textureCoords);\n"
00075 "}\n";
00076 }
00077
00078 std::string GetShadedVertexShader() {
00079 return "attribute vec4 vertex;\n"
00080 "attribute vec3 normal;\n"
00081 "uniform mat4 mvp;\n"
00082 "uniform mat4 mv;\n"
00083 "uniform vec4 color;\n"
00084 "uniform vec3 lightVec;\n"
00085 "varying vec4 v_color;\n"
00086 "void main() {\n"
00087 " vec3 mvNormal = vec3(mv * vec4(normal, 0.0));\n"
00088 " float diffuse = max(-dot(mvNormal, lightVec), 0.0);\n"
00089 " v_color.a = color.a;\n"
00090 " v_color.xyz = color.xyz * diffuse + color.xyz * 0.3;\n"
00091 " gl_Position = mvp*vertex;\n"
00092 "}\n";
00093 }
00094 }
00095 }