This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
shaders.h
116 lines (96 loc) · 2.3 KB
/
shaders.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#pragma once
#include <osg/GL>
//
// vertex color shader
//
#if OSG_GLES3_FEATURES
const char* ColorShaderVert =
"#version 300 es\n"
"in vec4 osg_Vertex;\n"
"in vec4 osg_Color;\n"
"out vec4 vertColor;\n"
"uniform mat4 osg_ModelViewProjectionMatrix;\n"
"void main()\n"
"{\n"
" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"
" vertColor = osg_Color;\n"
"}\n";
const char* ColorShaderFrag =
"#version 300 es\n"
"in lowp vec4 vertColor;\n"
"out lowp vec4 fragColor;\n"
"void main()\n"
"{\n"
" fragColor = vertColor;\n"
"}\n";
#elif OSG_GLES2_FEATURES
const char* ColorShaderVert =
"#version 100\n"
"attribute vec4 osg_Vertex;\n"
"attribute vec4 osg_Color;\n"
"uniform mat4 osg_ModelViewProjectionMatrix;\n"
"varying vec4 vertColor;\n"
"void main()\n"
"{\n"
" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"
" vertColor = osg_Color;\n"
"}\n";
const char* ColorShaderFrag =
"#version 100\n"
"varying lowp vec4 vertColor;\n"
"void main()\n"
"{\n"
" gl_FragColor = vertColor;\n"
"}\n";
#else
const char* ColorShaderVert = NULL;
const char* ColorShaderFrag = NULL;
#endif
//
// texture shader
//
#if OSG_GLES3_FEATURES
const char* TextureShaderVert =
"#version 300 es\n"
"in vec4 osg_Vertex;\n"
"in vec4 osg_MultiTexCoord0;\n"
"out vec4 texcoord0;\n"
"uniform mat4 osg_ModelViewProjectionMatrix;\n"
"void main()\n"
"{\n"
" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"
" texcoord0 = osg_MultiTexCoord0;\n"
"}\n";
const char* TextureShaderFrag =
"#version 300 es\n"
"in lowp vec4 texcoord0;\n"
"uniform sampler2D texture0;\n"
"out lowp vec4 fragColor;\n"
"void main()\n"
"{\n"
" fragColor = texture(texture0, texcoord0.xy);\n"
"}\n";
#elif OSG_GLES2_FEATURES
const char* TextureShaderVert =
"#version 100\n"
"attribute vec4 osg_Vertex;\n"
"attribute vec4 osg_MultiTexCoord0;\n"
"uniform mat4 osg_ModelViewProjectionMatrix;\n"
"varying vec4 texcoord0;\n"
"void main()\n"
"{\n"
" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"
" texcoord0 = osg_MultiTexCoord0;\n"
"}\n";
const char* TextureShaderFrag =
"#version 100\n"
"varying lowp vec4 texcoord0;\n"
"uniform sampler2D texture0;\n"
"void main()\n"
"{\n"
" gl_FragColor = texture2D(texture0, texcoord0.xy);\n"
"}\n";
#else
const char* TextureShaderVert = NULL;
const char* TextureShaderFrag = NULL;
#endif