Skip to content

Commit

Permalink
Add missing log depth to appearances, point primitives and vector til…
Browse files Browse the repository at this point in the history
…e polylines.
  • Loading branch information
bagnell committed Feb 15, 2018
1 parent c94e5ad commit 7d716e9
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Source/Shaders/Appearances/AllMaterialAppearanceFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ varying vec3 v_normalEC;
varying vec3 v_tangentEC;
varying vec3 v_bitangentEC;
varying vec2 v_st;
varying float v_inverse_depth;

void main()
{
Expand All @@ -26,4 +27,6 @@ void main()
#else
gl_FragColor = czm_phong(normalize(positionToEyeEC), material);
#endif

czm_logDepth(v_inverse_depth);
}
2 changes: 1 addition & 1 deletion Source/Shaders/Appearances/AllMaterialAppearanceVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void main()
v_tangentEC = czm_normal * tangent; // tangent in eye coordinates
v_bitangentEC = czm_normal * bitangent; // bitangent in eye coordinates
v_st = st;
v_inverse_depth = -1.0 / v_positionEC.z;

gl_Position = czm_modelViewProjectionRelativeToEye * p;
v_inverse_depth = 1.0 / gl_Position.w;
}
9 changes: 6 additions & 3 deletions Source/Shaders/Appearances/BasicMaterialAppearanceFS.glsl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
varying vec3 v_positionEC;
varying vec3 v_normalEC;
varying float v_inverse_depth;

void main()
{
vec3 positionToEyeEC = -v_positionEC;
vec3 positionToEyeEC = -v_positionEC;

vec3 normalEC = normalize(v_normalEC);
#ifdef FACE_FORWARD
Expand All @@ -14,10 +15,12 @@ void main()
materialInput.normalEC = normalEC;
materialInput.positionToEyeEC = positionToEyeEC;
czm_material material = czm_getMaterial(materialInput);
#ifdef FLAT

#ifdef FLAT
gl_FragColor = vec4(material.diffuse + material.emission, material.alpha);
#else
gl_FragColor = czm_phong(normalize(positionToEyeEC), material);
#endif

czm_logDepth(v_inverse_depth);
}
6 changes: 4 additions & 2 deletions Source/Shaders/Appearances/BasicMaterialAppearanceVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ attribute float batchId;

varying vec3 v_positionEC;
varying vec3 v_normalEC;
varying float v_inverse_depth;

void main()
void main()
{
vec4 p = czm_computePosition();

v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates
v_normalEC = czm_normal * normal; // normal in eye coordinates

gl_Position = czm_modelViewProjectionRelativeToEye * p;
v_inverse_depth = 1.0 / gl_Position.w;
}
17 changes: 10 additions & 7 deletions Source/Shaders/Appearances/EllipsoidSurfaceAppearanceFS.glsl
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
varying vec3 v_positionMC;
varying vec3 v_positionEC;
varying vec2 v_st;
varying float v_inverse_depth;

void main()
{
czm_materialInput materialInput;

vec3 normalEC = normalize(czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)));
#ifdef FACE_FORWARD
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif

materialInput.s = v_st.s;
materialInput.st = v_st;
materialInput.str = vec3(v_st, 0.0);

// Convert tangent space material normal to eye space
materialInput.normalEC = normalEC;
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, materialInput.normalEC);

// Convert view vector to world space
vec3 positionToEyeEC = -v_positionEC;
vec3 positionToEyeEC = -v_positionEC;
materialInput.positionToEyeEC = positionToEyeEC;

czm_material material = czm_getMaterial(materialInput);
#ifdef FLAT

#ifdef FLAT
gl_FragColor = vec4(material.diffuse + material.emission, material.alpha);
#else
gl_FragColor = czm_phong(normalize(positionToEyeEC), material);
#endif

czm_logDepth(v_inverse_depth);
}
6 changes: 4 additions & 2 deletions Source/Shaders/Appearances/EllipsoidSurfaceAppearanceVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ attribute float batchId;
varying vec3 v_positionMC;
varying vec3 v_positionEC;
varying vec2 v_st;
varying float v_inverse_depth;

void main()
void main()
{
vec4 p = czm_computePosition();

v_positionMC = position3DHigh + position3DLow; // position in model coordinates
v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates
v_st = st;

gl_Position = czm_modelViewProjectionRelativeToEye * p;
v_inverse_depth = 1.0 / gl_Position.w;
}
2 changes: 2 additions & 0 deletions Source/Shaders/PointPrimitiveCollectionFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ varying vec4 v_color;
varying vec4 v_outlineColor;
varying float v_innerPercent;
varying float v_pixelDistance;
varying float v_inverse_depth;

#ifdef RENDER_FOR_PICK
varying vec4 v_pickColor;
Expand Down Expand Up @@ -46,4 +47,5 @@ void main()
#else
gl_FragColor = color;
#endif
czm_logDepth(v_inverse_depth);
}
3 changes: 3 additions & 0 deletions Source/Shaders/PointPrimitiveCollectionVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ varying vec4 v_color;
varying vec4 v_outlineColor;
varying float v_innerPercent;
varying float v_pixelDistance;
varying float v_inverse_depth;

#ifdef RENDER_FOR_PICK
varying vec4 v_pickColor;
Expand Down Expand Up @@ -180,6 +181,8 @@ void main()
v_pixelDistance = 2.0 / totalSize;
gl_PointSize = totalSize;

v_inverse_depth = 1.0 / (czm_modelViewProjectionRelativeToEye * p).w;

#ifdef RENDER_FOR_PICK
v_pickColor = pickColor;
#endif
Expand Down
3 changes: 3 additions & 0 deletions Source/Shaders/Vector3DTilePolylinesVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ attribute float a_batchId;

uniform mat4 u_modifiedModelView;

varying float v_inverse_depth;

void main()
{
float expandDir = expandAndWidth.x;
Expand All @@ -19,4 +21,5 @@ void main()
float angle;
vec4 positionWC = getPolylineWindowCoordinatesEC(p, prev, next, expandDir, width, usePrev, angle);
gl_Position = czm_viewportOrthographic * positionWC;
v_inverse_depth = 1.0 / (czm_projection * u_modifiedModelView * currentPosition).w;
}

0 comments on commit 7d716e9

Please sign in to comment.