Skip to content

Commit

Permalink
Updated shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
r.kuznetsov authored and darina committed Jun 28, 2018
1 parent 21860e2 commit 68f4e87
Show file tree
Hide file tree
Showing 43 changed files with 292 additions and 291 deletions.
12 changes: 6 additions & 6 deletions shaders/GL/area.vsh.glsl
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
attribute vec3 a_position;
attribute vec2 a_colorTexCoords;

uniform mat4 modelView;
uniform mat4 projection;
uniform mat4 pivotTransform;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;

#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
#endif

void main()
{
vec4 pos = vec4(a_position, 1) * modelView * projection;
gl_Position = applyPivotTransform(pos, pivotTransform, 0.0);
vec4 pos = vec4(a_position, 1) * u_modelView * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords);
#else
Expand Down
22 changes: 11 additions & 11 deletions shaders/GL/area3d.vsh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_colorTexCoords;

uniform mat4 modelView;
uniform mat4 projection;
uniform mat4 pivotTransform;
uniform float zScale;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
uniform float u_zScale;

varying vec2 v_colorTexCoords;
varying float v_intensity;
Expand All @@ -14,21 +14,21 @@ const vec4 kNormalizedLightDir = vec4(0.3162, 0.0, 0.9486, 0.0);

void main()
{
vec4 pos = vec4(a_position, 1.0) * modelView;
vec4 pos = vec4(a_position, 1.0) * u_modelView;

vec4 normal = vec4(a_position + a_normal, 1.0) * modelView;
normal.xyw = (normal * projection).xyw;
normal.z = normal.z * zScale;
vec4 normal = vec4(a_position + a_normal, 1.0) * u_modelView;
normal.xyw = (normal * u_projection).xyw;
normal.z = normal.z * u_zScale;

pos.xyw = (pos * projection).xyw;
pos.z = a_position.z * zScale;
pos.xyw = (pos * u_projection).xyw;
pos.z = a_position.z * u_zScale;

vec4 normDir = normal - pos;
if (dot(normDir, normDir) != 0.0)
v_intensity = max(0.0, -dot(kNormalizedLightDir, normalize(normDir)));
else
v_intensity = 0.0;

gl_Position = pivotTransform * pos;
gl_Position = u_pivotTransform * pos;
v_colorTexCoords = a_colorTexCoords;
}
18 changes: 9 additions & 9 deletions shaders/GL/area3d_outline.vsh.glsl
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
attribute vec3 a_position;
attribute vec2 a_colorTexCoords;

uniform mat4 modelView;
uniform mat4 projection;
uniform mat4 pivotTransform;
uniform float zScale;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
uniform float u_zScale;

#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
#endif

