Working OS X version

This commit is contained in:
Jonas Strandstedt
2014-10-31 15:37:03 +01:00
parent 83bebbd60f
commit a96e32badb
34 changed files with 87 additions and 111 deletions

2
.gitignore vendored
View File

@@ -8,7 +8,7 @@ ext/SGCT
# generated glsl files
*.gglsl
*.OpenSpaceGenerated.glsl
*.GhoulGenerated.glsl
shaders/generated/*
# CMake stuff

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/constants.hglsl>:notrack
#ifndef APPLE
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
@@ -43,7 +41,18 @@ layout (binding = 1, rgba32ui) uniform uimageBuffer fragmentTexture;
#endif
ABufferStruct_t createGeometryFragment(vec4 fragColor, vec4 position, float z = gl_FragCoord.z) {
layout(location = 0) out vec4 framebuffer_output_color;
ABufferStruct_t createGeometryFragment(vec4 fragColor, vec4 position) {
ABufferStruct_t frag;
_col_(frag, fragColor);
_z_(frag, gl_FragCoord.z);
_type_(frag, 0);
_pos_(frag, position);
return frag;
}
ABufferStruct_t createGeometryFragment(vec4 fragColor, vec4 position, float z) {
ABufferStruct_t frag;
_col_(frag, fragColor);
_z_(frag, z);
@@ -54,7 +63,7 @@ ABufferStruct_t createGeometryFragment(vec4 fragColor, vec4 position, float z =
void addToBuffer(ABufferStruct_t frag) {
#if ABUFFER_IMPLEMENTATION == ABUFFER_NONE || defined(APPLE)
gl_FragColor = _col_(frag);
framebuffer_output_color = _col_(frag);
gl_FragDepth = _z_(frag);
#endif
#ifndef APPLE

View File

@@ -22,13 +22,11 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
// ================================================================================
// Settings
// ================================================================================
//#pragma openspace insert SETTINGS
#include <${SHADERS_GENERATED}/ABufferSettings.hglsl>:notrack
//#include <${SHADERS_GENERATED}/ABufferSettings.hglsl>:notrack
// Select type of depth calculations
#define PSCDEPTH 1

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
in vec4 position;
out vec2 texCoord;

View File

@@ -25,11 +25,7 @@
#ifndef ABUFFERSTRUCT_H_HGLSL
#define ABUFFERSTRUCT_H_HGLSL
// The different kinds of implementation, set from OpenSpace
// #define ABUFFER_SINGLE_LINKED 1
// #define ABUFFER_FIXED 2
// #define ABUFFER_DYNAMIC 3
// #define ABUFFER_IMPLEMENTATION ABUFFER_SINGLE_LINKED
#include <${SHADERS_GENERATED}/constants.hglsl>:notrack
//========================================================================================
// ABufferStruct_t declaration
@@ -129,9 +125,9 @@ void _col_(inout ABufferStruct_t frag, vec4 color) {
uint _type_(ABufferStruct_t frag) {
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
return bitextract_u(frag.id, mask_id_type, shift_id_type);
return bitextract_u(frag.id, mask_id_type, shift_id_type);
#else
return frag.id;
return frag.id;
#endif
}
void _type_(inout ABufferStruct_t frag, uint type) {

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 330
in vec4 color;
out vec4 outputColor;

View File

@@ -21,8 +21,6 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 330
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;

View File

@@ -21,8 +21,6 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
@@ -52,7 +50,5 @@ void main()
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
discard;
}

View File

@@ -21,8 +21,6 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform int volumeType;
in vec3 vPosition;
@@ -47,6 +45,4 @@ void main() {
_type_(frag, volumeType);
_pos_(frag, position);
addToBuffer(frag);
discard;
}

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
layout(location = 0) in vec4 vertPosition;
uniform mat4 modelViewProjection;

View File

@@ -1,9 +0,0 @@
#define SCREEN_WIDTH 1280
#define SCREEN_HEIGHT 720
#define MAX_LAYERS 32
#define ABUFFER_NONE 0
#define ABUFFER_SINGLE_LINKED 1
#define ABUFFER_FIXED 2
#define ABUFFER_DYNAMIC 3
#define ABUFFER_IMPLEMENTATION ABUFFER_SINGLE_LINKED
#define WIN32

View File

@@ -21,8 +21,6 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
@@ -71,7 +69,5 @@ void main()
//ABufferStruct_t frag = createGeometryFragment(vec4(1,0,0,1), position, depth);
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
discard;
}

View File

@@ -21,8 +21,6 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform float time;
uniform sampler2D texture1;
@@ -52,6 +50,4 @@ void main()
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
discard;
}

View File

@@ -21,7 +21,6 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform vec4 campos;
uniform vec4 objpos;
//uniform vec3 camdir; // add this for specular
@@ -75,6 +73,4 @@ void main()
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
discard;
}

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 330
uniform sampler2D quadTex;
in vec2 texCoord;
out vec4 color;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 330
layout(location = 0) in vec2 texCoordinate;
layout(location = 2) in vec3 vertPosition;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 330
in vec4 position;
out vec2 texCoord;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 400 core
// Based on http://prideout.net/blog/?p=64
uniform sampler3D texVolume;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 400 core
// Based on http://prideout.net/blog/?p=64
layout(points) in;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 400 core
// Based on http://prideout.net/blog/?p=64
layout(location = 0) in vec4 Position;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform sampler2D texture1;
uniform vec3 Color;
@@ -33,9 +31,6 @@ in vec2 texCoord;
layout(location = 2) in vec3 ge_brightness;
out vec4 diffuse;
#include "ABuffer/abufferStruct.hglsl"
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "PowerScaling/powerScaling_fs.hglsl"
@@ -75,7 +70,7 @@ void main(void)
vec4 color = bv2rgb(ge_brightness[0])/1.1;
// color.rgb = 1/ color.rgb;
// color.a = 1-color.a;
diffuse = texture2D(texture1, texCoord)*color;
framebuffer_output_color = texture(texture1, texCoord)*color;
//diffuse = vec4(1,1,0,1);
///diffuse = vec4(Color, 1.0);

View File

@@ -1,4 +1,27 @@
#version 440
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
uniform sampler2D texture1;
uniform vec3 Color;

View File

@@ -22,24 +22,22 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
const vec2 corners[4] = {
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)
};
);
#include "PowerScaling/powerScalingMath.hglsl"
in vec4 psc_position[];
in vec4 campos[];
in vec4 cam_position[];
layout(points) in;
//layout(points, max_vertices = 1) out;
layout(location = 2) in vec3 vs_brightness[];
layout(location = 2) out vec3 ge_brightness[];
layout(location = 2) out vec3 ge_brightness;
layout(triangle_strip, max_vertices = 4) out;
out vec2 texCoord;
@@ -50,13 +48,13 @@ uniform mat4 projection; // we do this after distance computation.
float spriteSize = 0.0000005f; // set here for now.
void main(){
ge_brightness[0] = vs_brightness[0]; // pass on to fragment shader.
ge_brightness = vs_brightness[0]; // pass on to fragment shader.
/// --- distance modulus --- NOT OPTIMIZED YET.
// float M = vs_brightness[0][0]; // get ABSOLUTE magnitude (x param)
float M = vs_brightness[0][2]; // if NOT running test-target.
vec4 cam = vec4(-campos[0].xyz, campos[0].w); // get negative camera position
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
@@ -69,7 +67,7 @@ void main(){
vec2 pc = vec2(sqrt(x*x +y*y + z*z), result[3]); // form vec2
pc[0] *= 0.324077929f; // convert meters -> parsecs
pc[1] += -18f;
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.

View File

@@ -1,4 +1,27 @@
#version 440
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
layout(points) in;
layout(points, max_vertices = 1) out; // Draw points
//layout(triangle_strip, max_vertices = 4) out; // Draw quads

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <${SHADERS_GENERATED}/version.hglsl>:notrack
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 400 core
uniform sampler2D texBack, texFront;
uniform sampler3D texVolume;
uniform float stepSize;

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version 400 core
layout(location = 0) in vec2 texCoordinate;
layout(location = 2) in vec3 vertPosition;

View File

@@ -98,12 +98,14 @@ bool RenderEngine::initialize()
_mainCamera->setScaling(glm::vec2(1.0, -8.0));
_mainCamera->setPosition(psc(0.f, 0.f, 1.499823f, 11.f));
OsEng.interactionHandler().setCamera(_mainCamera);
#ifndef __APPLE__
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
_abuffer = new ABufferSingleLinked();
#elif ABUFFER_IMPLEMENTATION == ABUFFER_FIXED
_abuffer = new ABufferFixed();
#elif ABUFFER_IMPLEMENTATION == ABUFFER_DYNAMIC
_abuffer = new ABufferDynamic();
#endif
#endif
return true;
}
@@ -176,9 +178,9 @@ bool RenderEngine::initializeGL()
}
_mainCamera->setMaxFov(maxFov);
}
#ifndef __APPLE__
_abuffer->initialize();
#endif
_log = new ScreenLog();
ghoul::logging::LogManager::ref().addLog(_log);
@@ -198,7 +200,9 @@ void RenderEngine::postSynchronizationPreDraw()
}
if (updateAbuffer) {
generateGlslConfig();
#ifndef __APPLE__
_abuffer->reinitialize();
#endif
}
// converts the quaternion used to rotation matrices
@@ -414,20 +418,10 @@ void RenderEngine::generateGlslConfig() {
// TODO: Make this file creation dynamic and better in every way
// TODO: If the screen size changes it is enough if this file is regenerated to
// recompile all necessary files
std::ofstream os_version(absPath("${SHADERS_GENERATED}/version.hglsl"));
#ifdef __APPLE__
os_version << "#version 410\n";
#else
os_version << "#version 430\n";
#endif
os_version.close();
std::ofstream os(absPath("${SHADERS_GENERATED}/constants.hglsl"));
os << "#define SCREEN_WIDTH " << xSize << "\n"
os << "#ifndef CONSTANTS_HGLSL\n"
<< "#define CONSTANTS_HGLSL\n"
<< "#define SCREEN_WIDTH " << xSize << "\n"
<< "#define SCREEN_HEIGHT " << ySize << "\n"
<< "#define MAX_LAYERS " << ABuffer::MAX_LAYERS << "\n"
<< "#define ABUFFER_NONE 0\n"
@@ -445,6 +439,7 @@ void RenderEngine::generateGlslConfig() {
#ifdef __linux__
os << "#define linux\n";
#endif
os << "#endif\n";
os.close();
}

View File

@@ -260,8 +260,9 @@ void SceneGraph::update(const UpdateData& data)
_sceneGraphToLoad = "";
if (!success)
return;
#ifndef __APPLE__
OsEng.renderEngine().abuffer()->invalidateABuffer();
#endif
}
for (auto node : _nodes)
node->update(data);