mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-02 00:44:43 -05:00
Update path rendering to higher precision.
This commit is contained in:
@@ -22,23 +22,16 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
in vec4 vs_point_position;
|
||||
flat in int isHour;
|
||||
in vec4 vs_point_color;
|
||||
|
||||
uniform vec3 color;
|
||||
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
#include "fragment.glsl"
|
||||
|
||||
in vec4 vs_positionScreenSpace;
|
||||
in vec4 vs_pointColor;
|
||||
|
||||
Fragment getFragment() {
|
||||
vec4 position = vs_point_position;
|
||||
float depth = pscDepth(position);
|
||||
|
||||
vec4 diffuse = vs_point_color;
|
||||
|
||||
Fragment frag;
|
||||
frag.color = diffuse;
|
||||
frag.depth = depth;
|
||||
frag.color = vs_pointColor;
|
||||
frag.depth = vs_positionScreenSpace.w;
|
||||
return frag;
|
||||
}
|
||||
|
||||
@@ -25,108 +25,32 @@
|
||||
#version __CONTEXT__
|
||||
|
||||
in vec4 in_point_position;
|
||||
|
||||
uniform vec3 color;
|
||||
uniform mat4 modelViewTransform;
|
||||
uniform mat4 projectionTransform;
|
||||
|
||||
out vec4 vs_point_position;
|
||||
flat out int isHour;
|
||||
out vec4 vs_point_color;
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
uniform vec4 objectVelocity;
|
||||
uniform vec4 lastPosition;
|
||||
|
||||
//this function does not consider cases where w component is negative
|
||||
float psc_distance(vec4 v1, vec4 v2) {
|
||||
// reduce position numbers
|
||||
/*while(v1.w > 1 && v2.w > 1) {
|
||||
v1.w -= 1;
|
||||
v2.w -= 1;
|
||||
} */
|
||||
// get position in vec3
|
||||
if (v1.w > 1) {
|
||||
float f = floor(v1.w);
|
||||
v1.xyz *= pow(10, f);
|
||||
v1.w -= f;
|
||||
}
|
||||
|
||||
if (v2.w > 1) {
|
||||
float f = floor(v2.w);
|
||||
v2.xyz *= pow(10, f);
|
||||
v2.w -= f;
|
||||
}
|
||||
|
||||
// using native distance function
|
||||
return distance(v1.xyz, v2.xyz);
|
||||
}
|
||||
out vec4 vs_positionScreenSpace;
|
||||
out vec4 vs_pointColor;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
vec4 gray = vec4(0.6f, 0.6f, 0.6f, 0.8f);
|
||||
float cameraTooFar = 1 * pow(k, 10);
|
||||
float bigPoint = 5.f;
|
||||
float smallPoint = 2.f;
|
||||
|
||||
vec4 tmp = in_point_position;
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_point_position = tmp;
|
||||
position = ViewProjection * position;
|
||||
gl_Position = z_normalization(position);
|
||||
|
||||
void main() {
|
||||
vec4 positionClipSpace = projectionTransform * modelViewTransform * in_point_position;
|
||||
vs_positionScreenSpace = z_normalization(positionClipSpace);
|
||||
|
||||
gl_Position = vs_positionScreenSpace;
|
||||
|
||||
int id = gl_VertexID;
|
||||
float hour = mod(id, 4);
|
||||
bool isNewHour = mod(id * 900, 3600) > 0;
|
||||
|
||||
vs_point_color.xyz = color;
|
||||
vs_point_color[3] = 1.f;
|
||||
|
||||
vec4 v1 = campos;
|
||||
vec4 v2 = vs_point_position;
|
||||
float cameraDistance = psc_distance(v1,v2);
|
||||
|
||||
vec4 temp = in_point_position;
|
||||
vec4 templast = lastPosition;
|
||||
|
||||
if (temp.w > 1) {
|
||||
float f = floor(temp.w);
|
||||
temp.w -= f;
|
||||
temp.xyz *= pow(10, f);
|
||||
}
|
||||
|
||||
if (templast.w > 1) {
|
||||
float f = floor(templast.w);
|
||||
templast.w -= f;
|
||||
templast.xyz *= pow(10, f);
|
||||
}
|
||||
|
||||
// while(temp.w > 1) {
|
||||
// temp.xyz *= 10;
|
||||
// temp.w -= 1;
|
||||
// }
|
||||
// while(templast.w > 1) {
|
||||
// templast.xyz *= 10;
|
||||
// templast.w -= 1;
|
||||
// }
|
||||
float observerDistance = length(temp.xyz);
|
||||
float lastDistance = length(templast.xyz);
|
||||
|
||||
if(hour > 0.1f) {
|
||||
isHour = 0;
|
||||
vs_point_color = gray;
|
||||
gl_PointSize = bigPoint;
|
||||
if(isNewHour) {
|
||||
vs_pointColor = vec4(0.6f, 0.6f, 0.6f, 0.8f);
|
||||
gl_PointSize = 5.f;
|
||||
}
|
||||
else {
|
||||
isHour = 1;
|
||||
gl_PointSize = bigPoint;
|
||||
vs_pointColor.rgb = color;
|
||||
vs_pointColor.a = 1.f;
|
||||
gl_PointSize = 10.0f;
|
||||
}
|
||||
if (observerDistance > (lastDistance/20)) {
|
||||
gl_PointSize = smallPoint;
|
||||
//vs_point_color = gray;
|
||||
}
|
||||
/*if (cameraDistance > cameraTooFar ) {
|
||||
vs_point_color[3] = 0.0f;
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user