forked from organicmaps/organicmaps-tmp
[drape] new shaders
This commit is contained in:
parent
7147b87ef6
commit
930668008d
7 changed files with 78 additions and 15 deletions
23
drape/shaders/doc/normalize_vertex_shader_vsh.txt
Normal file
23
drape/shaders/doc/normalize_vertex_shader_vsh.txt
Normal file
|
@ -0,0 +1,23 @@
|
|||
Transform point from mercator to current model view and forming triangles by normals
|
||||
|
||||
mercatorPoint -> currentModelViewPoint
|
||||
currentModelViewPoint + normal;
|
||||
|
||||
Example:
|
||||
vertex number 1 2 3 4
|
||||
pt stream = [{ 0.0, 0.0}, { 0.0, 0.0} , {0.0, 0.0} , {0.0, 0.0}]
|
||||
normal stream = [{-1.0, 1.0}, {-1.0, -1.0} , {1.0, 1.0} , {1.0, -1.0}]
|
||||
Type = Triangle strip
|
||||
|
||||
1 3
|
||||
_____
|
||||
| /|
|
||||
| . |
|
||||
|/__|
|
||||
2 4
|
||||
|
||||
attribute a_position
|
||||
[x, y] - mercator position
|
||||
[z ] - depth
|
||||
attribute a_normal
|
||||
[x, y] - forming normal
|
10
drape/shaders/normalize_vertex_shader.vsh
Normal file
10
drape/shaders/normalize_vertex_shader.vsh
Normal file
|
@ -0,0 +1,10 @@
|
|||
attribute vec4 a_position;
|
||||
attribute vec4 a_normal;
|
||||
|
||||
uniform mat4 modelView;
|
||||
uniform mat4 projection;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = ((a_position * modelView) + a_normal) * projection;
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
SOLID_AREA_PROGRAM simple_vertex_shader.vsh solid_color_fragment_shader.fsh
|
||||
SOLID_SHAPE_PROGRAM normalize_vertex_shader.vsh solid_color_fragment_shader.fsh
|
||||
TEXTURING_PROGRAM texturing_vertex_shader.vsh texturing_fragment_shader.fsh
|
||||
SOLID_LINE_PROGRAM line_vertex_shader.vsh line_fragment_shader.fsh
|
||||
SOLID_LINE_PROGRAM line_vertex_shader.vsh line_fragment_shader.fsh
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
attribute vec4 position;
|
||||
attribute vec4 a_position;
|
||||
|
||||
uniform mat4 modelView;
|
||||
uniform mat4 projection;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = position * modelView * projection;
|
||||
gl_Position = a_position * modelView * projection;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
uniform lowp vec4 color;
|
||||
uniform lowp vec4 u_color;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_FragColor = color;
|
||||
gl_FragColor = u_color;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,35 @@
|
|||
uniform sampler2D textureUnit;
|
||||
varying highp vec4 varTexCoords;
|
||||
uniform sampler2D u_textures[8];
|
||||
varying highp vec4 v_texCoords;
|
||||
|
||||
const int Index0 = 0;
|
||||
const int Index1 = 1;
|
||||
const int Index2 = 2;
|
||||
const int Index3 = 3;
|
||||
const int Index4 = 4;
|
||||
const int Index5 = 5;
|
||||
const int Index6 = 6;
|
||||
const int Index7 = 7;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_FragColor = texture2D(textureUnit, varTexCoords.st);
|
||||
int index = int(floor(v_texCoords.z));
|
||||
highp vec4 color;
|
||||
if (index == Index0)
|
||||
color = texture2D(u_textures[Index0], v_texCoords.st);
|
||||
else if (index == Index1)
|
||||
color = texture2D(u_textures[Index1], v_texCoords.st);
|
||||
else if (index == Index2)
|
||||
color = texture2D(u_textures[Index2], v_texCoords.st);
|
||||
else if (index == Index3)
|
||||
color = texture2D(u_textures[Index3], v_texCoords.st);
|
||||
else if (index == Index4)
|
||||
color = texture2D(u_textures[Index4], v_texCoords.st);
|
||||
else if (index == Index5)
|
||||
color = texture2D(u_textures[Index5], v_texCoords.st);
|
||||
else if (index == Index6)
|
||||
color = texture2D(u_textures[Index6], v_texCoords.st);
|
||||
else if (index == Index7)
|
||||
color = texture2D(u_textures[Index7], v_texCoords.st);
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
attribute mediump vec2 position;
|
||||
attribute mediump float depth;
|
||||
attribute mediump vec4 texCoords;
|
||||
attribute highp vec4 a_position;
|
||||
attribute highp vec4 a_normal;
|
||||
attribute highp vec4 a_texCoords;
|
||||
|
||||
uniform highp mat4 modelViewProjectionMatrix;
|
||||
uniform highp mat4 modelView;
|
||||
uniform highp mat4 projection;
|
||||
|
||||
varying highp vec4 varTexCoords;
|
||||
varying highp vec4 v_texCoords;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = modelViewProjectionMatrix * vec4(position, depth, 1.0);
|
||||
varTexCoords = texCoords;
|
||||
gl_Position = ((a_position * modelView) + a_normal) * projection;
|
||||
v_texCoords = a_texCoords;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue