Merge branch 'develop' into plutoViz

Conflicts:
	include/openspace/rendering/planets/simplespheregeometry.h
	include/openspace/util/powerscaledsphere.h
	openspace.cfg
	shaders/pscstandard_fs.glsl
	src/engine/openspaceengine.cpp
	src/rendering/planets/renderableplanet.cpp
	src/rendering/renderablefov.cpp
	src/rendering/renderabletrail.cpp
	src/rendering/renderengine.cpp
	src/scenegraph/scenegraph.cpp
This commit is contained in:
Joakim Kilby
2015-02-18 15:52:35 +01:00
167 changed files with 5615 additions and 3792 deletions
@@ -34,8 +34,7 @@ out vec4 vs_position;
#include "PowerScaling/powerScaling_vs.hglsl"
void main()
{
void main() {
vec4 tmp = vec4(in_position, exponent);
vs_position = tmp;
+79
View File
@@ -0,0 +1,79 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* 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__
uniform float time;
uniform sampler2D texture1;
uniform float alpha;
in vec2 vs_st;
in vec4 vs_position;
#include "ABuffer/abufferStruct.hglsl"
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "PowerScaling/powerScaling_fs.hglsl"
void main()
{
vec4 position = vs_position;
// This has to be fixed with the ScaleGraph in place (precision deficiency in depth buffer) ---abock
// float depth = pscDepth(position);
float depth = 1000.0;
vec4 diffuse;
vec2 texCoord = vs_st;
texCoord.s = 1 - texCoord.s;
texCoord.t = 1 - texCoord.y;
// if(gl_FrontFacing)
diffuse = texture(texture1, texCoord);
// else
// diffuse = texture(texture1, vec2(1-vs_st.s,vs_st.t));
diffuse.a *= alpha;
//vec4 diffuse = vec4(1,vs_st,1);
//vec4 diffuse = vec4(1,0,0,1);
// if(position.w > 9.0) {
// diffuse = vec4(1,0,0,1);
// }
// #if 0
// diffuse = vec4(vs_position.xyz / 10, 1.0);
// #else
// // if (abs(vs_st.r - 0.75) <= 0.01 && abs(vs_st.g - 0.5) <= 0.01)
// if (abs(vs_st.g - 0.5) <= 0.01)
// diffuse = vec4(vec2(vs_st), 0.0, 1.0);
// else
// diffuse = vec4(0.0);
// #endif
// diffuse = vec4(1.0, 0.0, 0.0, 1.0);
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
}
+57
View File
@@ -0,0 +1,57 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* 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__
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
layout(location = 0) in vec4 in_position;
layout(location = 1) in vec2 in_st;
out vec2 vs_st;
out vec4 vs_position;
out float s;
#include "PowerScaling/powerScaling_vs.hglsl"
void main()
{
vec4 tmp = in_position;
mat4 mt = ModelTransform;
mt = mat4(0, -1, 0, 0,
1, 0, 0, 0,
0, 0, -1, 0,
0, 0, 0, 1) * mt;
vec4 position = pscTransform(tmp, mt);
vs_position = in_position;
vs_st = in_st;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}
+27 -18
View File
@@ -41,8 +41,6 @@ layout(location = 2) in vec3 ge_velocity;
layout(location = 3) in float ge_speed;
layout(location = 4) in vec2 texCoord;
#include "ABuffer/abufferStruct.hglsl"
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "PowerScaling/powerScaling_fs.hglsl"
@@ -62,7 +60,7 @@ void main() {
vec4 color = vec4(0.0);
switch (colorOption) {
case COLOROPTION_COLOR:
color = bv2rgb(ge_brightness[0].x);
color = bv2rgb(ge_brightness.x);
break;
case COLOROPTION_VELOCITY:
color = vec4(abs(ge_velocity), 0.5);
@@ -73,25 +71,36 @@ void main() {
break;
}
// These can be removed once we get a better star psf texture ---abock
vec4 textureColor = texture(psfTexture, texCoord);
// textureColor.a = (textureColor.a - 0.25) / (0.85);
// color.rgb = 1/ color.rgb;
// color.a = 1-color.a;
framebuffer_output_color = texture(psfTexture, texCoord) * color;
// framebuffer_output_color = vec4(1.0, 0.0, 0.0, 1.0);
vec4 fullColor = vec4(color.rgb, textureColor.a);
// vec4 fullColor = textureColor * color;
// if (fullColor.a <= 0.125)
// discard;
// framebuffer_output_color = vec4(ge_velocity, 1.0);
float M = ge_brightness.z;
// if (M > 10)
// discard;
float targetM = 6;
float maxM = 14.0;
if (M > targetM) {
float alpha = (M - targetM) / (maxM - targetM);
fullColor.a *= alpha;
//diffuse = vec4(1,1,0,1);
///diffuse = vec4(Color, 1.0);
}
// if (ge_brightness.z > 7.0)
// discard;
vec4 position = vs_position;
float depth = pscDepth(position);
gl_FragDepth = depth;
// This has to be fixed when the scale graph is in place ---abock
float depth = pscDepth(position) + 1000;
// float depth = 10000.0;
// gl_FragDepth = depth;
//ABufferStruct_t frag = createGeometryFragment(vec4(1,0,0,1), position, depth);
//ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
//addToBuffer(frag);
//discard;
ABufferStruct_t frag = createGeometryFragment(fullColor, position, depth);
addToBuffer(frag);
// discard;
}
+119 -49
View File
@@ -26,9 +26,9 @@
const vec2 corners[4] = vec2[4](
vec2(0.0, 1.0),
vec2(0.0, 0.0),
vec2(1.0, 1.0),
vec2(1.0, 0.0)
vec2(0.0, 0.0),
vec2(1.0, 1.0),
vec2(1.0, 0.0)
);
#include "PowerScaling/powerScalingMath.hglsl"
@@ -49,56 +49,126 @@ layout(location = 2) out vec3 ge_velocity;
layout(location = 3) out float ge_speed;
layout(location = 4) out vec2 texCoord;
uniform mat4 projection; // we do this after distance computation.
uniform mat4 projection;
uniform float spriteSize;
uniform vec2 magnitudeClamp;
uniform float exponentialOffset;
uniform float exponentialDampening;
uniform float scaleFactor;
// As soon as the scalegraph is in place, replace this by a dynamic calculation
// of apparent magnitude in relation to the camera position ---abock
void main() {
ge_brightness = vs_brightness[0];
ge_velocity = vs_velocity[0];
ge_speed = vs_speed[0];
/// --- distance modulus --- NOT OPTIMIZED YET.
// float M = vs_brightness[0][0]; // get ABSOLUTE magnitude (x param)
float M = vs_brightness[0].z; // if NOT running test-target.
vec4 cam = vec4(-cam_position[0].xyz, cam_position[0].w); // get negative camera position
vec4 pos = psc_position[0]; // get OK star position
vec4 result = psc_addition(pos, cam); // compute vec from camera to position
float x, y, z, w;
x = result[0];
y = result[1];
z = result[2];
w = result[3];
// Skip the Sun
if (psc_position[0].x == 0.0 && psc_position[0].y == 0.0 && psc_position[0].z == 0.0) {
return;
}
ge_brightness = vs_brightness[0];
ge_velocity = vs_velocity[0];
ge_speed = vs_speed[0];
vec2 pc = vec2(length(result.xyz), result[3]);
float M = vs_brightness[0].z;
// @Check conversion is also done in the cpp file ---abock
pc[0] *= 0.324077929f; // convert meters -> parsecs
pc[1] += -18.0f;
float pc_psc = pc[0] * pow(10, pc[1]); // psc scale out
float apparent = -(M - 5.0f * (1.f - log10(pc_psc))); // get APPARENT magnitude.
// M = clamp(M, 1.0, 4.0);
M = clamp(M, magnitudeClamp[0], magnitudeClamp[1]);
// float modifiedSpriteSize = exp((-5 - M) * 0.871);
float modifiedSpriteSize = exp((-exponentialOffset - M) * exponentialDampening) * scaleFactor;
for(int i = 0; i < 4; i++){
vec4 p1 = gl_in[0].gl_Position;
p1.xy += vec2(modifiedSpriteSize * (corners[i] - vec2(0.5)));
vs_position = p1;
gl_Position = projection * p1;
// gl_Position = z_normalization(projection * p1);
texCoord = corners[i];
EmitVertex();
}
EndPrimitive();
}
// Old method, still in the code for reference ---abock
#if 0
void main() {
ge_brightness = vs_brightness[0];
ge_velocity = vs_velocity[0];
ge_speed = vs_speed[0];
// float M = vs_brightness[0][0]; // get ABSOLUTE magnitude (x param)
float M = vs_brightness[0].z; // if NOT running test-target.
// We are using a fixed position until the scalegraph is implemented ---abock
// vec4 cam = vec4(-cam_position[0].xyz, cam_position[0].w); // get negative camera position
// vec4 cam = vec4(0.0);
vec4 pos = psc_position[0]; // get OK star position
// vec4 result = psc_addition(pos, cam); // compute vec from camera to position
vec4 result = pos;
vec2 pc = vec2(
length(result.xyz),
result.w
);
// convert meters into parsecs
// pc[0] *= 0.324077929f;
// pc[1] -= 18.0f;
float distLog = log10(pc[0]) + pc[1];
float apparent = (M - 5.f * (1.f - distLog));
// p = vec4(vec3(apparent), 1.0);
vec4 P = gl_in[0].gl_Position;
float weight = 0.00001f; // otherwise this takes over.
float depth = pc[0] * pow(10, pc[1]);
depth *= pow(apparent,3);
// check everything below this ---abock
float weight = 0.000025f; // otherwise this takes over.
double depth = pc[0] * pow(10, pc[1]);
depth *= pow(apparent,3);
//float modifiedSpriteSize = spriteSize + (depth*weight);
float modifiedSpriteSize = 0.0005 + (depth*weight);
// EMIT QUAD
for(int i = 0; i < 4; i++){
vec4 p1 = P;
p1.xy += modifiedSpriteSize *(corners[i] - vec2(0.5));
vs_position = p1;
gl_Position = projection * p1;
// gl_Position = z_normalization(projection * p1);
texCoord = corners[i];
EmitVertex();
}
EndPrimitive();
}
double modifiedSpriteSize = (spriteBaseSize * 0.0005f) + (depth*weight);
modifiedSpriteSize *= spriteResponseSize;
// // modifiedSpriteSize = min(modifiedSpriteSize, -0.0025f);
// {
// vec4 p = gl_in[0].gl_Position;
// p.xy += vec2(modifiedSpriteSize * (corners[1] - vec2(0.5)));
// p = projection * p;
// vec4 q = gl_in[0].gl_Position;
// q.xy += vec2(modifiedSpriteSize * (corners[2] - vec2(0.5)));
// q = projection * q;
// if (length(p.xyz-q.xyz) < 0.025)
// return;
// // if (sin(dot(p,q)) < 0.1)
// // return;
// }
// if (depth < -0.00000001)
// return;
// float distLy = vs_brightness[0].w;
// float distParsec = distLy * 0.306594845;
// if (distParsec > 200 && -apparent > 1.0)
// return;
for(int i = 0; i < 4; i++){
vec4 p1 = gl_in[0].gl_Position;
// vec4 p1 = psc_position[0];
p1.w = 1.0;
// p1.w = 1.0;
p1.xy += vec2(modifiedSpriteSize * (corners[i] - vec2(0.5)));
vs_position = p1;
gl_Position = projection * p1;
// gl_Position = p1;
// if (modifiedSpriteSize > -0.001f)
// texCoord = vec2(0.5);
// else
texCoord = corners[i];
EmitVertex();
}
EndPrimitive();
}
#endif
+6 -4
View File
@@ -42,17 +42,19 @@ layout(location = 4) out vec4 cam_position;
#include "PowerScaling/powerScaling_vs.hglsl"
void main() {
psc_position = in_position;
vec4 p = in_position;
psc_position = p;
vs_brightness = in_brightness;
vs_velocity = in_velocity;
vs_speed = in_speed;
cam_position = campos;
vec4 tmp = in_position;
vec4 tmp = p;
vec4 position = pscTransform(tmp, mat4(1.0));
// vec4 position = pscTransform(tmp, model);
// psc_position = tmp;
position = model * view * position;
position = view * position;
// position = ViewProjection * ModelTransform * position;
// gl_Position = z_normalization(position);
gl_Position = position;
gl_Position = position;
}
@@ -24,33 +24,21 @@
#version __CONTEXT__
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
in vec4 vs_point_position;
in vec4 vs_point_velocity;
in float fade;
//out vec4 diffuse;
uniform vec3 color;
#include "ABuffer/abufferStruct.hglsl"
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "PowerScaling/powerScaling_fs.hglsl"
void main()
{
void main() {
vec4 position = vs_point_position;
float depth = pscDepth(position);
vec4 position = vs_point_position;
float depth = pscDepth(position);
// set the depth
//gl_FragDepth = depth;
//float l = length(vs_point_velocity);
vec4 diffuse = vs_point_velocity;
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
vec4 c = vec4(color, fade);
ABufferStruct_t frag = createGeometryFragment(c, position, depth);
addToBuffer(frag);
}
@@ -26,53 +26,26 @@
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
//uniform vec4 etColor;
uniform vec4 objectVelocity;
layout(location = 0) in vec4 in_point_position;
layout(location = 1) in vec4 in_point_velocity;
layout(location = 2) in vec2 in_point_timeindex;
out vec4 vs_point_position;
out vec4 vs_point_velocity;
out float fade;
uniform uint nVertices;
uniform float lineFade;
#include "PowerScaling/powerScaling_vs.hglsl"
void main()
{
vs_point_velocity = in_point_velocity;
void main() {
float id = float(gl_VertexID) / float(nVertices * lineFade);
fade = 1.0 - id;
vec4 tmp = in_point_position;
vec4 position = pscTransform(tmp, ModelTransform);
vs_point_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
/*
//vs_point_position = objpos;
// rotate and scale vertex with model transform and add the translation
vec3 local_vertex_pos = mat3(ModelTransform) * in_point_position.xyz;
//vec4 lvp = ModelTransform * in_point_position;
// PSC addition; local vertex position and the object power scaled world position
vs_point_position = psc_addition(vec4(local_vertex_pos,in_point_position.w),objpos);
//vs_point_position = psc_addition(lvp,objpos);
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
vs_point_position = psc_addition(vs_point_position,vec4(-campos.xyz,campos.w));
// rotate the camera
local_vertex_pos = mat3(camrot) * vs_point_position.xyz;
vs_point_position = vec4(local_vertex_pos, vs_point_position.w);
//vs_point_position = camrot* vs_point_position;
// project using the rescaled coordinates,
//vec4 vs_point_position_rescaled = psc_scaling(vs_point_position, scaling);
vec4 vs_point_position_rescaled = psc_to_meter(vs_point_position, scaling);
//vs_point_position = vs_point_position_rescaled;
// project the position to view space
gl_Position = ViewProjection * vs_point_position_rescaled;
*/
}
+34 -32
View File
@@ -28,7 +28,7 @@ uniform vec4 campos;
uniform vec4 objpos;
//uniform vec3 camdir; // add this for specular
uniform vec3 sun_pos;
uniform bool _performShading = true;
uniform int shadows;
@@ -49,37 +49,39 @@ void main()
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse = texture(texture1, vs_st);
// directional lighting
vec3 origin = vec3(0.0);
vec4 spec = vec4(0.0);
vec3 n = normalize(vs_normal.xyz);
//vec3 e = normalize(camdir);
vec3 l_pos = sun_pos; // sun.
vec3 l_dir = normalize(l_pos-objpos.xyz);
float intensity = min(max(5*dot(n,l_dir), 0.3), 1);
float shine = 0.0001;
vec4 specular = vec4(0.5);
vec4 ambient = vec4(0.0,0.0,0.0,1);
/*
if(intensity > 0.f){
// halfway vector
vec3 h = normalize(l_dir + e);
// specular factor
float intSpec = max(dot(h,n),0.0);
spec = specular * pow(intSpec, shine);
if (_performShading) {
// directional lighting
vec3 origin = vec3(0.0);
vec4 spec = vec4(0.0);
vec3 n = normalize(vs_normal.xyz);
//vec3 e = normalize(camdir);
vec3 l_pos = vec3(0.0); // sun.
vec3 l_dir = normalize(l_pos-objpos.xyz);
float intensity = min(max(5*dot(n,l_dir), 0.0), 1);
float shine = 0.0001;
vec4 specular = vec4(0.5);
vec4 ambient = vec4(0.0,0.0,0.0,1);
/*
if(intensity > 0.f){
// halfway vector
vec3 h = normalize(l_dir + e);
// specular factor
float intSpec = max(dot(h,n),0.0);
spec = specular * pow(intSpec, shine);
}
*/
diffuse = max(intensity * diffuse, ambient);
//diffuse = vec4(1);
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
}
else {
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
}
*/
vec4 tmpdiff = diffuse;
tmpdiff[3] = 1;
if(shadows == 1)
diffuse = max(intensity * diffuse, ambient);
//diffuse[3] = 0.6f;
//diffuse = vec4(1);
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
}