mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-27 14:39:20 -06:00
Added pre-computation as a debuggin tool in GUI.
This commit is contained in:
@@ -10,6 +10,31 @@ function preInitialization()
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime(openspace.time.currentWallTime())
|
||||
|
||||
--YYYY-MM-DDTHH:MN:SS
|
||||
--openspace.time.setTime(openspace.time.currentWallTime())
|
||||
--[[
|
||||
-- March 9, 2016 total eclipse times from land
|
||||
-- Palembang, South Sumatra, Indonesia
|
||||
-- Partial solar eclipse begins: 6:20 a.m. local Western Indonesian Time
|
||||
-- Total solar eclipse begins: 7:20 a.m. local time
|
||||
-- Maximum eclipse: 7:21 a.m. local time
|
||||
-- Total solar eclipse ends: 7:22 a.m. local time
|
||||
-- Partial solar eclipse ends: 8:31 a.m. local time
|
||||
|
||||
-- 6:20 -> 23:20 day before in UTC
|
||||
]]--
|
||||
|
||||
openspace.time.setTime("2016-03-08T22:45:00")
|
||||
|
||||
-- Total Lunar Eclipse Jan 31, 2018 at 10:51:13 UTC
|
||||
-- Regions seeing, at least, some parts of the eclipse: North/East Europe,
|
||||
-- Asia, Australia, North/East Africa, North America, North/East South America,
|
||||
-- Pacific, Atlantic, Indian Ocean, Arctic, Antarctica.
|
||||
--openspace.time.setTime("2018-01-31T10:30:00")
|
||||
|
||||
|
||||
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
end
|
||||
|
||||
@@ -49,6 +74,7 @@ return {
|
||||
Modules = {
|
||||
"sun",
|
||||
"atmosphereearth",
|
||||
"moon",
|
||||
--"earth",
|
||||
"stars",
|
||||
--"stars-denver",
|
||||
|
||||
@@ -23,14 +23,14 @@ return {
|
||||
Body = "EARTH",
|
||||
Geometry = {
|
||||
Type = "SimpleSphere",
|
||||
Radius = { 6.371, 6 },
|
||||
Radius = { 6.3781366, 6 },
|
||||
Segments = 100
|
||||
},
|
||||
Shadow_Group = {
|
||||
Source1 = {
|
||||
Name = "Sun",
|
||||
-- All radius in meters
|
||||
Radius = {696.3, 6}
|
||||
Radius = {696.0, 6}
|
||||
},
|
||||
--Source2 = { Name = "Monolith", Radius = {0.01, 6} },
|
||||
Caster1 = {
|
||||
@@ -44,7 +44,7 @@ return {
|
||||
Type = "simple",
|
||||
Color = "textures/earth_bluemarble.jpg",
|
||||
Night = "textures/earth_night.jpg",
|
||||
--Height = "textures/earth_bluemarble_height.jpg",
|
||||
Height = "textures/earth_bluemarble_height.jpg",
|
||||
-- Depth = "textures/earth_depth.png",
|
||||
Reflectance = "textures/earth_reflectance.png",
|
||||
Clouds = "textures/earth_clouds.jpg"
|
||||
@@ -54,7 +54,8 @@ return {
|
||||
AtmoshereRadius = 6420,
|
||||
--AtmoshereRadius = 6390,
|
||||
--PlanetRadius = 6371,
|
||||
PlanetRadius = 6360,
|
||||
--PlanetRadius = 6360,
|
||||
PlanetRadius = 6378.1366,
|
||||
PlanetAverageGroundReflectance = 0.1,
|
||||
Rayleigh = {
|
||||
Coefficients = {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -118,9 +118,11 @@ private:
|
||||
void createComputationTextures();
|
||||
void deleteComputationTextures();
|
||||
void deleteUnusedComputationTextures();
|
||||
void updateAtmosphereParameters();
|
||||
void loadAtmosphereDataIntoShaderProgram(std::unique_ptr<ghoul::opengl::ProgramObject> & shaderProg);
|
||||
void executeCalculations(const GLuint vao, const GLenum drawBuffers[2], const GLsizei vertexSize);
|
||||
void executeCalculations(const GLuint vao, const GLenum drawBuffers[1], const GLsizei vertexSize);
|
||||
void preCalculateAtmosphereParam();
|
||||
void resetAtmosphereTextures(const GLuint vao, const GLenum drawBuffers[1], const GLsizei vertexSize);
|
||||
void createAtmosphereFBO();
|
||||
void createRenderQuad(GLuint * vao, GLuint * vbo, const GLfloat size);
|
||||
void renderQuadForCalc(const GLuint vao, const GLsizei size);
|
||||
@@ -149,6 +151,7 @@ private:
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _deltaJProgramObject;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _atmosphereProgramObject;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _deferredAtmosphereProgramObject;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _cleanTextureProgramObject;
|
||||
ghoul::opengl::TextureUnit _dummyTextureUnit;
|
||||
ghoul::opengl::TextureUnit _transmittanceTableTextureUnit;
|
||||
ghoul::opengl::TextureUnit _irradianceTableTextureUnit;
|
||||
@@ -180,9 +183,21 @@ private:
|
||||
properties::FloatProperty _heightExaggeration;
|
||||
|
||||
planetgeometry::PlanetGeometry* _geometry;
|
||||
planetgeometry::PlanetGeometry* _atmosphereGeometry;
|
||||
properties::BoolProperty _performShading;
|
||||
properties::IntProperty _rotation;
|
||||
|
||||
|
||||
// ATMOSPHERE PROPERTIES
|
||||
properties::FloatProperty _atmosphereHeightP;
|
||||
properties::FloatProperty _groundAverageReflectanceP;
|
||||
properties::FloatProperty _rayleighHeightScaleP;
|
||||
properties::FloatProperty _mieHeightScaleP;
|
||||
properties::FloatProperty _mieScatteringCoefficientP;
|
||||
properties::FloatProperty _mieScatteringExtinctionPropCoefficientP;
|
||||
properties::FloatProperty _mieAsymmetricFactorGP;
|
||||
|
||||
|
||||
// DEBUG Properties:
|
||||
properties::BoolProperty _saveDeferredFramebuffer;
|
||||
|
||||
|
||||
@@ -456,10 +456,15 @@ Fragment getFragment() {
|
||||
vec4 viewport = vec4(screenX, screenY, screenWIDTH, screenHEIGHT);
|
||||
vec4 ndcPos;
|
||||
ndcPos.xy = ((2.0 * gl_FragCoord.xy) - (2.0 * viewport.xy)) / (viewport.zw) - 1;
|
||||
ndcPos.z = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far) /
|
||||
//ndcPos.x = ((2.0f * gl_FragCoord.x) - (2.0f * viewport.x)) / viewport.z - 1.0f;
|
||||
//ndcPos.y = 1.0f - (2.0f * gl_FragCoord.y) / viewport.w;
|
||||
ndcPos.z = (2.0f * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far) /
|
||||
(gl_DepthRange.far - gl_DepthRange.near);
|
||||
ndcPos.w = 1.0;
|
||||
ndcPos.w = 1.0f;
|
||||
vec4 clipPos = ndcPos / gl_FragCoord.w;
|
||||
//vec4 clipPos = ndcPos;
|
||||
//clipPos.z = -1.0;
|
||||
//clipPos.w = 1.0;
|
||||
vec4 projCoords = projInverse * clipPos;
|
||||
vec4 viewDirection = normalize(completeInverse * vec4(projCoords.xyz, 0.0));
|
||||
vec3 v = normalize(viewDirection.xyz);
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
uniform mat4 NormalTransform;
|
||||
uniform sampler2D heightTex;
|
||||
uniform bool _hasHeightMap;
|
||||
uniform float _heightExaggeration;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
layout(location = 1) in vec2 in_st;
|
||||
@@ -68,9 +71,16 @@ void main()
|
||||
vs_posWorld = conv;
|
||||
|
||||
vs_position = tmp;
|
||||
|
||||
if (_hasHeightMap) {
|
||||
float height = texture(heightTex, in_st).r;
|
||||
vec3 displacementDirection = abs(normalize(in_normal.xyz));
|
||||
float displacementFactor = height * _heightExaggeration;
|
||||
position.xyz = position.xyz + displacementDirection * displacementFactor;
|
||||
}
|
||||
|
||||
// Now the position is transformed from view coordinates to SGCT projection
|
||||
// coordinates.
|
||||
position = ViewProjection * position;
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
}
|
||||
|
||||
30
modules/base/shaders/texture_clean_fs.glsl
Normal file
30
modules/base/shaders/texture_clean_fs.glsl
Normal file
@@ -0,0 +1,30 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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__
|
||||
|
||||
out vec4 renderTableColor;
|
||||
|
||||
void main(void) {
|
||||
renderTableColor = vec4(0.0);
|
||||
}
|
||||
31
modules/base/shaders/texture_clean_vs.glsl
Normal file
31
modules/base/shaders/texture_clean_vs.glsl
Normal file
@@ -0,0 +1,31 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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 in_position;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(in_position, 1.0);
|
||||
}
|
||||
@@ -54,13 +54,13 @@ float opticalDepth(const float r, const float mu, const float scaleHeight) {
|
||||
|
||||
float r2 = r*r;
|
||||
// Is ray below horizon?
|
||||
// cosine law for triangles: y_i^2 = a^2 + b^2 - 2abcos(alpha)
|
||||
// cosine law for triangles: y_i^2 = a^2 + b^2 - 2abcos(alpha)
|
||||
float cosZenithHorizon = -sqrt(1.0 - ((Rg*Rg)/r2));
|
||||
if (mu < cosZenithHorizon)
|
||||
return 1e9;
|
||||
|
||||
// Integrating using the Trapezoidal rule:
|
||||
// Integral(f(y)dy)(from a to b) = (b-a)/2n_steps*(Sum(f(y_i+1)+f(y_i)))
|
||||
// Integral(f(y)dy)(from a to b) = ((b-a)/2n_steps)*(Sum(f(y_i+1)+f(y_i)))
|
||||
float b_a = rayDistance(r, mu);
|
||||
float deltaStep = b_a / float(TRANSMITTANCE_STEPS);
|
||||
// cosine law
|
||||
@@ -100,4 +100,4 @@ void main(void) {
|
||||
vec3 depth = betaMEx * opticalDepth(r, mu, HM) + betaR * opticalDepth(r, mu, HR);
|
||||
|
||||
renderTableColor = vec4(exp(-depth), 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user