Merge branch 'thesis/2021/skybrowser' of https://github.com/OpenSpace/OpenSpace into thesis/2021/skybrowser

This commit is contained in:
Ylva Selling
2021-03-30 08:31:20 +02:00
2 changed files with 7 additions and 10 deletions

View File

@@ -10,12 +10,9 @@ in vec4 vs_position;
float crossLine(in float _width, in float _coord) {
float center = 0.5f;
float line = smoothstep(center, center+(_width/2) , _coord) -
smoothstep(center-(_width/2), center, _coord);
return line;
}
@@ -24,23 +21,23 @@ float crossLine(in float _width, in float _coord) {
Fragment getFragment() {
Fragment frag;
float ratio = targetDimensions.y / targetDimensions.x;
// draw crosshair
float crossWidth = 0.1f;
float ratio = targetDimensions.y / targetDimensions.x;
vec3 crosshair = vec3(crossLine(crossWidth*ratio, (vs_st).x) + crossLine(crossWidth, (vs_st).y));
// draw square border
vec2 bl = step(vec2(borderWidth),(1.0-vs_st)); // bottom-left line
vec2 tr = step(vec2(borderWidth),vs_st); // top-right line
vec3 border = vec3(tr.x * tr.y * bl.x * bl.y);
float borderBottomLeft = step(borderWidth*ratio, vs_st.x) * step(borderWidth*ratio, (1.0)-vs_st.x);
float borderTopRight = step(borderWidth, vs_st.y) * step(borderWidth, (1.0)-vs_st.y);
vec3 border = vec3(borderBottomLeft*borderTopRight);
// show crosshair or border
frag.color = vec4(1,1,1,1);
frag.color.rgb = vec3(borderColor / 255);
if(showCrosshair) {
frag.color = vec4(1,1,1,1);
frag.color.rgb = vec3(borderColor / 255);
if(crosshair == vec3(0.0)) {
frag.color.a = 0.0;
}

View File

@@ -204,7 +204,7 @@ namespace openspace {
glDisable(GL_CULL_FACE);
glm::mat4 modelTransform = globalRotationMatrix() * translationMatrix() * localRotationMatrix() * scaleMatrix();
float borderWidth = 0.004f /(_scale.value());
float borderWidth = 0.005f/_scale.value();
glm::vec2 targetDim;
bool showCrosshair;
_targetDimensions.value() == glm::vec2(0) ? targetDim = glm::vec2(1) : targetDim = _targetDimensions.value();