mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-06 04:18:36 -06:00
moved fade calculations to frag shader
This commit is contained in:
committed by
ElonOlsson
parent
d0c78b544a
commit
fe5600e3c3
@@ -25,9 +25,9 @@
|
||||
#include "fragment.glsl"
|
||||
#include "floatoperations.glsl"
|
||||
|
||||
//layout(location = 0) in vec4 vertex; // 1: x, 2: y, 3: z, 4: time
|
||||
layout(location = 0) in vec4 vertex; // 1: x, 2: y, 3: z, 4: time
|
||||
// This doesn't work, plz help
|
||||
//layout(location = 1) in vec2 orbit; // 1: epoch, 2: period
|
||||
layout(location = 1) in vec2 orbit; // 1: epoch, 2: period
|
||||
|
||||
uniform vec3 color;
|
||||
uniform float opacity = 1.0;
|
||||
@@ -41,7 +41,7 @@ in vec4 viewSpacePosition;
|
||||
in vec4 vs_position;
|
||||
//in float nrOfPeriods;
|
||||
//in float offsetPeriods;
|
||||
in float fade;
|
||||
//in float fade;
|
||||
//in vec3 vs_color;
|
||||
//in vec2 vs_texcoord;
|
||||
|
||||
|
||||
@@ -34,49 +34,49 @@ layout (location = 0) in vec4 vertex_data; // 1: x, 2: y, 3: z, 4: time
|
||||
layout (location = 1) in vec2 orbit_data; // 1: epoch, 2: period
|
||||
|
||||
|
||||
//layout(location = 0) out vec4 vertex_data; // 1: x, 2: y, 3: z, 4: time
|
||||
layout(location = 0) out vec4 vertex; // 1: x, 2: y, 3: z, 4: time
|
||||
// This doesn't work, plz help
|
||||
//layout(location = 1) out vec2 orbit_data; // 1: epoch, 2: period
|
||||
layout(location = 1) out vec2 orbit; // 1: epoch, 2: period
|
||||
|
||||
|
||||
uniform dmat4 modelViewTransform;
|
||||
uniform mat4 projectionTransform;
|
||||
|
||||
//uniform int numberOfSegments;
|
||||
uniform float lineFade;
|
||||
//uniform float lineFade;
|
||||
//uniform vec3 debrisPosition;
|
||||
//uniform int* VertexIDs;
|
||||
//uniform int numberOfOrbits;
|
||||
uniform float inGameTime;
|
||||
//uniform float inGameTime;
|
||||
|
||||
out vec4 viewSpacePosition;
|
||||
out vec4 vs_position;
|
||||
//out float nrOfPeriods;
|
||||
//out float offsetPeriods;
|
||||
out float fade;
|
||||
//out float fade;
|
||||
|
||||
void main() {
|
||||
|
||||
// calculate nr of periods, get fractional part to know where
|
||||
// the vertex closest to the debris part is right now
|
||||
float nrOfPeriods = (inGameTime - orbit_data.x) / orbit_data.y;
|
||||
float periodFraction = fract(nrOfPeriods); //mod(nrOfPeriods, 1.0);
|
||||
//float nrOfPeriods = (inGameTime - orbit_data.x) / orbit_data.y;
|
||||
//float periodFraction = fract(nrOfPeriods); //mod(nrOfPeriods, 1.0);
|
||||
|
||||
// same procedure for the current vertex
|
||||
float offsetPeriods = vertex_data.w / orbit_data.y;
|
||||
float offsetFraction = offsetPeriods; //mod(offsetPeriods, 1.0);
|
||||
//float offsetPeriods = vertex_data.w / orbit_data.y;
|
||||
//float offsetFraction = offsetPeriods; //mod(offsetPeriods, 1.0);
|
||||
|
||||
// check difference of these two locations
|
||||
float vertexDistance = periodFraction - offsetFraction;
|
||||
//float vertexDistance = periodFraction - offsetFraction;
|
||||
|
||||
if(vertexDistance < 0.0) {
|
||||
vertexDistance += 1.0;
|
||||
}
|
||||
//if(vertexDistance < 0.0) {
|
||||
// vertexDistance += 1.0;
|
||||
//}
|
||||
|
||||
// int vertexID = gl_VertexID;
|
||||
// float id = float(vertexID) / float(numberOfSegments*numberOfOrbits);
|
||||
|
||||
float test = 1.0 - vertexDistance; // * lineFade;
|
||||
//float test = 1.0 - vertexDistance; // * lineFade;
|
||||
// if (test < 1.0 ) {
|
||||
// test = 0.4;
|
||||
// }
|
||||
@@ -84,7 +84,7 @@ void main() {
|
||||
// test = 1.0;
|
||||
// }
|
||||
|
||||
fade = clamp(test * lineFade, 0.0, 1.0) ;
|
||||
//fade = clamp(test * lineFade, 0.0, 1.0) ;
|
||||
|
||||
//fade = 0.5 * lineFade;
|
||||
|
||||
@@ -94,6 +94,8 @@ void main() {
|
||||
// int offset = VertexIDs[orbit] - gl_VertexID
|
||||
// to know the direction of the debris
|
||||
// if(debrisPosition == vs_position)
|
||||
vertex = vertex_data;
|
||||
orbit = orbit_data;
|
||||
|
||||
viewSpacePosition = vec4(modelViewTransform * dvec4(vertex_data.xyz, 1));
|
||||
vs_position = z_normalization( projectionTransform * viewSpacePosition);
|
||||
|
||||
Reference in New Issue
Block a user