Files
OpenSpace/modules/base/shaders/axes_fs.glsl
Emma Broman 16aa150f10 Polish RenderableCartesianAxes - documentation, examples, and make fading work correctly (#3478)
* Make `RenderableCartesianAxes` fade and fix opacity setting

* Update existing documentation of cartesian axes

* Add example with custom colros and parent node

* Apply suggestions from code review

Co-authored-by: Alexander Bock <alexander.bock@liu.se>

* Include earth asset instead of using string identifer

---------

Co-authored-by: Alexander Bock <alexander.bock@liu.se>
2025-01-17 13:18:45 +01:00

54 lines
2.8 KiB
GLSL

/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2025 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include "fragment.glsl"
in float vs_screenSpaceDepth;
in vec4 vs_positionViewSpace;
in vec3 vs_positionModelSpace;
uniform vec3 xColor;
uniform vec3 yColor;
uniform vec3 zColor;
uniform float opacity;
Fragment getFragment() {
Fragment frag;
// We compare against a small value as the first vertex doesn't have a positional
// information (or rather it is 0) and we don't want to miss out on the color close to
// the origin
vec3 colorComponents = step(2e-32, vs_positionModelSpace);
frag.color.rgb = colorComponents.x * xColor +
colorComponents.y * yColor +
colorComponents.z * zColor;
frag.color.a = opacity;
frag.depth = vs_screenSpaceDepth;
frag.gPosition = vs_positionViewSpace;
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
return frag;
}