omar
October 19, 2019, 7:20pm
2
This is where the position_absolute is computed in the shader:
}
} else {
vs += ' vec4 color = u_constantColor; \n';
}
if (isQuantized || isQuantizedDraco) {
vs += ' vec3 position = a_position * u_quantizedVolumeScaleAndOctEncodedRange.xyz; \n';
} else {
vs += ' vec3 position = a_position; \n';
}
vs += ' vec3 position_absolute = vec3(czm_model * vec4(position, 1.0)); \n';
if (usesNormals) {
if (isOctEncoded16P) {
vs += ' vec3 normal = czm_octDecode(a_normal); \n';
} else if (isOctEncodedDraco) {
// Draco oct-encoding decodes to zxy order
vs += ' vec3 normal = czm_octDecode(a_normal, u_quantizedVolumeScaleAndOctEncodedRange.w).zxy; \n';
} else {
vs += ' vec3 normal = a_normal; \n';
}
Notice that it’s possible position_absolute has less precision than is used to place the point in the right location on the globe, because the point’s location is split into the RTC_CENTER and its position relative to that.
Also, in case others find it useful, here’s a Sandcastle that styles the points by distance relative to a given point . The point is computed by clicking somewhere and copying the console output into the shader.