Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
likangning93 committed Sep 23, 2019
1 parent ca765ff commit c283527
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Source/Renderer/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ define([
},

/**
* <code>true</code> returns if the context's floating point textures support 6 decimal places of precision.
* Returns <code>true</code> if the context's floating point textures support 6 decimal places of precision.
* @memberof Context.prototype
* @type {Boolean}
* @see {@link https://www.khronos.org/registry/webgl/extensions/OES_texture_float/}
Expand Down
2 changes: 1 addition & 1 deletion Source/Renderer/checkFloatTexturePrecision.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define([
* Checks if the context's floating point textures support 6 decimal places of precision.
*
* @param {Context} context A context wrapping a gl implementation.
* @returns {Boolean} whether or not the context's floating point textures support 6 decimal places of precision
* @returns {Boolean} Whether or not the context's floating point textures support 6 decimal places of precision
*
* @private
*/
Expand Down
3 changes: 2 additions & 1 deletion Source/Shaders/CheckFloatTexturePrecisionFS.glsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
uniform sampler2D u_floatTexture;

void main() {
void main()
{
float actual = texture2D(u_floatTexture, vec2(0.5, 0.5)).r;
float expected = 123456.0;
gl_FragColor = vec4(abs(actual - expected), 0.0, 0.0, 1.0);
Expand Down
12 changes: 8 additions & 4 deletions Source/Shaders/ShadowVolumeAppearanceFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ varying vec4 v_color;
#endif

#ifdef NORMAL_EC
vec3 getEyeCoordinate3FromWindowCoordinate(vec2 fragCoord, float logDepthOrDepth) {
vec3 getEyeCoordinate3FromWindowCoordinate(vec2 fragCoord, float logDepthOrDepth)
{
vec4 eyeCoordinate = czm_windowToEyeCoordinates(fragCoord, logDepthOrDepth);
return eyeCoordinate.xyz / eyeCoordinate.w;
}

vec3 vectorFromOffset(vec4 eyeCoordinate, vec2 positiveOffset) {
vec3 vectorFromOffset(vec4 eyeCoordinate, vec2 positiveOffset)
{
vec2 glFragCoordXY = gl_FragCoord.xy;
// Sample depths at both offset and negative offset
float upOrRightLogDepth = czm_unpackDepth(texture2D(czm_globeDepthTexture, (glFragCoordXY + positiveOffset) / czm_viewport.zw));
Expand Down Expand Up @@ -71,7 +73,8 @@ void main(void)

#ifdef PICK
#ifdef CULL_FRAGMENTS
if (0.0 <= uv.x && uv.x <= 1.0 && 0.0 <= uv.y && uv.y <= 1.0) {
if (0.0 <= uv.x && uv.x <= 1.0 && 0.0 <= uv.y && uv.y <= 1.0)
{
gl_FragColor.a = 1.0; // 0.0 alpha leads to discard from ShaderSource.createPickFragmentShaderSource
czm_writeDepthClampedToFarPlane();
}
Expand All @@ -81,7 +84,8 @@ void main(void)
#else // PICK

#ifdef CULL_FRAGMENTS
if (uv.x <= 0.0 || 1.0 <= uv.x || uv.y <= 0.0 || 1.0 <= uv.y) {
if (uv.x <= 0.0 || 1.0 <= uv.x || uv.y <= 0.0 || 1.0 <= uv.y)
{
discard;
}
#endif
Expand Down
28 changes: 19 additions & 9 deletions Source/Shaders/ShadowVolumeAppearanceVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ varying vec3 v_vMaxAndInverseDistance;
#endif // TEXTURE_COORDINATES

#if defined(TEXTURE_COORDINATES) && !defined(SPHERICAL) && defined(UINT8_PACKING)
vec4 clampAndMagnitude(vec4 sd) {
vec4 clampAndMagnitude(vec4 sd)
{
vec4 d = sd;
d.x = czm_branchFreeTernary(sd.x < 128.0, d.x, (255.0 - sd.x));
d.x = floor(0.5 + d.x);
Expand All @@ -36,24 +37,29 @@ vec4 clampAndMagnitude(vec4 sd) {
return d;
}

float unpackLowLessThan100k(vec4 sd) {
float unpackLowLessThan100k(vec4 sd)
{
vec4 d = clampAndMagnitude(sd);
return (1000.0 * d.x + 10.0 * d.y + 0.1 * d.z + 0.001 * d.w) * czm_branchFreeTernary(sd.x < 128.0, 1.0, -1.0);
}

vec3 southwest_LOW(vec4 x, vec4 y, vec4 z) {
vec3 southwest_LOW(vec4 x, vec4 y, vec4 z)
{
vec3 value;
value.x = unpackLowLessThan100k(x);
value.y = unpackLowLessThan100k(y);
value.z = unpackLowLessThan100k(z);
return value;
}

float unpackHighMagLessThan100Million(vec4 sd) {
float unpackHighMagLessThan100Million(vec4 sd)
{
vec4 d = clampAndMagnitude(sd);
return (1000000.0 * d.x + 10000.0 * d.y + 100.0 * d.z + d.w) * czm_branchFreeTernary(sd.x < 128.0, 1.0, -1.0);
}
vec3 southwest_HIGH(vec4 x, vec4 y, vec4 z) {

vec3 southwest_HIGH(vec4 x, vec4 y, vec4 z)
{
vec3 value;
value.x = unpackHighMagLessThan100Million(x);
value.y = unpackHighMagLessThan100Million(y);
Expand All @@ -62,7 +68,8 @@ vec3 southwest_HIGH(vec4 x, vec4 y, vec4 z) {
}

#ifdef COLUMBUS_VIEW_2D
vec4 unpackPlanes2D_HIGH(vec4 x, vec4 y, vec4 z, vec4 w) {
vec4 unpackPlanes2D_HIGH(vec4 x, vec4 y, vec4 z, vec4 w)
{
vec4 value;
value.x = unpackHighMagLessThan100Million(x);
value.y = unpackHighMagLessThan100Million(y);
Expand All @@ -71,7 +78,8 @@ vec4 unpackPlanes2D_HIGH(vec4 x, vec4 y, vec4 z, vec4 w) {
return value;
}

vec4 unpackPlanes2D_LOW(vec4 x, vec4 y, vec4 z, vec4 w) {
vec4 unpackPlanes2D_LOW(vec4 x, vec4 y, vec4 z, vec4 w)
{
vec4 value;
value.x = unpackLowLessThan100k(x);
value.y = unpackLowLessThan100k(y);
Expand All @@ -81,12 +89,14 @@ vec4 unpackPlanes2D_LOW(vec4 x, vec4 y, vec4 z, vec4 w) {
}

#else
float unpackLowLessThan1000k(vec4 sd) {
float unpackLowLessThan1000k(vec4 sd)
{
vec4 d = clampAndMagnitude(sd);
return (10000.0 * d.x + 100.0 * d.y + d.z + 0.01 * d.w) * czm_branchFreeTernary(sd.x < 128.0, 1.0, -1.0);
}

vec3 unpackExtent(vec4 x, vec4 y, vec4 z) {
vec3 unpackExtent(vec4 x, vec4 y, vec4 z)
{
vec3 value;
value.x = unpackLowLessThan1000k(x);
value.y = unpackLowLessThan1000k(y);
Expand Down

0 comments on commit c283527

Please sign in to comment.