void main()
{
vec4 pos = vec4(a_position, 1.0) * modelView;
pos.xyw = (pos * projection).xyw;
pos.z = a_position.z * zScale;
gl_Position = pivotTransform * pos;
vec4 pos = vec4(a_position, 1.0) * u_modelView;
pos.xyw = (pos * u_projection).xyw;
pos.z = a_position.z * u_zScale;
gl_Position = u_pivotTransform * pos;

#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords);
Expand Down
6 changes: 3 additions & 3 deletions shaders/GL/circle.fsh.glsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
uniform float u_opacity;
#ifdef ENABLE_VTF
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoords;
Expand All @@ -13,9 +13,9 @@ const float aaPixelsCount = 2.5;
void main()
{
#ifdef ENABLE_VTF
lowp vec4 finalColor = v_color;
LOW_P vec4 finalColor = v_color;
#else
lowp vec4 finalColor = texture2D(u_colorTex, v_colorTexCoords);
LOW_P vec4 finalColor = texture2D(u_colorTex, v_colorTexCoords);
#endif

float smallRadius = v_radius.z - aaPixelsCount;
Expand Down
12 changes: 6 additions & 6 deletions shaders/GL/circle.vsh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_colorTexCoords;

uniform mat4 modelView;
uniform mat4 projection;
uniform mat4 pivotTransform;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;

varying vec3 v_radius;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
#endif

void main()
{
vec4 p = vec4(a_position, 1) * modelView;
vec4 p = vec4(a_position, 1) * u_modelView;
vec4 pos = vec4(a_normal.xy, 0, 0) + p;
gl_Position = applyPivotTransform(pos * projection, pivotTransform, 0.0);
gl_Position = applyPivotTransform(pos * u_projection, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords);
#else
Expand Down
10 changes: 5 additions & 5 deletions shaders/GL/circle_point.vsh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ attribute vec3 a_normal;
attribute vec3 a_position;
attribute vec4 a_color;

uniform mat4 modelView;
uniform mat4 projection;
uniform mat4 pivotTransform;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;

varying vec3 v_radius;
varying vec4 v_color;

void main()
{
vec3 radius = a_normal * a_position.z;
vec4 pos = vec4(a_position.xy, 0, 1) * modelView;
vec4 pos = vec4(a_position.xy, 0, 1) * u_modelView;
vec4 shiftedPos = vec4(radius.xy, 0, 0) + pos;
gl_Position = applyPivotTransform(shiftedPos * projection, pivotTransform, 0.0);
gl_Position = applyPivotTransform(shiftedPos * u_projection, u_pivotTransform, 0.0);

v_radius = radius;
v_color = a_color;
Expand Down
8 changes: 4 additions & 4 deletions shaders/GL/colored_symbol.fsh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ uniform float u_opacity;

varying vec4 v_normal;
#ifdef ENABLE_VTF
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoords;
Expand All @@ -13,17 +13,17 @@ const float aaPixelsCount = 2.5;
void main()
{
#ifdef ENABLE_VTF
lowp vec4 color = v_color;
LOW_P vec4 color = v_color;
#else
lowp vec4 color = texture2D(u_colorTex, v_colorTexCoords);
LOW_P vec4 color = texture2D(u_colorTex, v_colorTexCoords);
#endif

float r1 = (v_normal.z - aaPixelsCount) * (v_normal.z - aaPixelsCount);
float r2 = v_normal.x * v_normal.x + v_normal.y * v_normal.y;
float r3 = v_normal.z * v_normal.z;
float alpha = mix(step(r3, r2), smoothstep(r1, r3, r2), v_normal.w);

lowp vec4 finalColor = color;
LOW_P vec4 finalColor = color;
finalColor.a = finalColor.a * u_opacity * (1.0 - alpha);
if (finalColor.a == 0.0)
discard;
Expand Down
12 changes: 6 additions & 6 deletions shaders/GL/colored_symbol.vsh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ attribute vec3 a_position;
attribute vec4 a_normal;
attribute vec4 a_colorTexCoords;

uniform mat4 modelView;
uniform mat4 projection;
uniform mat4 pivotTransform;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;

varying vec4 v_normal;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
#endif

void main()
{
vec4 p = vec4(a_position, 1) * modelView;
vec4 p = vec4(a_position, 1) * u_modelView;
vec4 pos = vec4(a_normal.xy + a_colorTexCoords.zw, 0, 0) + p;
gl_Position = applyPivotTransform(pos * projection, pivotTransform, 0.0);
gl_Position = applyPivotTransform(pos * u_projection, u_pivotTransform, 0.0);

#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords.xy);
Expand Down
14 changes: 7 additions & 7 deletions shaders/GL/colored_symbol_billboard.vsh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ attribute vec3 a_position;
attribute vec4 a_normal;
attribute vec4 a_colorTexCoords;

uniform mat4 modelView;
uniform mat4 projection;
uniform mat4 pivotTransform;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;

varying vec4 v_normal;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
#endif

void main()
{
vec4 pivot = vec4(a_position.xyz, 1.0) * modelView;
vec4 offset = vec4(a_normal.xy + a_colorTexCoords.zw, 0.0, 0.0) * projection;
gl_Position = applyBillboardPivotTransform(pivot * projection, pivotTransform, 0.0, offset.xy);
vec4 pivot = vec4(a_position.xyz, 1.0) * u_modelView;
vec4 offset = vec4(a_normal.xy + a_colorTexCoords.zw, 0.0, 0.0) * u_projection;
gl_Position = applyBillboardPivotTransform(pivot * u_projection, u_pivotTransform, 0.0, offset.xy);

#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords.xy);
Expand Down
16 changes: 8 additions & 8 deletions shaders/GL/dashed_line.vsh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ attribute vec3 a_normal;
attribute vec2 a_colorTexCoord;
attribute vec4 a_maskTexCoord;

uniform mat4 modelView;
uniform mat4 projection;
uniform mat4 pivotTransform;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;

varying vec2 v_colorTexCoord;
varying vec2 v_maskTexCoord;
Expand All @@ -15,18 +15,18 @@ void main()
{
vec2 normal = a_normal.xy;
float halfWidth = length(normal);
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * modelView).xy;
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
if (halfWidth != 0.0)
{
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + normal,
modelView, halfWidth);
u_modelView, halfWidth);
}

float uOffset = min(length(vec4(kShapeCoordScalar, 0, 0, 0) * modelView) * a_maskTexCoord.x, 1.0);
float uOffset = min(length(vec4(kShapeCoordScalar, 0, 0, 0) * u_modelView) * a_maskTexCoord.x, 1.0);
v_colorTexCoord = a_colorTexCoord;
v_maskTexCoord = vec2(a_maskTexCoord.y + uOffset * a_maskTexCoord.z, a_maskTexCoord.w);
v_halfLength = vec2(sign(a_normal.z) * halfWidth, abs(a_normal.z));
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * projection;
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;

gl_Position = applyPivotTransform(pos, pivotTransform, 0.0);
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}
6 changes: 3 additions & 3 deletions shaders/GL/hatching_area.fsh.glsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
uniform float u_opacity;

#ifdef ENABLE_VTF
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoords;
Expand All @@ -13,9 +13,9 @@ varying vec2 v_maskTexCoords;
void main()
{
#ifdef ENABLE_VTF
lowp vec4 color = v_color;
LOW_P vec4 color = v_color;
#else
lowp vec4 color = texture2D(u_colorTex, v_colorTexCoords);
LOW_P vec4 color = texture2D(u_colorTex, v_colorTexCoords);
#endif
color *= texture2D(u_maskTex, v_maskTexCoords);
color.a *= u_opacity;
Expand Down
12 changes: 6 additions & 6 deletions shaders/GL/hatching_area.vsh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ attribute vec3 a_position;
attribute vec2 a_colorTexCoords;
attribute vec2 a_maskTexCoords;

uniform mat4 modelView;
uniform mat4 projection;
uniform mat4 pivotTransform;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;

#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
#endif
varying vec2 v_maskTexCoords;

void main()
{
vec4 pos = vec4(a_position, 1) * modelView * projection;
gl_Position = applyPivotTransform(pos, pivotTransform, 0.0);
vec4 pos = vec4(a_position, 1) * u_modelView * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords);
#else
Expand Down
6 changes: 3 additions & 3 deletions shaders/GL/line.fsh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ varying vec2 v_halfLength;

uniform float u_opacity;
#ifdef ENABLE_VTF
varying lowp vec4 v_color;
varying LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoord;
Expand All @@ -13,9 +13,9 @@ const float aaPixelsCount = 2.5;
void main()
{
#ifdef ENABLE_VTF
lowp vec4 color = v_color;
LOW_P vec4 color = v_color;
#else
lowp vec4 color = texture2D(u_colorTex, v_colorTexCoord);
LOW_P vec4 color = texture2D(u_colorTex, v_colorTexCoord);
#endif
color.a *= u_opacity;

Expand Down
Loading

0 comments on commit 68f4e87

Please sign in to comment.