Files
OpenSpace/modules/space/shaders/keplerpoints_vs.glsl
Adam Rohdin 57f2705157 feature/multithreaded-asteroids (#3799)
- Added multithreading and a better system for updating which segments to render for each orbit
- Less work is being done while time is paused
- Added multithreading for loading of data
- Added support for "Camera View Direction" in addition to existing "Camera Position Normal"
2025-10-14 16:46:52 +02:00

53 lines
2.9 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. *
****************************************************************************************/
#version __CONTEXT__
layout (location = 0) in vec3 vertexData; // 1: x, 2: y, 3: z
layout (location = 1) in dvec3 orbitData; // 1: timeOffset, 2: epoch, 3: period
uniform double inGameTime;
flat out float currentRevolutionFraction;
flat out float vertexRevolutionFraction;
void main() {
double timeOffset = orbitData.x;
double epoch = orbitData.y;
double period = orbitData.z;
// calculate nr of periods, get fractional part to know where the vertex closest to the
// debris part is right now
double numOfRevolutions = (inGameTime - epoch) / period;
currentRevolutionFraction = float(numOfRevolutions - double(int(numOfRevolutions)));
if (currentRevolutionFraction < 0.0) {
currentRevolutionFraction += 1.0;
}
// Same procedure for the current vertex
vertexRevolutionFraction = float(timeOffset / period);
gl_Position = vec4(vertexData.xyz, 1.0);
}