mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
Merged master.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# #
|
||||
# OpenSpace #
|
||||
# #
|
||||
# Copyright (c) 2014-2018 #
|
||||
# Copyright (c) 2014-2019 #
|
||||
# #
|
||||
# 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 #
|
||||
@@ -27,9 +27,9 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
project(OpenSpace)
|
||||
|
||||
set(OPENSPACE_VERSION_MAJOR 0)
|
||||
set(OPENSPACE_VERSION_MINOR 14)
|
||||
set(OPENSPACE_VERSION_PATCH 1)
|
||||
set(OPENSPACE_VERSION_STRING "Beta-4")
|
||||
set(OPENSPACE_VERSION_MINOR 15)
|
||||
set(OPENSPACE_VERSION_PATCH -1)
|
||||
set(OPENSPACE_VERSION_STRING "Beta-5 RC1")
|
||||
|
||||
|
||||
set(OPENSPACE_BASE_DIR "${PROJECT_SOURCE_DIR}")
|
||||
|
||||
@@ -1131,7 +1131,7 @@ int main(int argc, char** argv) {
|
||||
"evaluated before it is passed to OpenSpace."
|
||||
));
|
||||
|
||||
// setCommandLine returns a referece to the vector that will be filled later
|
||||
// setCommandLine returns a reference to the vector that will be filled later
|
||||
const std::vector<std::string>& sgctArguments = parser.setCommandLine(
|
||||
{ argv, argv + argc }
|
||||
);
|
||||
|
||||
54
config/single_fisheye_gui.xml
Normal file
54
config/single_fisheye_gui.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<!-- <Scene>
|
||||
<Orientation yaw="0.0" pitch="-27.0" roll="0.0" />
|
||||
<Offset x="0.0" y="0.0" z="0.0" />
|
||||
<Scale value="1.0" />
|
||||
</Scene> -->
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false" numberOfSamples="4" name="OpenSpace">
|
||||
<Stereo type="none" />
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1024" y="1024" />
|
||||
<!-- Frame buffer resolution
|
||||
<Res x="4096" y="4096" /> -->
|
||||
<!--
|
||||
quality options (cubemap size):
|
||||
- low (256)
|
||||
- medium (512)
|
||||
- high/1k (1024)
|
||||
- 2k (2048)
|
||||
- 4k (4096)
|
||||
- 8k (8192)
|
||||
tilt specifies the dome tilt angle in degrees from the horizontal
|
||||
-->
|
||||
<Viewport name="fisheye">
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<FisheyeProjection fov="180" quality="1k" tilt="27.0">
|
||||
<Background r="0.1" g="0.1" b="0.1" a="1.0" />
|
||||
</FisheyeProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
|
||||
|
||||
<Window fullScreen="false" msaa="1" name="GUI" tags="GUI">
|
||||
<Stereo type="none" />
|
||||
<Size x="1280" y="720" />
|
||||
<Res x="2048" y="2048" />
|
||||
<Pos x="50" y="50" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="25.267007923362" left="40.0" right="40.0" up="25.267007923362" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
|
||||
</Node>
|
||||
<User eyeSeparation="0.06">
|
||||
<Pos x="0.0" y="0.0" z="0.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
@@ -15,6 +15,7 @@ asset.require('scene/solarsystem/planets')
|
||||
asset.require('scene/solarsystem/planets/mars/moons/phobos')
|
||||
asset.require('scene/solarsystem/planets/mars/moons/deimos')
|
||||
asset.require('scene/solarsystem/dwarf_planets/pluto/system')
|
||||
asset.request('scene/milkyway/milkyway/volume')
|
||||
|
||||
assetHelper.requestAll(asset, 'scene/digitaluniverse')
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ local speck = asset.syncedResource({
|
||||
Name = "Constellation Speck Files",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "digitaluniverse_constellations_speck",
|
||||
Version = 1
|
||||
Version = 2
|
||||
})
|
||||
|
||||
local constellationsExtragalactic = {
|
||||
|
||||
@@ -54,7 +54,7 @@ local plane = {
|
||||
Parent = "Root",
|
||||
Renderable = {
|
||||
Type = "RenderablePlanesCloud",
|
||||
Enabled = true,
|
||||
Enabled = false,
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Transparency = 0.90,
|
||||
ScaleFactor = 2.8,
|
||||
|
||||
@@ -13,7 +13,7 @@ local speck = asset.syncedResource({
|
||||
Name = "OB Associations Speck Files",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "digitaluniverse_obassociations_speck",
|
||||
Version = 1
|
||||
Version = 2
|
||||
})
|
||||
|
||||
local object = {
|
||||
|
||||
@@ -13,7 +13,7 @@ local speck = asset.syncedResource({
|
||||
Name = "Stars Speck Files",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "stars_du",
|
||||
Version = 1
|
||||
Version = 3
|
||||
})
|
||||
|
||||
local colorLUT = asset.syncedResource({
|
||||
|
||||
42
data/assets/scene/milkyway/milkyway/volume.asset
Normal file
42
data/assets/scene/milkyway/milkyway/volume.asset
Normal file
@@ -0,0 +1,42 @@
|
||||
-- asset.require('../examples/volume/generated/cartesian.asset')
|
||||
|
||||
local assetHelper = asset.require("util/asset_helper")
|
||||
local transforms = asset.require("scene/solarsystem/sun/transforms")
|
||||
|
||||
local data = asset.syncedResource({
|
||||
Name = "Milkyway Volume Data",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "milkyway_volume_data",
|
||||
Version = 1
|
||||
})
|
||||
|
||||
local MilkyWayVolumeGalaxy = {
|
||||
Identifier = "Milky Way Volume",
|
||||
Parent = transforms.SolarSystemBarycenter.Identifier,
|
||||
Renderable = {
|
||||
Type = "RenderableGalaxy",
|
||||
StepSize = 0.01,
|
||||
AbsorptionMultiply = 75,
|
||||
EmissionMultiply = 200,
|
||||
Translation = {0.2, 0, 0},
|
||||
Rotation = {3.1415926, 3.1248, 4.45741},
|
||||
Volume = {
|
||||
Type = "Volume",
|
||||
Filename = data .. "/MilkyWayRGBAVolume1024x1024x128.raw",
|
||||
Dimensions = {1024, 1024, 128},
|
||||
Size = {1.2E21, 1.2E21, 0.15E21}
|
||||
},
|
||||
Points = {
|
||||
Type = "Points",
|
||||
Filename = data .. "/MilkyWayPoints.off",
|
||||
EnabledPointsRatio = 0.3,
|
||||
Texture = data .. "/halo.png"
|
||||
}
|
||||
},
|
||||
GUI = {
|
||||
Path = "/Milky Way"
|
||||
}
|
||||
}
|
||||
|
||||
local objects = { MilkyWayVolumeGalaxy }
|
||||
assetHelper.registerSceneGraphNodesAndExport(asset, objects)
|
||||
@@ -3,7 +3,7 @@ asset.require('./static_server')
|
||||
local guiCustomization = asset.require('customization/gui')
|
||||
|
||||
-- Select which commit hashes to use for the frontend and backend
|
||||
local frontendHash = "2d1bb8d8d8478b6ed025ccc6f1e0ceacf04b6114"
|
||||
local frontendHash = "129a2c70ec8179b193fdb3a689c37bd65418ac22"
|
||||
local dataProvider = "data.openspaceproject.com/files/webgui"
|
||||
|
||||
local frontend = asset.syncedResource({
|
||||
@@ -60,7 +60,8 @@ asset.onDeinitialize(function ()
|
||||
local directories = openspace.getPropertyValue("Modules.WebGui.Directories")
|
||||
local newDirectories = {};
|
||||
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.DefaultEndpoint", "")
|
||||
-- @TODO(maci, 2019-08-23) see message below
|
||||
--openspace.setPropertyValueSingle("Modules.WebGui.DefaultEndpoint", "")
|
||||
|
||||
for i = 0, #directories, 2 do
|
||||
-- @TODO(abock, 2019-08-20) The explicit check for directories[i] is a workaround
|
||||
@@ -70,5 +71,8 @@ asset.onDeinitialize(function ()
|
||||
newDirectories[#newDirectories + 1] = directories[i + 1]
|
||||
end
|
||||
end
|
||||
openspace.setPropertyValueSingle("Modules.WebGui.Directories", newDirectories)
|
||||
-- @TODO(maci, 2019-08-23) setting this value on exit was causing the server to restart
|
||||
-- on macos, which in turn, stopped the application from exiting.
|
||||
-- need to address in webguimodule.cpp
|
||||
--openspace.setPropertyValueSingle("Modules.WebGui.Directories", newDirectories)
|
||||
end)
|
||||
|
||||
Submodule ext/ghoul updated: 526b27cb65...d73b914734
@@ -83,7 +83,7 @@ public:
|
||||
ScriptCameraStates& scriptStates();
|
||||
const ScriptCameraStates& scriptStates() const;
|
||||
|
||||
bool shouldFollowAnchorRotation() const;
|
||||
bool shouldFollowAnchorRotation(const glm::dvec3& cameraPosition) const;
|
||||
bool followingAnchorRotation() const;
|
||||
const SceneGraphNode* anchorNode() const;
|
||||
const SceneGraphNode* aimNode() const;
|
||||
@@ -290,8 +290,8 @@ private:
|
||||
/**
|
||||
* Interpolates between rotationDiff and a 0 rotation.
|
||||
*/
|
||||
glm::dquat interpolateRotationDifferential(double deltaTime,
|
||||
double interpolationTime, const glm::dquat& rotationDiff);
|
||||
glm::dquat interpolateRotationDifferential(double deltaTime, double interpolationTime,
|
||||
const glm::dvec3 cameraPosition, const glm::dquat& rotationDiff);
|
||||
|
||||
/**
|
||||
* Get the vector from the camera to the surface of the anchor object in world space.
|
||||
|
||||
@@ -121,10 +121,8 @@ private:
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _hdrFilteringProgram;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _tmoProgram;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _resolveProgram;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _fxaaProgram;
|
||||
|
||||
UniformCache(mainColorTexture, blackoutFactor) _uniformCache;
|
||||
UniformCache(hdrFeedingTexture, blackoutFactor, hdrExposure, gamma,
|
||||
Hue, Saturation, Value) _hdrUniformCache;
|
||||
UniformCache(renderedTexture, inverseScreenSize) _fxaaUniformCache;
|
||||
|
||||
@@ -92,6 +92,9 @@ public:
|
||||
float globalBlackOutFactor();
|
||||
void setGlobalBlackOutFactor(float opacity);
|
||||
|
||||
float hdrExposure() const;
|
||||
bool isHdrDisabled() const;
|
||||
|
||||
void addScreenSpaceRenderable(std::unique_ptr<ScreenSpaceRenderable> s);
|
||||
void removeScreenSpaceRenderable(ScreenSpaceRenderable* s);
|
||||
void removeScreenSpaceRenderable(const std::string& identifier);
|
||||
|
||||
@@ -41,7 +41,10 @@ public:
|
||||
int patch;
|
||||
};
|
||||
|
||||
~VersionChecker();
|
||||
|
||||
void requestLatestVersion(const std::string& url);
|
||||
void cancel();
|
||||
bool hasLatestVersionInfo();
|
||||
SemanticVersion latestVersion();
|
||||
|
||||
|
||||
@@ -568,8 +568,18 @@ void main() {
|
||||
// Fragments positions into G-Buffer are written in SGCT Eye Space (View plus Camera Rig Coords)
|
||||
// when using their positions later, one must convert them to the planet's coords
|
||||
|
||||
// =======================
|
||||
// Get data from G-Buffer
|
||||
vec4 normal = texture(mainNormalTexture, texCoord);
|
||||
// =======================
|
||||
|
||||
// Normal is stored in SGCT View Space and transformed to the current object space
|
||||
vec4 normalViewSpaceAndWaterReflectance = texture(mainNormalTexture, texCoord);
|
||||
dvec4 normalViewSpace = vec4(normalViewSpaceAndWaterReflectance.xyz, 0.0);
|
||||
dvec4 normalWorldSpace = dSGCTViewToWorldMatrix * normalViewSpace;
|
||||
vec4 normal = vec4(dInverseModelTransformMatrix * normalWorldSpace);
|
||||
normal.xyz = normalize(normal.xyz);
|
||||
normal.w = normalViewSpaceAndWaterReflectance.w;
|
||||
|
||||
// Data in the mainPositionTexture are written in view space (view plus camera rig)
|
||||
vec4 position = texture(mainPositionTexture, texCoord);
|
||||
|
||||
|
||||
@@ -137,7 +137,12 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
if (dictionary.hasKey(SegmentsInfo.identifier)) {
|
||||
_segments = static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
|
||||
}
|
||||
_segments.onChange([&]() { _gridIsDirty = true; });
|
||||
_segments.onChange([&]() {
|
||||
if (_segments.value() % 2 == 1) {
|
||||
_segments = _segments - 1;
|
||||
}
|
||||
_gridIsDirty = true;
|
||||
});
|
||||
addProperty(_segments);
|
||||
|
||||
if (dictionary.hasKey(LineWidthInfo.identifier)) {
|
||||
@@ -259,7 +264,10 @@ void RenderableSphericalGrid::update(const UpdateData&) {
|
||||
_isize = 6 * _segments * _segments;
|
||||
_vsize = (_segments + 1) * (_segments + 1);
|
||||
_varray.resize(_vsize);
|
||||
Vertex v = { 0.f, 0.f, 0.f };
|
||||
std::fill(_varray.begin(), _varray.end(), v);
|
||||
_iarray.resize(_isize);
|
||||
std::fill(_iarray.begin(), _iarray.end(), 0);
|
||||
|
||||
int nr = 0;
|
||||
const float fsegments = static_cast<float>(_segments);
|
||||
|
||||
@@ -202,7 +202,6 @@ RenderableTrail::Appearance::Appearance()
|
||||
RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
{
|
||||
|
||||
setRenderBin(RenderBin::Overlay);
|
||||
addProperty(_opacity);
|
||||
|
||||
@@ -212,35 +211,28 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
|
||||
addPropertySubOwner(_translation.get());
|
||||
|
||||
_appearance.lineColor = dictionary.value<glm::vec3>(LineColorInfo.identifier);
|
||||
addProperty(_appearance.lineColor);
|
||||
|
||||
if (dictionary.hasKeyAndValue<bool>(EnableFadeInfo.identifier)) {
|
||||
_appearance.useLineFade = dictionary.value<bool>(EnableFadeInfo.identifier);
|
||||
}
|
||||
addProperty(_appearance.useLineFade);
|
||||
|
||||
if (dictionary.hasKeyAndValue<double>(FadeInfo.identifier)) {
|
||||
_appearance.lineFade = static_cast<float>(dictionary.value<double>(FadeInfo.identifier));
|
||||
_appearance.lineFade = static_cast<float>(
|
||||
dictionary.value<double>(FadeInfo.identifier)
|
||||
);
|
||||
}
|
||||
addProperty(_appearance.lineFade);
|
||||
|
||||
if (dictionary.hasKeyAndValue<double>(LineWidthInfo.identifier)) {
|
||||
_appearance.lineWidth = static_cast<float>(dictionary.value<double>(
|
||||
LineWidthInfo.identifier
|
||||
));
|
||||
}
|
||||
addProperty(_appearance.lineWidth);
|
||||
|
||||
if (dictionary.hasKeyAndValue<double>(PointSizeInfo.identifier)) {
|
||||
_appearance.pointSize = static_cast<int>(dictionary.value<double>(PointSizeInfo.identifier));
|
||||
_appearance.pointSize = static_cast<int>(
|
||||
dictionary.value<double>(PointSizeInfo.identifier)
|
||||
);
|
||||
}
|
||||
addProperty(_appearance.pointSize);
|
||||
|
||||
_appearance.renderingModes.addOptions({
|
||||
{ RenderingModeLines, "Lines" },
|
||||
{ RenderingModePoints, "Points" },
|
||||
{ RenderingModeLinesPoints, "Lines+Points" }
|
||||
});
|
||||
|
||||
// This map is not accessed out of order as long as the Documentation is adapted
|
||||
// whenever the map changes. The documentation will check for valid values
|
||||
@@ -252,7 +244,8 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
|
||||
else {
|
||||
_appearance.renderingModes = RenderingModeLines;
|
||||
}
|
||||
addProperty(_appearance.renderingModes);
|
||||
|
||||
addPropertySubOwner(_appearance);
|
||||
}
|
||||
|
||||
void RenderableTrail::initializeGL() {
|
||||
|
||||
@@ -84,10 +84,11 @@ Fragment getFragment() {
|
||||
frag.color.rgb = diffuseAlbedo;
|
||||
}
|
||||
|
||||
frag.color.a = opacity;
|
||||
frag.depth = vs_screenSpaceDepth;
|
||||
frag.gPosition = vs_positionCameraSpace;
|
||||
frag.gNormal = vec4(vs_normalViewSpace, 1.0);
|
||||
frag.color.a = opacity;
|
||||
frag.depth = vs_screenSpaceDepth;
|
||||
frag.gPosition = vs_positionCameraSpace;
|
||||
frag.gNormal = vec4(vs_normalViewSpace, 0.0);
|
||||
frag.disableLDR2HDR = true;
|
||||
|
||||
|
||||
return frag;
|
||||
|
||||
@@ -710,14 +710,16 @@ bool RenderableDUMeshes::readSpeckFile() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.substr(0, 4) != "mesh") {
|
||||
std::size_t found = line.find("mesh");
|
||||
if (found == std::string::npos) {
|
||||
//if (line.substr(0, 4) != "mesh") {
|
||||
// we read a line that doesn't belong to the header, so we have to jump back
|
||||
// before the beginning of the current line
|
||||
file.seekg(position);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (line.substr(0, 4) == "mesh") {
|
||||
//if (line.substr(0, 4) == "mesh") {
|
||||
// mesh lines are structured as follows:
|
||||
// mesh -t texnum -c colorindex -s style {
|
||||
// where textnum is the index of the texture;
|
||||
|
||||
@@ -42,9 +42,21 @@ set(SOURCE_FILES
|
||||
)
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
set(SHADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/galaxyraycast.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard_ge.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/points_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/points_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/raycasterbounds_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/raycasterbounds_vs.glsl
|
||||
)
|
||||
source_group("Shader Files" FILES ${SHADER_FILES})
|
||||
|
||||
create_new_module(
|
||||
"Galaxy"
|
||||
galaxy
|
||||
STATIC
|
||||
${HEADER_FILES} ${SOURCE_FILES}
|
||||
${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES}
|
||||
)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
set(DEFAULT_MODULE ON)
|
||||
|
||||
set (OPENSPACE_DEPENDENCIES
|
||||
volume
|
||||
space
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace {
|
||||
constexpr const char* GlslRaycastPath =
|
||||
"${MODULES}/galaxy/shaders/galaxyraycast.glsl";
|
||||
constexpr const char* GlslBoundsVsPath =
|
||||
"${MODULES}/galaxy/shaders/raycasterbounds.vs";
|
||||
"${MODULES}/galaxy/shaders/raycasterbounds_vs.glsl";
|
||||
constexpr const char* GlslBoundsFsPath =
|
||||
"${MODULES}/galaxy/shaders/raycasterbounds.fs";
|
||||
"${MODULES}/galaxy/shaders/raycasterbounds_fs.glsl";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -55,14 +55,8 @@ void GalaxyRaycaster::initialize() {
|
||||
void GalaxyRaycaster::renderEntryPoints(const RenderData& data,
|
||||
ghoul::opengl::ProgramObject& program)
|
||||
{
|
||||
program.setUniform("modelTransform", _modelTransform);
|
||||
program.setUniform("modelViewTransform", glm::mat4(modelViewTransform(data)));
|
||||
program.setUniform("viewProjection", data.camera.viewProjectionMatrix());
|
||||
program.setUniform("blendMode", static_cast<unsigned int>(1));
|
||||
|
||||
program.setUniform("campos", glm::vec4(data.camera.positionVec3(), 1.f));
|
||||
program.setUniform("objpos", glm::vec4(data.modelTransform.translation, 0.f));
|
||||
program.setUniform("camrot", glm::mat4(data.camera.viewRotationMatrix()));
|
||||
program.setUniform("scaling", glm::vec2(1.f, 0.f));
|
||||
|
||||
// Cull back face
|
||||
glEnable(GL_CULL_FACE);
|
||||
@@ -76,14 +70,8 @@ void GalaxyRaycaster::renderExitPoints(const RenderData& data,
|
||||
ghoul::opengl::ProgramObject& program)
|
||||
{
|
||||
// Uniforms
|
||||
program.setUniform("modelTransform", _modelTransform);
|
||||
program.setUniform("modelViewTransform", glm::mat4(modelViewTransform(data)));
|
||||
program.setUniform("viewProjection", data.camera.viewProjectionMatrix());
|
||||
program.setUniform("blendMode", static_cast<unsigned int>(1));
|
||||
|
||||
program.setUniform("campos", glm::vec4(data.camera.positionVec3(), 1.f));
|
||||
program.setUniform("objpos", glm::vec4(data.modelTransform.translation, 0.f));
|
||||
program.setUniform("camrot", glm::mat4(data.camera.viewRotationMatrix()));
|
||||
program.setUniform("scaling", glm::vec2(1.f, 0.f));
|
||||
|
||||
// Cull front face
|
||||
glEnable(GL_CULL_FACE);
|
||||
@@ -96,6 +84,16 @@ void GalaxyRaycaster::renderExitPoints(const RenderData& data,
|
||||
glCullFace(GL_BACK);
|
||||
}
|
||||
|
||||
glm::dmat4 GalaxyRaycaster::modelViewTransform(const RenderData& data) {
|
||||
glm::dmat4 modelTransform =
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
|
||||
glm::dmat4(data.modelTransform.rotation) *
|
||||
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)) *
|
||||
glm::dmat4(_modelTransform);
|
||||
|
||||
return data.camera.combinedViewMatrix() * modelTransform;
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::preRaycast(const RaycastData& data,
|
||||
ghoul::opengl::ProgramObject& program)
|
||||
{
|
||||
@@ -107,9 +105,17 @@ void GalaxyRaycaster::preRaycast(const RaycastData& data,
|
||||
const std::string opacityCoefficientUniformName = "opacityCoefficient" +
|
||||
std::to_string(data.id);
|
||||
|
||||
const std::string absorptionMultiplyUniformName = "absorptionMultiply" +
|
||||
std::to_string(data.id);
|
||||
|
||||
const std::string emissionMultiplyUniformName = "emissionMultiply" +
|
||||
std::to_string(data.id);
|
||||
|
||||
program.setUniform(volumeAspectUniformName, _aspect);
|
||||
program.setUniform(stepSizeUniformName, _stepSize);
|
||||
program.setUniform(opacityCoefficientUniformName, _opacityCoefficient);
|
||||
program.setUniform(absorptionMultiplyUniformName, _absorptionMultiply);
|
||||
program.setUniform(emissionMultiplyUniformName, _emissionMultiply);
|
||||
|
||||
_textureUnit = std::make_unique<ghoul::opengl::TextureUnit>();
|
||||
_textureUnit->activate();
|
||||
@@ -122,35 +128,14 @@ void GalaxyRaycaster::postRaycast(const RaycastData&, ghoul::opengl::ProgramObje
|
||||
}
|
||||
|
||||
bool GalaxyRaycaster::isCameraInside(const RenderData& data, glm::vec3& localPosition) {
|
||||
// Camera rig position in world coordinates.
|
||||
const glm::vec4 rigWorldPos = glm::vec4(data.camera.positionVec3(), 1.0);
|
||||
//rigWorldPos /= data.camera.scaling().x * pow(10.0, data.camera.scaling().y);
|
||||
//glm::mat4 invSgctMatrix = glm::inverse(data.camera.viewMatrix());
|
||||
|
||||
// Camera position in world coordinates.
|
||||
const glm::vec4 camWorldPos = rigWorldPos;
|
||||
const glm::vec3 objPos = static_cast<glm::vec3>(data.modelTransform.translation);
|
||||
|
||||
const glm::mat4 modelTransform = glm::translate(_modelTransform, objPos);
|
||||
|
||||
float divisor = 1.f;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (abs(modelTransform[i][j] > divisor)) {
|
||||
divisor = modelTransform[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const glm::mat4 scaledModelTransform = modelTransform / divisor;
|
||||
|
||||
const glm::vec4 modelPos = (glm::inverse(scaledModelTransform) / divisor) *
|
||||
camWorldPos;
|
||||
glm::vec4 modelPos = glm::inverse(modelViewTransform(data)) *
|
||||
glm::vec4(0.f, 0.f, 0.f, 1.f);
|
||||
|
||||
localPosition = (glm::vec3(modelPos) + glm::vec3(0.5));
|
||||
return (localPosition.x > 0 && localPosition.y > 0 &&
|
||||
localPosition.z > 0 && localPosition.x < 1 &&
|
||||
localPosition.y < 1 && localPosition.z < 1);
|
||||
|
||||
return (localPosition.x > 0 && localPosition.x < 1 &&
|
||||
localPosition.y > 0 && localPosition.y < 1 &&
|
||||
localPosition.z > 0 && localPosition.z < 1);
|
||||
}
|
||||
|
||||
std::string GalaxyRaycaster::boundsVertexShaderPath() const {
|
||||
@@ -181,6 +166,14 @@ void GalaxyRaycaster::setOpacityCoefficient(float opacityCoefficient) {
|
||||
_opacityCoefficient = opacityCoefficient;
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::setAbsorptionMultiplier(float absorptionMultiply) {
|
||||
_absorptionMultiply = absorptionMultiply;
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::setEmissionMultiplier(float emissionMultiply) {
|
||||
_emissionMultiply = emissionMultiply;
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::setTime(double time) {
|
||||
_time = time;
|
||||
}
|
||||
|
||||
@@ -71,14 +71,20 @@ public:
|
||||
void setTime(double time);
|
||||
void setStepSize(float stepSize);
|
||||
void setOpacityCoefficient(float opacityCoefficient);
|
||||
void setAbsorptionMultiplier(float absorptionMultiply);
|
||||
void setEmissionMultiplier(float emissionMultiply);
|
||||
|
||||
private:
|
||||
glm::dmat4 modelViewTransform(const RenderData& data);
|
||||
|
||||
BoxGeometry _boundingBox;
|
||||
float _stepSize;
|
||||
glm::mat4 _modelTransform;
|
||||
glm::vec3 _aspect;
|
||||
double _time;
|
||||
float _opacityCoefficient;
|
||||
float _absorptionMultiply;
|
||||
float _emissionMultiply;
|
||||
ghoul::opengl::Texture& _texture;
|
||||
std::unique_ptr<ghoul::opengl::TextureUnit> _textureUnit;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/boxgeometry.h>
|
||||
#include <openspace/util/distanceconstants.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
@@ -45,20 +46,50 @@
|
||||
#include <fstream>
|
||||
|
||||
namespace {
|
||||
constexpr const char* GlslRayCastPath = "${MODULES}/toyvolume/shaders/rayCast.glsl";
|
||||
constexpr const char* GlslBoundsVsPath = "${MODULES}/toyvolume/shaders/boundsVs.glsl";
|
||||
constexpr const char* GlslBoundsFsPath = "${MODULES}/toyvolume/shaders/boundsFs.glsl";
|
||||
constexpr const char* GlslRaycastPath =
|
||||
"${MODULES}/galaxy/shaders/galaxyraycast.glsl";
|
||||
constexpr const char* GlslBoundsVsPath =
|
||||
"${MODULES}/galaxy/shaders/raycasterbounds_vs.glsl";
|
||||
constexpr const char* GlslBoundsFsPath =
|
||||
"${MODULES}/galaxy/shaders/raycasterbounds_fs.glsl";
|
||||
constexpr const char* _loggerCat = "Renderable Galaxy";
|
||||
|
||||
constexpr const std::array<const char*, 4> UniformNamesPoints = {
|
||||
"modelMatrix", "cameraViewProjectionMatrix", "eyePosition",
|
||||
"opacityCoefficient"
|
||||
};
|
||||
constexpr const std::array<const char*, 5> UniformNamesBillboards = {
|
||||
"modelMatrix", "cameraViewProjectionMatrix",
|
||||
"cameraUp", "eyePosition", "psfTexture"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo VolumeRenderingEnabledInfo = {
|
||||
"VolumeRenderingEnabled",
|
||||
"Volume Rendering",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo StarRenderingEnabledInfo = {
|
||||
"StarRenderingEnabled",
|
||||
"Star Rendering",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo StepSizeInfo = {
|
||||
"StepSize",
|
||||
"Step Size",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo PointStepSizeInfo = {
|
||||
"PointStepSize",
|
||||
"Point Step Size",
|
||||
constexpr openspace::properties::Property::PropertyInfo AbsorptionMultiplyInfo = {
|
||||
"AbsorptionMultiply",
|
||||
"Absorption Multiplier",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo EmissionMultiplyInfo = {
|
||||
"EmissionMultiply",
|
||||
"Emission Multiplier",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
@@ -74,8 +105,15 @@ namespace {
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo StarRenderingMethodInfo = {
|
||||
"StarRenderingMethod",
|
||||
"Star Rendering Method",
|
||||
"This value determines which rendering method is used for visualization of the "
|
||||
"stars."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo EnabledPointsRatioInfo = {
|
||||
"NEnabledPointsRatio",
|
||||
"EnabledPointsRatio",
|
||||
"Enabled points",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
@@ -85,15 +123,78 @@ namespace openspace {
|
||||
|
||||
RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _stepSize(StepSizeInfo, 0.012f, 0.0005f, 0.05f)
|
||||
, _pointStepSize(PointStepSizeInfo, 0.01f, 0.01f, 0.1f)
|
||||
, _translation(TranslationInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(10.f))
|
||||
, _volumeRenderingEnabled(VolumeRenderingEnabledInfo, true)
|
||||
, _starRenderingEnabled(StarRenderingEnabledInfo, true)
|
||||
, _stepSize(StepSizeInfo, 0.01f, 0.0005f, 0.05f, 0.001f)
|
||||
, _absorptionMultiply(AbsorptionMultiplyInfo, 40.f, 0.0f, 100.0f)
|
||||
, _emissionMultiply(EmissionMultiplyInfo, 400.f, 0.0f, 1000.0f)
|
||||
, _starRenderingMethod(
|
||||
StarRenderingMethodInfo,
|
||||
properties::OptionProperty::DisplayType::Dropdown
|
||||
)
|
||||
, _enabledPointsRatio(EnabledPointsRatioInfo, 0.5f, 0.01f, 1.0f)
|
||||
, _translation(TranslationInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _rotation(RotationInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(6.28f))
|
||||
, _enabledPointsRatio(EnabledPointsRatioInfo, 0.2f, 0.f, 1.f)
|
||||
{
|
||||
dictionary.getValue("VolumeRenderingEnabled", _volumeRenderingEnabled);
|
||||
dictionary.getValue("StarRenderingEnabled", _starRenderingEnabled);
|
||||
dictionary.getValue("StepSize", _stepSize);
|
||||
dictionary.getValue("AbsorptionMultiply", _absorptionMultiply);
|
||||
dictionary.getValue("EmissionMultiply", _emissionMultiply);
|
||||
dictionary.getValue("StarRenderingMethod", _starRenderingMethod);
|
||||
dictionary.getValue("EnabledPointsRatio", _enabledPointsRatio);
|
||||
dictionary.getValue("Translation", _translation);
|
||||
dictionary.getValue("Rotation", _rotation);
|
||||
dictionary.getValue("StepSize", _stepSize);
|
||||
|
||||
if (dictionary.hasKeyAndValue<bool>(VolumeRenderingEnabledInfo.identifier)) {
|
||||
_volumeRenderingEnabled = dictionary.value<bool>(
|
||||
VolumeRenderingEnabledInfo.identifier
|
||||
);
|
||||
}
|
||||
|
||||
if (dictionary.hasKeyAndValue<bool>(StarRenderingEnabledInfo.identifier)) {
|
||||
_starRenderingEnabled = static_cast<bool>(StarRenderingEnabledInfo.identifier);
|
||||
}
|
||||
|
||||
if (dictionary.hasKeyAndValue<double>(StepSizeInfo.identifier)) {
|
||||
_stepSize = static_cast<float>(dictionary.value<double>(StepSizeInfo.identifier));
|
||||
}
|
||||
|
||||
if (dictionary.hasKeyAndValue<double>(AbsorptionMultiplyInfo.identifier)) {
|
||||
_absorptionMultiply = static_cast<float>(
|
||||
dictionary.value<double>(AbsorptionMultiplyInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
if (dictionary.hasKeyAndValue<double>(EmissionMultiplyInfo.identifier)) {
|
||||
_emissionMultiply = static_cast<float>(
|
||||
dictionary.value<double>(EmissionMultiplyInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
_starRenderingMethod.addOptions({
|
||||
{ 0, "Points" },
|
||||
{ 1, "Billboards" }
|
||||
});
|
||||
if (dictionary.hasKey(StarRenderingMethodInfo.identifier)) {
|
||||
const std::string starRenderingMethod = dictionary.value<std::string>(
|
||||
StarRenderingMethodInfo.identifier
|
||||
);
|
||||
if (starRenderingMethod == "Points") {
|
||||
_starRenderingMethod = 0;
|
||||
}
|
||||
else if (starRenderingMethod == "Billboards") {
|
||||
_starRenderingMethod = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (dictionary.hasKeyAndValue<glm::vec3>(TranslationInfo.identifier)) {
|
||||
_translation = dictionary.value<glm::vec3>(TranslationInfo.identifier);
|
||||
}
|
||||
|
||||
if (dictionary.hasKeyAndValue<glm::vec3>(RotationInfo.identifier)) {
|
||||
_rotation = dictionary.value<glm::vec3>(RotationInfo.identifier);
|
||||
}
|
||||
|
||||
if (!dictionary.hasKeyAndValue<ghoul::Dictionary>("Volume")) {
|
||||
LERROR("No volume dictionary specified.");
|
||||
@@ -104,13 +205,15 @@ namespace openspace {
|
||||
std::string volumeFilename;
|
||||
if (volumeDictionary.getValue("Filename", volumeFilename)) {
|
||||
_volumeFilename = absPath(volumeFilename);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LERROR("No volume filename specified.");
|
||||
}
|
||||
glm::vec3 volumeDimensions;
|
||||
if (volumeDictionary.getValue("Dimensions", volumeDimensions)) {
|
||||
_volumeDimensions = static_cast<glm::ivec3>(volumeDimensions);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LERROR("No volume dimensions specified.");
|
||||
}
|
||||
glm::vec3 volumeSize;
|
||||
@@ -129,10 +232,27 @@ namespace openspace {
|
||||
std::string pointsFilename;
|
||||
if (pointsDictionary.getValue("Filename", pointsFilename)) {
|
||||
_pointsFilename = absPath(pointsFilename);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LERROR("No points filename specified.");
|
||||
}
|
||||
|
||||
if (pointsDictionary.hasKeyAndValue<double>(EnabledPointsRatioInfo.identifier)) {
|
||||
_enabledPointsRatio = static_cast<float>(
|
||||
pointsDictionary.value<double>(EnabledPointsRatioInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
std::string pointSpreadFunctionTexturePath;
|
||||
if (pointsDictionary.getValue("Texture", pointSpreadFunctionTexturePath)) {
|
||||
_pointSpreadFunctionTexturePath = absPath(pointSpreadFunctionTexturePath);
|
||||
_pointSpreadFunctionFile = std::make_unique<ghoul::filesystem::File>(
|
||||
_pointSpreadFunctionTexturePath
|
||||
);
|
||||
}
|
||||
else {
|
||||
LERROR("No points filename specified.");
|
||||
}
|
||||
pointsDictionary.getValue("Scaling", _pointScaling);
|
||||
}
|
||||
|
||||
void RenderableGalaxy::initializeGL() {
|
||||
@@ -140,7 +260,7 @@ void RenderableGalaxy::initializeGL() {
|
||||
_aspect = static_cast<glm::vec3>(_volumeDimensions);
|
||||
_aspect /= std::max(std::max(_aspect.x, _aspect.y), _aspect.z);
|
||||
|
||||
volume::RawVolumeReader<glm::tvec4<GLfloat>> reader(
|
||||
volume::RawVolumeReader<glm::tvec4<GLubyte>> reader(
|
||||
_volumeFilename,
|
||||
_volumeDimensions
|
||||
);
|
||||
@@ -149,10 +269,10 @@ void RenderableGalaxy::initializeGL() {
|
||||
_texture = std::make_unique<ghoul::opengl::Texture>(
|
||||
_volumeDimensions,
|
||||
ghoul::opengl::Texture::Format::RGBA,
|
||||
GL_RGBA32F,
|
||||
GL_FLOAT,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
ghoul::opengl::Texture::FilterMode::Linear,
|
||||
ghoul::opengl::Texture::WrappingMode::Clamp);
|
||||
ghoul::opengl::Texture::WrappingMode::ClampToEdge);
|
||||
|
||||
_texture->setPixelData(reinterpret_cast<char*>(
|
||||
_volume->data()),
|
||||
@@ -178,91 +298,142 @@ void RenderableGalaxy::initializeGL() {
|
||||
|
||||
onEnabledChange(onChange);
|
||||
|
||||
addProperty(_volumeRenderingEnabled);
|
||||
addProperty(_starRenderingEnabled);
|
||||
addProperty(_stepSize);
|
||||
addProperty(_pointStepSize);
|
||||
addProperty(_absorptionMultiply);
|
||||
addProperty(_emissionMultiply);
|
||||
addProperty(_starRenderingMethod);
|
||||
addProperty(_enabledPointsRatio);
|
||||
addProperty(_translation);
|
||||
addProperty(_rotation);
|
||||
addProperty(_enabledPointsRatio);
|
||||
|
||||
// initialize points.
|
||||
std::ifstream pointFile(_pointsFilename, std::ios::in | std::ios::binary);
|
||||
if (!_pointsFilename.empty()) {
|
||||
_pointsProgram = global::renderEngine.buildRenderProgram(
|
||||
"Galaxy points",
|
||||
absPath("${MODULE_GALAXY}/shaders/points_vs.glsl"),
|
||||
absPath("${MODULE_GALAXY}/shaders/points_fs.glsl")
|
||||
);
|
||||
_billboardsProgram = global::renderEngine.buildRenderProgram(
|
||||
"Galaxy billboard",
|
||||
absPath("${MODULE_GALAXY}/shaders/billboard_vs.glsl"),
|
||||
absPath("${MODULE_GALAXY}/shaders/billboard_fs.glsl"),
|
||||
absPath("${MODULE_GALAXY}/shaders/billboard_ge.glsl")
|
||||
);
|
||||
|
||||
std::vector<glm::vec3> pointPositions;
|
||||
std::vector<glm::vec3> pointColors;
|
||||
if (!_pointSpreadFunctionTexturePath.empty()) {
|
||||
_pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture(
|
||||
absPath(_pointSpreadFunctionTexturePath)
|
||||
);
|
||||
|
||||
int64_t nPoints;
|
||||
pointFile.seekg(0, std::ios::beg); // read heder.
|
||||
pointFile.read(reinterpret_cast<char*>(&nPoints), sizeof(int64_t));
|
||||
if (_pointSpreadFunctionTexture) {
|
||||
LDEBUG(fmt::format(
|
||||
"Loaded texture from '{}'",
|
||||
absPath(_pointSpreadFunctionTexturePath)
|
||||
));
|
||||
_pointSpreadFunctionTexture->uploadTexture();
|
||||
}
|
||||
_pointSpreadFunctionTexture->setFilter(
|
||||
ghoul::opengl::Texture::FilterMode::AnisotropicMipMap
|
||||
);
|
||||
|
||||
_nPoints = static_cast<size_t>(nPoints);
|
||||
_pointSpreadFunctionFile = std::make_unique<ghoul::filesystem::File>(
|
||||
_pointSpreadFunctionTexturePath
|
||||
);
|
||||
}
|
||||
|
||||
size_t nFloats = _nPoints * 7;
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_pointsProgram,
|
||||
_uniformCachePoints,
|
||||
UniformNamesPoints
|
||||
);
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_billboardsProgram,
|
||||
_uniformCacheBillboards,
|
||||
UniformNamesBillboards
|
||||
);
|
||||
|
||||
std::vector<float> pointData(nFloats);
|
||||
pointFile.seekg(sizeof(int64_t), std::ios::beg); // read past heder.
|
||||
pointFile.read(reinterpret_cast<char*>(pointData.data()), nFloats * sizeof(float));
|
||||
pointFile.close();
|
||||
_pointsProgram->setIgnoreUniformLocationError(
|
||||
ghoul::opengl::ProgramObject::IgnoreError::Yes
|
||||
);
|
||||
|
||||
float maxdist = 0;
|
||||
GLint positionAttrib = _pointsProgram->attributeLocation("in_position");
|
||||
GLint colorAttrib = _pointsProgram->attributeLocation("in_color");
|
||||
|
||||
for (size_t i = 0; i < _nPoints; ++i) {
|
||||
float x = pointData[i * 7 + 0];
|
||||
float y = pointData[i * 7 + 1];
|
||||
float z = pointData[i * 7 + 2];
|
||||
float r = pointData[i * 7 + 3];
|
||||
float g = pointData[i * 7 + 4];
|
||||
float b = pointData[i * 7 + 5];
|
||||
maxdist = std::max(maxdist, glm::length(glm::vec3(x, y, z)));
|
||||
//float a = pointData[i * 7 + 6]; alpha is not used.
|
||||
std::ifstream pointFile(_pointsFilename, std::ios::in);
|
||||
|
||||
pointPositions.emplace_back(x, y, z);
|
||||
pointColors.emplace_back(r, g, b);
|
||||
std::vector<glm::vec3> pointPositions;
|
||||
std::vector<glm::vec3> pointColors;
|
||||
int64_t nPoints;
|
||||
|
||||
// Read header for OFF (Object File Format)
|
||||
std::string line;
|
||||
std::getline(pointFile, line);
|
||||
|
||||
// Read point count
|
||||
std::getline(pointFile, line);
|
||||
std::istringstream iss(line);
|
||||
iss >> nPoints;
|
||||
|
||||
// Prepare point reading
|
||||
_nPoints = static_cast<size_t>(nPoints);
|
||||
float maxdist = 0;
|
||||
|
||||
// Read points
|
||||
float x, y, z, r, g, b, a;
|
||||
for (size_t i = 0;
|
||||
i < static_cast<size_t>(_nPoints * _enabledPointsRatio.maxValue()) + 1;
|
||||
++i)
|
||||
{
|
||||
std::getline(pointFile, line);
|
||||
std::istringstream issp(line);
|
||||
issp >> x >> y >> z >> r >> g >> b >> a;
|
||||
|
||||
//Convert klioparsec to meters
|
||||
glm::vec3 position = glm::vec3(x, y, z);
|
||||
position *= (openspace::distanceconstants::Parsec * 100);
|
||||
|
||||
maxdist = std::max(maxdist, glm::length(position));
|
||||
|
||||
pointPositions.emplace_back(position);
|
||||
pointColors.emplace_back(r, g, b);
|
||||
}
|
||||
|
||||
pointFile.close();
|
||||
|
||||
std::cout << maxdist << std::endl;
|
||||
|
||||
glGenVertexArrays(1, &_pointsVao);
|
||||
glGenBuffers(1, &_positionVbo);
|
||||
glGenBuffers(1, &_colorVbo);
|
||||
|
||||
glBindVertexArray(_pointsVao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _positionVbo);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
pointPositions.size() * sizeof(glm::vec3),
|
||||
pointPositions.data(),
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _colorVbo);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
pointColors.size() * sizeof(glm::vec3),
|
||||
pointColors.data(),
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _positionVbo);
|
||||
glEnableVertexAttribArray(positionAttrib);
|
||||
glVertexAttribPointer(positionAttrib, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _colorVbo);
|
||||
glEnableVertexAttribArray(colorAttrib);
|
||||
glVertexAttribPointer(colorAttrib, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
std::cout << maxdist << std::endl;
|
||||
|
||||
glGenVertexArrays(1, &_pointsVao);
|
||||
glGenBuffers(1, &_positionVbo);
|
||||
glGenBuffers(1, &_colorVbo);
|
||||
|
||||
glBindVertexArray(_pointsVao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _positionVbo);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
pointPositions.size() * sizeof(glm::vec3),
|
||||
pointPositions.data(),
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _colorVbo);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
pointColors.size() * sizeof(glm::vec3),
|
||||
pointColors.data(),
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
_pointsProgram = global::renderEngine.buildRenderProgram(
|
||||
"Galaxy points",
|
||||
absPath("${MODULE_GALAXY}/shaders/points.vs"),
|
||||
absPath("${MODULE_GALAXY}/shaders/points.fs")
|
||||
);
|
||||
|
||||
_pointsProgram->setIgnoreUniformLocationError(
|
||||
ghoul::opengl::ProgramObject::IgnoreError::Yes
|
||||
);
|
||||
|
||||
GLint positionAttrib = _pointsProgram->attributeLocation("inPosition");
|
||||
GLint colorAttrib = _pointsProgram->attributeLocation("inColor");
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _positionVbo);
|
||||
glEnableVertexAttribArray(positionAttrib);
|
||||
glVertexAttribPointer(positionAttrib, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _colorVbo);
|
||||
glEnableVertexAttribArray(colorAttrib);
|
||||
glVertexAttribPointer(colorAttrib, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void RenderableGalaxy::deinitializeGL() {
|
||||
@@ -289,9 +460,10 @@ void RenderableGalaxy::update(const UpdateData& data) {
|
||||
transform = glm::rotate(transform, eulerRotation.z, glm::vec3(0, 0, 1));
|
||||
|
||||
glm::mat4 volumeTransform = glm::scale(transform, _volumeSize);
|
||||
_pointTransform = glm::scale(transform, _pointScaling);
|
||||
_pointTransform = transform;
|
||||
//_pointTransform = glm::scale(transform, _pointScaling);
|
||||
|
||||
const glm::vec4 translation = glm::vec4(_translation.value(), 0.0);
|
||||
const glm::vec4 translation = glm::vec4(_translation.value()*_volumeSize, 0.0);
|
||||
|
||||
// Todo: handle floating point overflow, to actually support translation.
|
||||
|
||||
@@ -301,49 +473,223 @@ void RenderableGalaxy::update(const UpdateData& data) {
|
||||
_raycaster->setStepSize(_stepSize);
|
||||
_raycaster->setAspect(_aspect);
|
||||
_raycaster->setModelTransform(volumeTransform);
|
||||
// @EMIL: is this correct? ---abock
|
||||
_raycaster->setAbsorptionMultiplier(_absorptionMultiply);
|
||||
_raycaster->setEmissionMultiplier(_emissionMultiply);
|
||||
_raycaster->setTime(data.time.j2000Seconds());
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) {
|
||||
RaycasterTask task { _raycaster.get(), data };
|
||||
// Render the volume
|
||||
if (_raycaster && _volumeRenderingEnabled) {
|
||||
RaycasterTask task{ _raycaster.get(), data };
|
||||
|
||||
const glm::vec3 position = data.camera.positionVec3();
|
||||
const float length = safeLength(position);
|
||||
const glm::vec3 galaxySize = _volumeSize;
|
||||
const glm::vec3 position = data.camera.positionVec3();
|
||||
const float length = safeLength(position);
|
||||
const glm::vec3 galaxySize = _volumeSize;
|
||||
|
||||
const float maxDim = std::max(std::max(galaxySize.x, galaxySize.y), galaxySize.z);
|
||||
const float maxDim = std::max(std::max(galaxySize.x, galaxySize.y), galaxySize.z);
|
||||
|
||||
const float lowerRampStart = maxDim * 0.02f;
|
||||
const float lowerRampEnd = maxDim * 0.5f;
|
||||
const float lowerRampStart = maxDim * 0.02f;
|
||||
const float lowerRampEnd = maxDim * 0.5f;
|
||||
|
||||
const float upperRampStart = maxDim * 2.f;
|
||||
const float upperRampEnd = maxDim * 10.f;
|
||||
const float upperRampStart = maxDim * 2.f;
|
||||
const float upperRampEnd = maxDim * 10.f;
|
||||
|
||||
float opacityCoefficient = 1.f;
|
||||
float opacityCoefficient = 1.f;
|
||||
if (length < lowerRampStart) {
|
||||
opacityCoefficient = 0.f; // camera really close
|
||||
} else if (length < lowerRampEnd) {
|
||||
opacityCoefficient = (length - lowerRampStart) /
|
||||
(lowerRampEnd - lowerRampStart);
|
||||
} else if (length < upperRampStart) {
|
||||
opacityCoefficient = 1.f; // sweet spot (max)
|
||||
} else if (length < upperRampEnd) {
|
||||
opacityCoefficient = 1.f - (length - upperRampStart) /
|
||||
(upperRampEnd - upperRampStart); //fade out
|
||||
} else {
|
||||
opacityCoefficient = 0;
|
||||
}
|
||||
|
||||
if (length < lowerRampStart) {
|
||||
opacityCoefficient = 0.f; // camera really close
|
||||
} else if (length < lowerRampEnd) {
|
||||
opacityCoefficient = (length - lowerRampStart) / (lowerRampEnd - lowerRampStart);
|
||||
} else if (length < upperRampStart) {
|
||||
opacityCoefficient = 1.f; // sweet spot (max)
|
||||
} else if (length < upperRampEnd) {
|
||||
opacityCoefficient = 1.f - (length - upperRampStart) /
|
||||
(upperRampEnd - upperRampStart); //fade out
|
||||
} else {
|
||||
opacityCoefficient = 0;
|
||||
_opacityCoefficient = opacityCoefficient;
|
||||
ghoul_assert(
|
||||
_opacityCoefficient >= 0.f && _opacityCoefficient <= 1.f,
|
||||
"Opacity coefficient was not between 0 and 1"
|
||||
);
|
||||
if (opacityCoefficient > 0) {
|
||||
_raycaster->setOpacityCoefficient(_opacityCoefficient);
|
||||
tasks.raycasterTasks.push_back(task);
|
||||
}
|
||||
}
|
||||
|
||||
_opacityCoefficient = opacityCoefficient;
|
||||
ghoul_assert(
|
||||
_opacityCoefficient >= 0.f && _opacityCoefficient <= 1.f,
|
||||
"Opacity coefficient was not between 0 and 1"
|
||||
);
|
||||
if (opacityCoefficient > 0) {
|
||||
_raycaster->setOpacityCoefficient(_opacityCoefficient);
|
||||
tasks.raycasterTasks.push_back(task);
|
||||
// Render the stars
|
||||
if (_starRenderingEnabled && _opacityCoefficient > 0.f) {
|
||||
if (_starRenderingMethod == 1) {
|
||||
renderBillboards(data);
|
||||
}
|
||||
else {
|
||||
renderPoints(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableGalaxy::renderPoints(const RenderData& data) {
|
||||
if (_pointsProgram) {
|
||||
// Saving current OpenGL state
|
||||
GLenum blendEquationRGB;
|
||||
GLenum blendEquationAlpha;
|
||||
GLenum blendDestAlpha;
|
||||
GLenum blendDestRGB;
|
||||
GLenum blendSrcAlpha;
|
||||
GLenum blendSrcRGB;
|
||||
GLboolean depthMask;
|
||||
|
||||
glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB);
|
||||
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha);
|
||||
glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha);
|
||||
glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB);
|
||||
glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha);
|
||||
glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
|
||||
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glDepthMask(false);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
_pointsProgram->activate();
|
||||
|
||||
glm::dmat4 rotMatrix = glm::rotate(
|
||||
glm::dmat4(1.0),
|
||||
glm::pi<double>(),
|
||||
glm::dvec3(1.0, 0.0, 0.0)) *
|
||||
glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) *
|
||||
glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0)
|
||||
);
|
||||
|
||||
glm::dmat4 modelMatrix =
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
|
||||
glm::dmat4(data.modelTransform.rotation) * rotMatrix *
|
||||
glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)));
|
||||
|
||||
glm::dmat4 projectionMatrix = glm::dmat4(data.camera.projectionMatrix());
|
||||
|
||||
glm::dmat4 cameraViewProjectionMatrix = projectionMatrix *
|
||||
data.camera.combinedViewMatrix();
|
||||
|
||||
_pointsProgram->setUniform(_uniformCachePoints.modelMatrix, modelMatrix);
|
||||
_pointsProgram->setUniform(
|
||||
_uniformCachePoints.cameraViewProjectionMatrix,
|
||||
cameraViewProjectionMatrix
|
||||
);
|
||||
|
||||
glm::dvec3 eyePosition = glm::dvec3(
|
||||
glm::inverse(data.camera.combinedViewMatrix()) *
|
||||
glm::dvec4(0.0, 0.0, 0.0, 1.0)
|
||||
);
|
||||
_pointsProgram->setUniform(_uniformCachePoints.eyePosition, eyePosition);
|
||||
_pointsProgram->setUniform(
|
||||
_uniformCachePoints.opacityCoefficient,
|
||||
_opacityCoefficient
|
||||
);
|
||||
|
||||
glBindVertexArray(_pointsVao);
|
||||
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(_nPoints * _enabledPointsRatio));
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
_pointsProgram->deactivate();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(true);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// Restores OpenGL blending state
|
||||
glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha);
|
||||
glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha);
|
||||
glDepthMask(depthMask);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableGalaxy::renderBillboards(const RenderData& data) {
|
||||
if (_billboardsProgram) {
|
||||
// Saving current OpenGL state
|
||||
GLenum blendEquationRGB;
|
||||
GLenum blendEquationAlpha;
|
||||
GLenum blendDestAlpha;
|
||||
GLenum blendDestRGB;
|
||||
GLenum blendSrcAlpha;
|
||||
GLenum blendSrcRGB;
|
||||
GLboolean depthMask;
|
||||
|
||||
glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB);
|
||||
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha);
|
||||
glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha);
|
||||
glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB);
|
||||
glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha);
|
||||
glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
|
||||
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glDepthMask(false);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
_billboardsProgram->activate();
|
||||
|
||||
glm::dmat4 rotMatrix = glm::rotate(
|
||||
glm::dmat4(1.0),
|
||||
glm::pi<double>(),
|
||||
glm::dvec3(1.0, 0.0, 0.0)) *
|
||||
glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) *
|
||||
glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0)
|
||||
);
|
||||
|
||||
glm::dmat4 modelMatrix =
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
|
||||
glm::dmat4(data.modelTransform.rotation) * rotMatrix *
|
||||
glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)));
|
||||
|
||||
glm::dmat4 projectionMatrix = glm::dmat4(data.camera.projectionMatrix());
|
||||
|
||||
glm::dmat4 cameraViewProjectionMatrix = projectionMatrix *
|
||||
data.camera.combinedViewMatrix();
|
||||
|
||||
_billboardsProgram->setUniform(_uniformCacheBillboards.modelMatrix, modelMatrix);
|
||||
_billboardsProgram->setUniform(
|
||||
_uniformCacheBillboards.cameraViewProjectionMatrix,
|
||||
cameraViewProjectionMatrix
|
||||
);
|
||||
|
||||
glm::dvec3 eyePosition = glm::dvec3(
|
||||
glm::inverse(data.camera.combinedViewMatrix()) *
|
||||
glm::dvec4(0.0, 0.0, 0.0, 1.0)
|
||||
);
|
||||
_billboardsProgram->setUniform(_uniformCacheBillboards.eyePosition, eyePosition);
|
||||
|
||||
glm::dvec3 cameraUp = data.camera.lookUpVectorWorldSpace();
|
||||
_billboardsProgram->setUniform(_uniformCacheBillboards.cameraUp, cameraUp);
|
||||
|
||||
ghoul::opengl::TextureUnit psfUnit;
|
||||
psfUnit.activate();
|
||||
_pointSpreadFunctionTexture->bind();
|
||||
_billboardsProgram->setUniform(_uniformCacheBillboards.psfTexture, psfUnit);
|
||||
|
||||
glBindVertexArray(_pointsVao);
|
||||
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(_nPoints * _enabledPointsRatio));
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
_billboardsProgram->deactivate();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(true);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// Restores OpenGL blending state
|
||||
glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha);
|
||||
glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha);
|
||||
glDepthMask(depthMask);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,37 +700,4 @@ float RenderableGalaxy::safeLength(const glm::vec3& vector) const {
|
||||
return glm::length(vector / maxComponent) * maxComponent;
|
||||
}
|
||||
|
||||
/*void RenderableGalaxy::postRender(const RenderData& data) {
|
||||
|
||||
_raycaster->setStepSize(_pointStepSize);
|
||||
|
||||
_pointsProgram->activate();
|
||||
setPscUniforms(*_pointsProgram.get(), data.camera, data.position);
|
||||
|
||||
OsEng.ref().renderEngine().preRaycast(*_pointsProgram);
|
||||
|
||||
glm::mat4 modelMatrix = _pointTransform;
|
||||
glm::mat4 viewMatrix = data.camera.viewMatrix();
|
||||
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
|
||||
|
||||
_pointsProgram->setUniform("model", modelMatrix);
|
||||
_pointsProgram->setUniform("view", viewMatrix);
|
||||
_pointsProgram->setUniform("projection", projectionMatrix);
|
||||
|
||||
float emittanceFactor = _opacityCoefficient * static_cast<glm::vec3>(_volumeSize).x;
|
||||
_pointsProgram->setUniform("emittanceFactor", emittanceFactor);
|
||||
|
||||
glBindVertexArray(_pointsVao);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(false);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glDrawArrays(GL_POINTS, 0, _nPoints * _enabledPointsRatio);
|
||||
glBindVertexArray(0);
|
||||
glDepthMask(true);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
OsEng.ref().renderEngine().postRaycast(*_pointsProgram);
|
||||
}*/
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -29,7 +29,13 @@
|
||||
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <ghoul/opengl/uniformcache.h>
|
||||
|
||||
namespace ghoul::opengl {
|
||||
class ProgramObject;
|
||||
} // namespace ghoul::opengl
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -40,7 +46,7 @@ struct RenderData;
|
||||
|
||||
class RenderableGalaxy : public Renderable {
|
||||
public:
|
||||
RenderableGalaxy(const ghoul::Dictionary& dictionary);
|
||||
explicit RenderableGalaxy(const ghoul::Dictionary& dictionary);
|
||||
virtual ~RenderableGalaxy() = default;
|
||||
|
||||
void initializeGL() override;
|
||||
@@ -50,28 +56,48 @@ public:
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
void renderPoints(const RenderData& data);
|
||||
void renderBillboards(const RenderData& data);
|
||||
float safeLength(const glm::vec3& vector) const;
|
||||
|
||||
glm::vec3 _volumeSize;
|
||||
glm::vec3 _pointScaling;
|
||||
properties::BoolProperty _volumeRenderingEnabled;
|
||||
properties::BoolProperty _starRenderingEnabled;
|
||||
properties::FloatProperty _stepSize;
|
||||
properties::FloatProperty _pointStepSize;
|
||||
properties::FloatProperty _absorptionMultiply;
|
||||
properties::FloatProperty _emissionMultiply;
|
||||
properties::OptionProperty _starRenderingMethod;
|
||||
properties::FloatProperty _enabledPointsRatio;
|
||||
properties::Vec3Property _translation;
|
||||
properties::Vec3Property _rotation;
|
||||
properties::FloatProperty _enabledPointsRatio;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::Texture> _pointSpreadFunctionTexture;
|
||||
std::unique_ptr<ghoul::filesystem::File> _pointSpreadFunctionFile;
|
||||
|
||||
std::string _volumeFilename;
|
||||
glm::ivec3 _volumeDimensions;
|
||||
std::string _pointsFilename;
|
||||
std::string _pointSpreadFunctionTexturePath;
|
||||
|
||||
std::unique_ptr<GalaxyRaycaster> _raycaster;
|
||||
std::unique_ptr<volume::RawVolume<glm::tvec4<GLfloat>>> _volume;
|
||||
std::unique_ptr<volume::RawVolume<glm::tvec4<GLubyte>>> _volume;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
glm::mat4 _pointTransform;
|
||||
glm::vec3 _aspect;
|
||||
float _opacityCoefficient;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _pointsProgram;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _billboardsProgram;
|
||||
UniformCache(
|
||||
modelMatrix, cameraViewProjectionMatrix, eyePosition,
|
||||
opacityCoefficient
|
||||
) _uniformCachePoints;
|
||||
UniformCache(
|
||||
modelMatrix, cameraViewProjectionMatrix,
|
||||
cameraUp, eyePosition, psfTexture
|
||||
) _uniformCacheBillboards;
|
||||
std::vector<float> _pointsData;
|
||||
size_t _nPoints;
|
||||
GLuint _pointsVao;
|
||||
GLuint _positionVbo;
|
||||
|
||||
@@ -23,21 +23,28 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include "fragment.glsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
#include "floatoperations.glsl"
|
||||
|
||||
in vec3 vsPosition;
|
||||
in vec3 vsColor;
|
||||
|
||||
uniform float emittanceFactor;
|
||||
uniform sampler2D psfTexture;
|
||||
|
||||
in vec4 vs_position;
|
||||
in vec2 psfCoords;
|
||||
flat in vec3 ge_color;
|
||||
flat in float ge_screenSpaceDepth;
|
||||
|
||||
Fragment getFragment() {
|
||||
Fragment frag;
|
||||
|
||||
float coefficient = exp(1.38 * log(emittanceFactor) - 2*log(depth));
|
||||
frag.color = vec4(vsColor.rgb * coefficient, 1.0);
|
||||
vec4 textureColor = texture(psfTexture, 0.5*psfCoords + 0.5);
|
||||
vec4 fullColor = vec4(ge_color*textureColor.a, textureColor.a);
|
||||
if (fullColor.a == 0) {
|
||||
discard;
|
||||
}
|
||||
frag.color = fullColor;
|
||||
|
||||
frag.depth = pscDepth(vec4(vsPosition, 0.0));
|
||||
frag.depth = ge_screenSpaceDepth;
|
||||
frag.gPosition = vs_position;
|
||||
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
return frag;
|
||||
}
|
||||
101
modules/galaxy/shaders/billboard_ge.glsl
Normal file
101
modules/galaxy/shaders/billboard_ge.glsl
Normal file
@@ -0,0 +1,101 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* *
|
||||
* 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__
|
||||
|
||||
#include "floatoperations.glsl"
|
||||
#include "PowerScaling/powerScalingMath.hglsl"
|
||||
|
||||
uniform dvec3 eyePosition;
|
||||
uniform dvec3 cameraUp;
|
||||
uniform dmat4 cameraViewProjectionMatrix;
|
||||
uniform dmat4 modelMatrix;
|
||||
|
||||
layout(points) in;
|
||||
layout(triangle_strip, max_vertices = 4) out;
|
||||
|
||||
in vec4 vs_gPosition[];
|
||||
in vec3 vs_color[];
|
||||
|
||||
out vec4 vs_position;
|
||||
out vec2 psfCoords;
|
||||
flat out vec3 ge_color;
|
||||
flat out float ge_screenSpaceDepth;
|
||||
|
||||
const double PARSEC = 3.08567756E16;
|
||||
|
||||
void main() {
|
||||
vs_position = gl_in[0].gl_Position; // in object space
|
||||
ge_color = vs_color[0];
|
||||
|
||||
double scaleMultiply = 8.0;
|
||||
|
||||
dvec4 dpos = dvec4(vs_position);
|
||||
dpos.xyz *= scaleMultiply;
|
||||
dpos = modelMatrix * dpos;
|
||||
dpos /= PARSEC;
|
||||
//It lies about 8 kpc from the center on what is known as the Orion Arm of the Milky Way
|
||||
dpos.x += 8000;
|
||||
|
||||
scaleMultiply *= 4.0;
|
||||
dvec3 scaledRight = dvec3(0.0);
|
||||
dvec3 scaledUp = dvec3(0.0);
|
||||
vec4 bottomLeftVertex, bottomRightVertex, topLeftVertex, topRightVertex;
|
||||
|
||||
dvec3 normal = normalize(eyePosition - dpos.xyz);
|
||||
dvec3 newRight = normalize(cross(cameraUp, normal));
|
||||
dvec3 newUp = cross(normal, newRight);
|
||||
scaledRight = scaleMultiply * newRight;
|
||||
scaledUp = scaleMultiply * newUp;
|
||||
|
||||
bottomLeftVertex = z_normalization(vec4(cameraViewProjectionMatrix *
|
||||
dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w)));
|
||||
|
||||
//dvec4 dposCamera = cameraViewProjectionMatrix * dpos;
|
||||
//ge_screenSpaceDepth = float(length(eyePosition - dposCamera.xyz)/PARSEC);
|
||||
ge_screenSpaceDepth = bottomLeftVertex.w;
|
||||
|
||||
topRightVertex = z_normalization(vec4(cameraViewProjectionMatrix *
|
||||
dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w)));
|
||||
|
||||
bottomRightVertex = z_normalization(vec4(cameraViewProjectionMatrix *
|
||||
dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w)));
|
||||
topLeftVertex = z_normalization(vec4(cameraViewProjectionMatrix *
|
||||
dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w)));
|
||||
|
||||
// Build primitive
|
||||
gl_Position = topLeftVertex;
|
||||
psfCoords = vec2(-1.0, 1.0);
|
||||
EmitVertex();
|
||||
gl_Position = bottomLeftVertex;
|
||||
psfCoords = vec2(-1.0, -1.0);
|
||||
EmitVertex();
|
||||
gl_Position = topRightVertex;
|
||||
psfCoords = vec2(1.0, 1.0);
|
||||
EmitVertex();
|
||||
gl_Position = bottomRightVertex;
|
||||
psfCoords = vec2(1.0, -1.0);
|
||||
EmitVertex();
|
||||
EndPrimitive();
|
||||
}
|
||||
@@ -24,11 +24,13 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 0) in vec3 in_position;
|
||||
layout(location = 1) in vec3 in_color;
|
||||
|
||||
flat out vec3 vPosition;
|
||||
out vec3 vs_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = position;
|
||||
vPosition = position.xyz;
|
||||
vs_color = in_color;
|
||||
|
||||
gl_Position = vec4(in_position, 1.0);
|
||||
}
|
||||
@@ -1,93 +1,80 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* *
|
||||
* 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 float maxStepSize#{id} = 0.1;
|
||||
uniform vec3 aspect#{id} = vec3(1.0);
|
||||
uniform float opacityCoefficient#{id} = 1.0;
|
||||
|
||||
uniform float opacityCoefficient#{id} = 1.0;
|
||||
uniform float absorptionMultiply#{id} = 50.0;
|
||||
uniform float emissionMultiply#{id} = 1500.0;
|
||||
uniform sampler3D galaxyTexture#{id};
|
||||
|
||||
void sample#{id}(vec3 samplePos,
|
||||
vec3 dir,
|
||||
inout vec3 accumulatedColor,
|
||||
inout vec3 accumulatedAlpha,
|
||||
inout float maxStepSize)
|
||||
{
|
||||
|
||||
vec3 dir,
|
||||
inout vec3 accumulatedColor,
|
||||
inout vec3 accumulatedAlpha,
|
||||
inout float maxStepSize)
|
||||
{
|
||||
vec3 aspect = aspect#{id};
|
||||
maxStepSize = maxStepSize#{id} / length(dir / aspect);
|
||||
|
||||
vec4 sampledColor = texture(galaxyTexture#{id}, samplePos.xyz);
|
||||
|
||||
float STEP_SIZE = maxStepSize#{id};
|
||||
//Early ray termination on black parts of the data
|
||||
vec3 normalizedPos = (samplePos*2.0)-1.0;
|
||||
if(abs(normalizedPos.x) > 0.8 || abs(normalizedPos.y) > 0.8){
|
||||
return;
|
||||
}
|
||||
|
||||
float STEP_SIZE = maxStepSize#{id}*0.5;
|
||||
//float STEP_SIZE = 1 / 256.0;
|
||||
|
||||
vec3 alphaTint = vec3(0.3, 0.54, 0.85);
|
||||
|
||||
vec4 sampledColor = texture(galaxyTexture#{id}, samplePos.xyz);
|
||||
|
||||
// Source textures currently are square-rooted to avoid dithering in the shadows.
|
||||
// So square them back
|
||||
sampledColor = sampledColor*sampledColor;
|
||||
|
||||
// fudge for the dust "spreading"
|
||||
sampledColor.a = clamp(sampledColor.a, 0.0, 1.0) * opacityCoefficient#{id};
|
||||
sampledColor.a = pow(sampledColor.a, 0.7);
|
||||
//sampledColor.rgba = min(vec4(1.0), sampledColor.rgba);
|
||||
|
||||
//sampledColor.a = clamp(sampledColor.a * 10000000000.0, 0.0, 1.0);
|
||||
//sampledColor.a = exp(-sampledColor.a);
|
||||
//
|
||||
// absorption probability
|
||||
float scaled_density = sampledColor.a * STEP_SIZE * absorptionMultiply#{id};
|
||||
vec3 absorption = alphaTint * scaled_density;
|
||||
|
||||
//sampledColor.rgb = pow(sampledColor.rgb, vec3(10.0));
|
||||
//sampledColor.a = pow(sampledColor.a, 10.0);
|
||||
//sampledColor.a = pow(sampledColor.a, 100000000.0);
|
||||
sampledColor.rgb *= 500.0;
|
||||
sampledColor.a = sampledColor.a * 0.3; //1.0;
|
||||
// extinction
|
||||
vec3 extinction = exp(-absorption);
|
||||
accumulatedColor.rgb *= extinction;
|
||||
|
||||
|
||||
//float emissionCoefficient = 80;
|
||||
//float absorptionCoefficient = 1;
|
||||
// sampledColor = clamp(sampledColor, 0.0, 1.0);
|
||||
// emission
|
||||
accumulatedColor.rgb += sampledColor.rgb * STEP_SIZE * emissionMultiply#{id};
|
||||
|
||||
//backColor = vec3(1.0) - pow(vec3(1.0) - backColor, vec3(STEP_SIZE));
|
||||
/*if (sampledColor.a > 1.0) {
|
||||
sampledColor.a = 1.0;
|
||||
//accumulatedColor = vec3(1.0, 0.0, 0.0);
|
||||
//accumulatedAlpha = vec3(1.0, 1.0, 1.0);
|
||||
//return;
|
||||
}*/
|
||||
//sampledColor.a = 1.2;
|
||||
|
||||
//sampledColor.a *= 0.00001;
|
||||
|
||||
vec3 backColor = sampledColor.rgb;
|
||||
vec3 backAlpha = sampledColor.a * alphaTint;
|
||||
|
||||
backColor *= STEP_SIZE * opacityCoefficient#{id};
|
||||
backAlpha *= STEP_SIZE * opacityCoefficient#{id};
|
||||
|
||||
backColor = clamp(backColor, 0.0, 1.0);
|
||||
backAlpha = clamp(backAlpha, 0.0, 1.0);
|
||||
|
||||
vec3 oneMinusFrontAlpha = vec3(1.0) - accumulatedAlpha;
|
||||
accumulatedColor += oneMinusFrontAlpha * backColor;
|
||||
accumulatedAlpha += oneMinusFrontAlpha * backAlpha;
|
||||
}
|
||||
//accumulatedColor += oneMinusFrontAlpha * sampledColor.rgb;
|
||||
accumulatedAlpha += oneMinusFrontAlpha * sampledColor.rgb;
|
||||
}
|
||||
|
||||
float stepSize#{id}(vec3 samplePos, vec3 dir) {
|
||||
float stepSize#{id}(vec3 samplePos, vec3 dir) {
|
||||
return maxStepSize#{id} * length(dir * 1.0 / aspect#{id});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,32 +22,27 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
#include "fragment.glsl"
|
||||
#include "floatoperations.glsl"
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
in vec4 vs_position;
|
||||
in vec3 vs_color;
|
||||
in float vs_screenSpaceDepth;
|
||||
in float vs_starBrightness;
|
||||
|
||||
in vec3 inPosition;
|
||||
in vec3 inColor;
|
||||
uniform float opacityCoefficient;
|
||||
|
||||
out vec3 vsPosition;
|
||||
out vec3 vsColor;
|
||||
Fragment getFragment() {
|
||||
Fragment frag;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
float multipliedOpacityCoefficient = clamp(opacityCoefficient*opacityCoefficient*20.0, 0.0, 1.0);
|
||||
vec3 extinction = exp(vec3(0.6, 0.2, 0.3)-vs_color);
|
||||
vec4 fullColor = vec4(vs_color*extinction*vs_starBrightness*multipliedOpacityCoefficient, 1.0);
|
||||
frag.color = fullColor;
|
||||
|
||||
frag.depth = vs_screenSpaceDepth;
|
||||
frag.gPosition = vs_position;
|
||||
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
void main() {
|
||||
vec4 p = vec4(inPosition, 1.0);
|
||||
|
||||
vec4 worldPosition = model * vec4(inPosition, 1.0);
|
||||
worldPosition.w = 0.0;
|
||||
vec4 position = worldPosition; //pscTransform(worldPosition, model);
|
||||
|
||||
|
||||
position = pscTransform(position, mat4(1.0));
|
||||
vsPosition = position.xyz;
|
||||
position = projection * view * position;
|
||||
gl_Position = z_normalization(position);
|
||||
vsColor = inColor;
|
||||
return frag;
|
||||
}
|
||||
@@ -24,23 +24,37 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
#include "hdr.glsl"
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
layout (location = 0) out vec4 finalColor;
|
||||
layout(location = 0) in vec3 in_position;
|
||||
layout(location = 1) in vec3 in_color;
|
||||
|
||||
uniform int nAaSamples;
|
||||
uniform float backgroundConstant;
|
||||
uniform float backgroundExposure;
|
||||
uniform sampler2DMS mainColorTexture;
|
||||
out vec4 vs_position;
|
||||
out vec3 vs_color;
|
||||
out float vs_screenSpaceDepth;
|
||||
out float vs_starBrightness;
|
||||
|
||||
uniform dmat4 cameraViewProjectionMatrix;
|
||||
uniform dmat4 modelMatrix;
|
||||
uniform dvec3 eyePosition;
|
||||
|
||||
const double PARSEC = 3.08567756E16;
|
||||
|
||||
void main() {
|
||||
vec4 color = vec4(0.0);
|
||||
for (int i = 0; i < nAaSamples; i++) {
|
||||
color += texelFetch(mainColorTexture, ivec2(gl_FragCoord), i);
|
||||
}
|
||||
vs_position = vec4(in_position, 1.0);
|
||||
dvec4 dpos = dvec4(vs_position);
|
||||
|
||||
color /= nAaSamples;
|
||||
// color.rgb *= blackoutFactor;
|
||||
|
||||
finalColor = vec4(HDR(color.rgb * backgroundConstant, backgroundExposure), 1.0);
|
||||
double distanceToStar = length((dpos.xyz - eyePosition));
|
||||
vs_starBrightness = clamp(float(8000*PARSEC/distanceToStar), 0.0, 1.0);
|
||||
|
||||
dpos.xyz *= 8.0;
|
||||
dpos = modelMatrix * dpos;
|
||||
dpos /= PARSEC;
|
||||
//It lies about 8 kpc from the center on what is known as the Orion Arm of the Milky Way
|
||||
dpos.x += 8000;
|
||||
|
||||
vec4 positionScreenSpace = z_normalization(vec4(cameraViewProjectionMatrix * dpos));
|
||||
vs_color = in_color;
|
||||
vs_screenSpaceDepth = positionScreenSpace.w;
|
||||
gl_Position = positionScreenSpace;
|
||||
}
|
||||
@@ -22,22 +22,25 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
#include "floatoperations.glsl"
|
||||
#include "fragment.glsl"
|
||||
|
||||
in vec3 vPosition;
|
||||
in vec4 worldPosition;
|
||||
|
||||
uniform uint blendMode;
|
||||
|
||||
in vec3 modelPosition;
|
||||
in vec4 viewPosition;
|
||||
|
||||
Fragment getFragment() {
|
||||
vec4 position = worldPosition;
|
||||
float depth = pscDepth(position);
|
||||
|
||||
Fragment frag;
|
||||
frag.color = vec4((vPosition + 0.5), 1.0);
|
||||
frag.depth = depth;
|
||||
frag.blend = blendMode;
|
||||
//Early ray termination on black parts of the data
|
||||
/*vec3 normalizedPos = (modelPosition*2.0)-1.0;
|
||||
if(abs(modelPosition.x) > 0.9 || abs(modelPosition.y) > 0.9){
|
||||
frag.color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
else{*/
|
||||
vec3 pos = modelPosition + 0.5;
|
||||
//vec3 posClamp = clamp(pos, vec3(0.0), vec3(1.0));
|
||||
frag.color = vec4(pos, 1.0);
|
||||
//}
|
||||
|
||||
frag.depth = safeLength(viewPosition);
|
||||
return frag;
|
||||
}
|
||||
@@ -24,23 +24,20 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
layout(location = 0) in vec4 vertPosition;
|
||||
|
||||
out vec3 vPosition;
|
||||
out vec4 worldPosition;
|
||||
out vec3 modelPosition;
|
||||
out vec4 viewPosition;
|
||||
|
||||
uniform mat4 viewProjection;
|
||||
uniform mat4 modelTransform;
|
||||
uniform mat4 modelViewTransform;
|
||||
|
||||
|
||||
void main() {
|
||||
vPosition = vertPosition.xyz;
|
||||
modelPosition = vertPosition.xyz;
|
||||
viewPosition = modelViewTransform*vertPosition;
|
||||
|
||||
worldPosition = modelTransform * vec4(vertPosition.xyz, 1.0);
|
||||
worldPosition.w = 0.0;
|
||||
vec4 position = pscTransform(worldPosition, mat4(1.0));
|
||||
|
||||
gl_Position = z_normalization(viewProjection * position);
|
||||
// project the position to view space
|
||||
gl_Position = viewProjection * viewPosition;
|
||||
gl_Position.z = 0.0;
|
||||
}
|
||||
@@ -33,7 +33,6 @@
|
||||
layout(location = 1) in vec2 in_uv;
|
||||
|
||||
out vec4 fs_position;
|
||||
out vec3 fs_normal;
|
||||
out vec2 fs_uv;
|
||||
out vec3 ellipsoidNormalCameraSpace;
|
||||
out vec3 levelWeights;
|
||||
@@ -126,7 +125,6 @@ void main() {
|
||||
fs_position = z_normalization(positionClippingSpace);
|
||||
gl_Position = fs_position;
|
||||
ellipsoidNormalCameraSpace = mat3(modelViewTransform) * pair.normal;
|
||||
fs_normal = pair.normal;
|
||||
positionCameraSpace = vec3(modelViewTransform * vec4(pair.position, 1.0));
|
||||
|
||||
#if USE_ECLIPSE_SHADOWS
|
||||
|
||||
@@ -34,7 +34,6 @@ layout(location = 1) in vec2 in_uv;
|
||||
|
||||
out vec2 fs_uv;
|
||||
out vec4 fs_position;
|
||||
out vec3 fs_normal;
|
||||
out vec3 ellipsoidNormalCameraSpace;
|
||||
out vec3 levelWeights;
|
||||
out vec3 positionCameraSpace;
|
||||
@@ -56,7 +55,6 @@ uniform vec3 p10;
|
||||
uniform vec3 p01;
|
||||
uniform vec3 p11;
|
||||
uniform vec3 patchNormalCameraSpace;
|
||||
uniform vec3 patchNormalModelSpace;
|
||||
uniform float chunkMinHeight;
|
||||
|
||||
uniform float distanceScaleFactor;
|
||||
@@ -110,7 +108,6 @@ void main() {
|
||||
fs_position = z_normalization(positionClippingSpace);
|
||||
gl_Position = fs_position;
|
||||
ellipsoidNormalCameraSpace = patchNormalCameraSpace;
|
||||
fs_normal = patchNormalModelSpace;
|
||||
positionCameraSpace = p;
|
||||
|
||||
#if USE_ECLIPSE_SHADOWS
|
||||
|
||||
@@ -129,7 +129,6 @@ vec4 calcShadow(const ShadowRenderingStruct shadowInfoArray[numberOfShadows],
|
||||
#endif
|
||||
|
||||
in vec4 fs_position;
|
||||
in vec3 fs_normal;
|
||||
in vec2 fs_uv;
|
||||
in vec3 ellipsoidNormalCameraSpace;
|
||||
in vec3 levelWeights;
|
||||
@@ -138,10 +137,6 @@ in vec3 positionCameraSpace;
|
||||
#if USE_ACCURATE_NORMALS
|
||||
in vec3 ellipsoidTangentThetaCameraSpace;
|
||||
in vec3 ellipsoidTangentPhiCameraSpace;
|
||||
|
||||
// Once deferred light calculations are done in view space this can be removed
|
||||
// so that we only need one normal; in view space.
|
||||
uniform mat4 invViewModelTransform;
|
||||
#endif // USE_ACCURATE_NORMALS
|
||||
|
||||
#if USE_ECLIPSE_SHADOWS
|
||||
@@ -152,11 +147,10 @@ in vec3 positionWorldSpace;
|
||||
|
||||
Fragment getFragment() {
|
||||
Fragment frag;
|
||||
|
||||
frag.color = vec4(0.3, 0.3, 0.3, 1.0);
|
||||
|
||||
vec3 normal = normalize(ellipsoidNormalCameraSpace);
|
||||
vec3 normalModelSpace = normalize(fs_normal);
|
||||
|
||||
#if USE_ACCURATE_NORMALS
|
||||
normal = getTileNormal(
|
||||
fs_uv,
|
||||
@@ -165,9 +159,6 @@ Fragment getFragment() {
|
||||
normalize(ellipsoidTangentThetaCameraSpace),
|
||||
normalize(ellipsoidTangentPhiCameraSpace)
|
||||
);
|
||||
// Once deferred light calculations are done in view space this can be removed
|
||||
// so that we only need one normal; in view space.
|
||||
normalModelSpace = normalize(mat3(invViewModelTransform) * normal);
|
||||
#endif /// USE_ACCURATE_NORMALS
|
||||
|
||||
#if USE_COLORTEXTURE
|
||||
@@ -243,11 +234,8 @@ Fragment getFragment() {
|
||||
#else
|
||||
frag.gNormal.w = 0;
|
||||
#endif
|
||||
// Normal is written Object Space.
|
||||
// Right now the only renderable using this info is the atm and,
|
||||
// because all calculation for light interactions are done in Object
|
||||
// Space, we avoid a new computation saving the normals in Object Space.
|
||||
frag.gNormal.xyz = normalModelSpace;
|
||||
// Normal is written View Space (Including SGCT View Matrix).
|
||||
frag.gNormal.xyz = normal;
|
||||
|
||||
if (dot(positionCameraSpace, vec3(1.0)) != 0.0) {
|
||||
frag.gPosition = vec4(positionCameraSpace, 1.0); // in Camera Rig Space
|
||||
|
||||
@@ -761,8 +761,7 @@ void RenderableGlobe::update(const UpdateData& data) {
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_localRenderer.program,
|
||||
_localRenderer.uniformCache,
|
||||
{ "skirtLength", "p01", "p11", "p00", "p10", "patchNormalModelSpace",
|
||||
"patchNormalCameraSpace" }
|
||||
{ "skirtLength", "p01", "p11", "p00", "p10", "patchNormalCameraSpace" }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1024,27 +1023,6 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&) {
|
||||
);
|
||||
}
|
||||
|
||||
if (_generalProperties.useAccurateNormals &&
|
||||
!_layerManager.layerGroup(layergroupid::HeightLayers).activeLayers().empty())
|
||||
{
|
||||
// This should not be needed once the light calculations for the atmosphere
|
||||
// is performed in view space..
|
||||
_localRenderer.program->setUniform(
|
||||
"invViewModelTransform",
|
||||
glm::inverse(
|
||||
glm::mat4(data.camera.combinedViewMatrix()) *
|
||||
glm::mat4(_cachedModelTransform)
|
||||
)
|
||||
);
|
||||
_globalRenderer.program->setUniform(
|
||||
"invViewModelTransform",
|
||||
glm::inverse(
|
||||
glm::mat4(data.camera.combinedViewMatrix()) *
|
||||
glm::mat4(_cachedModelTransform)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
constexpr const int ChunkBufferSize = 2048;
|
||||
std::array<const Chunk*, ChunkBufferSize> global;
|
||||
int globalCount = 0;
|
||||
@@ -1274,6 +1252,7 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d
|
||||
|
||||
// TODO: Patch normal can be calculated for all corners and then linearly
|
||||
// interpolated on the GPU to avoid cracks for high altitudes.
|
||||
// JCC: Camera space includes the SGCT View transformation.
|
||||
const glm::vec3 patchNormalCameraSpace = normalize(
|
||||
cross(
|
||||
cornersCameraSpace[Quad::SOUTH_EAST] - cornersCameraSpace[Quad::SOUTH_WEST],
|
||||
@@ -1281,19 +1260,6 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d
|
||||
)
|
||||
);
|
||||
|
||||
// In order to improve performance, lets use the normal in object space (model space)
|
||||
// for deferred rendering.
|
||||
const glm::vec3 patchNormalModelSpace = normalize(
|
||||
cross(
|
||||
cornersModelSpace[Quad::SOUTH_EAST] - cornersModelSpace[Quad::SOUTH_WEST],
|
||||
cornersModelSpace[Quad::NORTH_EAST] - cornersModelSpace[Quad::SOUTH_WEST]
|
||||
)
|
||||
);
|
||||
|
||||
program.setUniform(
|
||||
_localRenderer.uniformCache.patchNormalModelSpace,
|
||||
patchNormalModelSpace
|
||||
);
|
||||
program.setUniform(
|
||||
_localRenderer.uniformCache.patchNormalCameraSpace,
|
||||
patchNormalCameraSpace
|
||||
@@ -1598,8 +1564,7 @@ void RenderableGlobe::recompileShaders() {
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_localRenderer.program,
|
||||
_localRenderer.uniformCache,
|
||||
{ "skirtLength", "p01", "p11", "p00", "p10", "patchNormalModelSpace",
|
||||
"patchNormalCameraSpace" }
|
||||
{ "skirtLength", "p01", "p11", "p00", "p10", "patchNormalCameraSpace" }
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ Fragment getFragment() {
|
||||
frag.depth = gs_screenSpaceDepth;
|
||||
frag.gPosition = vs_position;
|
||||
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
frag.disableLDR2HDR = true;
|
||||
|
||||
return frag;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,8 @@ Paths = {
|
||||
LOGS = "${BASE}/logs",
|
||||
MODULES = "${BASE}/modules",
|
||||
SCRIPTS = "${BASE}/scripts",
|
||||
SHADERS = "${BASE}/shaders"
|
||||
SHADERS = "${BASE}/shaders",
|
||||
TEMPORARY = "${BASE}/temp"
|
||||
}
|
||||
|
||||
ModuleConfigurations = {
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#define ITERATIONS 12
|
||||
#define SUBPIXEL_QUALITY 0.75f
|
||||
|
||||
const float[12] QUALITY = {1.f, 1.f, 1.f, 1.f, 1.f, 1.5f, 2.f, 2.f, 2.f, 2.f, 4.f, 8.f};
|
||||
const float[12] QUALITY = float[](1.f, 1.f, 1.f, 1.f, 1.f, 1.5f, 2.f, 2.f, 2.f, 2.f, 4.f, 8.f);
|
||||
// const float[24] QUALITY = {2.f, 4.f, 6.f, 8.f, 10.f, 12.f, 12.f, 12.f, 12.f, 12.f, 14.f, 18.f,
|
||||
// 18.f, 18.f, 18.f, 18.f, 18.f, 18.f, 18.f, 18.f, 18.f, 18.f,
|
||||
// 18.f, 18.f};
|
||||
@@ -53,25 +53,21 @@ void main() {
|
||||
// Detecting where to apply AA:
|
||||
// ============================
|
||||
|
||||
// Luma at the current fragment
|
||||
float lumaCenter = getLum(colorCenter.rgb);
|
||||
|
||||
// Luma at the four direct neighbours of the current fragment.
|
||||
float lumaDown = getLum(textureOffset(renderedTexture, texCoord, ivec2(0,-1)).rgb);
|
||||
float lumaUp = getLum(textureOffset(renderedTexture, texCoord, ivec2(0,1)).rgb);
|
||||
float lumaLeft = getLum(textureOffset(renderedTexture, texCoord, ivec2(-1,0)).rgb);
|
||||
float lumaRight = getLum(textureOffset(renderedTexture, texCoord, ivec2(1,0)).rgb);
|
||||
float pixelLumCenter = getLum(colorCenter.rgb);
|
||||
float pixelLumDown = getLum(textureOffset(renderedTexture, texCoord, ivec2(0,-1)).rgb);
|
||||
float pixelLumUp = getLum(textureOffset(renderedTexture, texCoord, ivec2(0,1)).rgb);
|
||||
float pixelLumLeft = getLum(textureOffset(renderedTexture, texCoord, ivec2(-1,0)).rgb);
|
||||
float pixelLumRight = getLum(textureOffset(renderedTexture, texCoord, ivec2(1,0)).rgb);
|
||||
|
||||
// Find the maximum and minimum luma around the current fragment.
|
||||
float lumaMin = min(lumaCenter, min(min(lumaDown, lumaUp), min(lumaLeft, lumaRight)));
|
||||
float lumaMax = max(lumaCenter, max(max(lumaDown, lumaUp), max(lumaLeft, lumaRight)));
|
||||
float pixelLumMin = min(pixelLumCenter, min(min(pixelLumDown, pixelLumUp), min(pixelLumLeft, pixelLumRight)));
|
||||
float pixelLumMax = max(pixelLumCenter, max(max(pixelLumDown, pixelLumUp), max(pixelLumLeft, pixelLumRight)));
|
||||
|
||||
// Compute the delta.
|
||||
float lumaRange = lumaMax - lumaMin;
|
||||
// Delta.
|
||||
float pixelLumRange = pixelLumMax - pixelLumMin;
|
||||
|
||||
// If the luma variation is lower that a threshold (or if we are in a really dark area),
|
||||
// If the pixelLum variation is lower that a threshold (or if we are in a really dark area),
|
||||
// we are not on an edge, don't perform any AA.
|
||||
if (lumaRange < max(EDGE_THRESHOLD_MIN, lumaMax * EDGE_THRESHOLD_MAX)) {
|
||||
if (pixelLumRange < max(EDGE_THRESHOLD_MIN, pixelLumMax * EDGE_THRESHOLD_MAX)) {
|
||||
aaFinalColor = colorCenter;
|
||||
return;
|
||||
}
|
||||
@@ -79,64 +75,50 @@ void main() {
|
||||
// ============================
|
||||
// Estimating the gradient:
|
||||
// ============================
|
||||
// Query the 4 remaining corners lumas.
|
||||
float lumaDownLeft = getLum(textureOffset(renderedTexture, texCoord, ivec2(-1,-1)).rgb);
|
||||
float lumaUpRight = getLum(textureOffset(renderedTexture, texCoord, ivec2(1,1)).rgb);
|
||||
float lumaUpLeft = getLum(textureOffset(renderedTexture, texCoord, ivec2(-1,1)).rgb);
|
||||
float lumaDownRight = getLum(textureOffset(renderedTexture, texCoord, ivec2(1,-1)).rgb);
|
||||
float pixelLumDownLeft = getLum(textureOffset(renderedTexture, texCoord, ivec2(-1,-1)).rgb);
|
||||
float pixelLumUpRight = getLum(textureOffset(renderedTexture, texCoord, ivec2(1,1)).rgb);
|
||||
float pixelLumUpLeft = getLum(textureOffset(renderedTexture, texCoord, ivec2(-1,1)).rgb);
|
||||
float pixelLumDownRight = getLum(textureOffset(renderedTexture, texCoord, ivec2(1,-1)).rgb);
|
||||
|
||||
// Combine the four edges lumas (using intermediary variables for future computations
|
||||
// with the same values).
|
||||
float lumaDownUp = lumaDown + lumaUp;
|
||||
float lumaLeftRight = lumaLeft + lumaRight;
|
||||
float pixelLumDownUp = pixelLumDown + pixelLumUp;
|
||||
float pixelLumLeftRight = pixelLumLeft + pixelLumRight;
|
||||
float pixelLumLeftCorners = pixelLumDownLeft + pixelLumUpLeft;
|
||||
float pixelLumDownCorners = pixelLumDownLeft + pixelLumDownRight;
|
||||
float pixelLumRightCorners = pixelLumDownRight + pixelLumUpRight;
|
||||
float pixelLumUpCorners = pixelLumUpRight + pixelLumUpLeft;
|
||||
|
||||
// Same for corners
|
||||
float lumaLeftCorners = lumaDownLeft + lumaUpLeft;
|
||||
float lumaDownCorners = lumaDownLeft + lumaDownRight;
|
||||
float lumaRightCorners = lumaDownRight + lumaUpRight;
|
||||
float lumaUpCorners = lumaUpRight + lumaUpLeft;
|
||||
|
||||
// Compute an estimation of the gradient along the horizontal and vertical axis.
|
||||
float edgeHorizontal = abs(-2.0 * lumaLeft + lumaLeftCorners) +
|
||||
abs(-2.0 * lumaCenter + lumaDownUp ) * 2.0 + abs(-2.0 * lumaRight + lumaRightCorners);
|
||||
float edgeVertical = abs(-2.0 * lumaUp + lumaUpCorners) +
|
||||
abs(-2.0 * lumaCenter + lumaLeftRight) * 2.0 + abs(-2.0 * lumaDown + lumaDownCorners);
|
||||
|
||||
// Is the local edge horizontal or vertical ?
|
||||
bool isHorizontal = (edgeHorizontal >= edgeVertical);
|
||||
// Compute an estimation of the gradient
|
||||
float edgeHorizontal = abs(-2.0 * pixelLumLeft + pixelLumLeftCorners) +
|
||||
abs(-2.0 * pixelLumCenter + pixelLumDownUp ) * 2.0 + abs(-2.0 * pixelLumRight + pixelLumRightCorners);
|
||||
float edgeVertical = abs(-2.0 * pixelLumUp + pixelLumUpCorners) +
|
||||
abs(-2.0 * pixelLumCenter + pixelLumLeftRight) * 2.0 + abs(-2.0 * pixelLumDown + pixelLumDownCorners);
|
||||
|
||||
// ============================
|
||||
// Choosing Edge Orientation:
|
||||
// ============================
|
||||
// Select the two neighboring texels lumas in the opposite direction to the local edge.
|
||||
float luma1 = isHorizontal ? lumaDown : lumaLeft;
|
||||
float luma2 = isHorizontal ? lumaUp : lumaRight;
|
||||
bool isHorizontal = (edgeHorizontal >= edgeVertical);
|
||||
float pixelLum1 = isHorizontal ? pixelLumDown : pixelLumLeft;
|
||||
float pixelLum2 = isHorizontal ? pixelLumUp : pixelLumRight;
|
||||
|
||||
// Compute gradients in this direction.
|
||||
float gradient1 = luma1 - lumaCenter;
|
||||
float gradient2 = luma2 - lumaCenter;
|
||||
// Gradients
|
||||
float gradient1 = pixelLum1 - pixelLumCenter;
|
||||
float gradient2 = pixelLum2 - pixelLumCenter;
|
||||
|
||||
// Which direction is the steepest ?
|
||||
bool is1Steepest = abs(gradient1) >= abs(gradient2);
|
||||
|
||||
// Gradient in the corresponding direction, normalized.
|
||||
float gradientScaled = 0.25 * max(abs(gradient1), abs(gradient2));
|
||||
|
||||
// Choose the step size (one pixel) according to the edge direction.
|
||||
// Step size (one pixel) according to the edge direction.
|
||||
float stepLength = isHorizontal ? inverseScreenSize.y : inverseScreenSize.x;
|
||||
|
||||
// Average luma in the correct direction.
|
||||
float lumaLocalAverage = 0.0;
|
||||
float pixelLumLocalAverage = 0.0;
|
||||
|
||||
if (is1Steepest) {
|
||||
// Switch the direction
|
||||
stepLength = - stepLength;
|
||||
lumaLocalAverage = 0.5 * (luma1 + lumaCenter);
|
||||
pixelLumLocalAverage = 0.5 * (pixelLum1 + pixelLumCenter);
|
||||
} else {
|
||||
lumaLocalAverage = 0.5 * (luma2 + lumaCenter);
|
||||
pixelLumLocalAverage = 0.5 * (pixelLum2 + pixelLumCenter);
|
||||
}
|
||||
|
||||
// Shift UV in the correct direction by half a pixel.
|
||||
vec2 currentUv = texCoord;
|
||||
if (isHorizontal) {
|
||||
currentUv.y += stepLength * 0.5;
|
||||
@@ -147,28 +129,22 @@ void main() {
|
||||
// ============================
|
||||
// Iterations:
|
||||
// ============================
|
||||
// Compute offset (for each iteration step) in the right direction.
|
||||
vec2 offset = isHorizontal ? vec2(inverseScreenSize.x, 0.0) : vec2(0.0, inverseScreenSize.y);
|
||||
|
||||
// Compute UVs to explore on each side of the edge, orthogonally.
|
||||
// The QUALITY allows us to step faster.
|
||||
vec2 uv1 = currentUv - offset;
|
||||
vec2 uv2 = currentUv + offset;
|
||||
|
||||
// Read the lumas at both current extremities of the exploration segment,
|
||||
// and compute the delta wrt to the local average luma.
|
||||
float lumaEnd1 = getLum(texture(renderedTexture, uv1).rgb);
|
||||
float lumaEnd2 = getLum(texture(renderedTexture, uv2).rgb);
|
||||
lumaEnd1 -= lumaLocalAverage;
|
||||
lumaEnd2 -= lumaLocalAverage;
|
||||
// Read the pixelLums at both current extremities of the exploration segment,
|
||||
// and compute the delta wrt to the local average pixelLum.
|
||||
float pixelLumEnd1 = getLum(texture(renderedTexture, uv1).rgb);
|
||||
float pixelLumEnd2 = getLum(texture(renderedTexture, uv2).rgb);
|
||||
pixelLumEnd1 -= pixelLumLocalAverage;
|
||||
pixelLumEnd2 -= pixelLumLocalAverage;
|
||||
|
||||
// If the luma deltas at the current extremities are larger than the local gradient,
|
||||
// we have reached the side of the edge.
|
||||
bool reached1 = abs(lumaEnd1) >= gradientScaled;
|
||||
bool reached2 = abs(lumaEnd2) >= gradientScaled;
|
||||
bool reached1 = abs(pixelLumEnd1) >= gradientScaled;
|
||||
bool reached2 = abs(pixelLumEnd2) >= gradientScaled;
|
||||
bool reachedBoth = reached1 && reached2;
|
||||
|
||||
// If the side is not reached, we continue to explore in this direction.
|
||||
if (!reached1) {
|
||||
uv1 -= offset;
|
||||
}
|
||||
@@ -177,27 +153,24 @@ void main() {
|
||||
uv2 += offset;
|
||||
}
|
||||
|
||||
// If both sides have not been reached, continue to explore.
|
||||
// Still exploring
|
||||
if (!reachedBoth) {
|
||||
for (int i = 2; i < ITERATIONS; i++) {
|
||||
// If needed, read luma in 1st direction, compute delta.
|
||||
// If needed, read pixelLum in 1st direction, compute delta.
|
||||
if (!reached1) {
|
||||
lumaEnd1 = getLum(texture(renderedTexture, uv1).rgb);
|
||||
lumaEnd1 = lumaEnd1 - lumaLocalAverage;
|
||||
pixelLumEnd1 = getLum(texture(renderedTexture, uv1).rgb);
|
||||
pixelLumEnd1 = pixelLumEnd1 - pixelLumLocalAverage;
|
||||
}
|
||||
// If needed, read luma in opposite direction, compute delta.
|
||||
// If needed, read pixelLum in opposite direction, compute delta.
|
||||
if (!reached2) {
|
||||
lumaEnd2 = getLum(texture(renderedTexture, uv2).rgb);
|
||||
lumaEnd2 = lumaEnd2 - lumaLocalAverage;
|
||||
pixelLumEnd2 = getLum(texture(renderedTexture, uv2).rgb);
|
||||
pixelLumEnd2 = pixelLumEnd2 - pixelLumLocalAverage;
|
||||
}
|
||||
// If the luma deltas at the current extremities is larger than
|
||||
// the local gradient, we have reached the side of the edge.
|
||||
reached1 = abs(lumaEnd1) >= gradientScaled;
|
||||
reached2 = abs(lumaEnd2) >= gradientScaled;
|
||||
reached1 = abs(pixelLumEnd1) >= gradientScaled;
|
||||
reached2 = abs(pixelLumEnd2) >= gradientScaled;
|
||||
reachedBoth = reached1 && reached2;
|
||||
|
||||
// If the side is not reached, we continue to explore in this direction,
|
||||
// with a variable quality.
|
||||
// If the side is not reached
|
||||
if (!reached1) {
|
||||
uv1 -= offset * QUALITY[i];
|
||||
}
|
||||
@@ -206,7 +179,7 @@ void main() {
|
||||
uv2 += offset * QUALITY[i];
|
||||
}
|
||||
|
||||
// If both sides have been reached, stop the exploration.
|
||||
// If both sides have been reached
|
||||
if (reachedBoth) {
|
||||
break;
|
||||
}
|
||||
@@ -216,55 +189,45 @@ void main() {
|
||||
// ============================
|
||||
// Estimating the offset:
|
||||
// ============================
|
||||
// Compute the distances to each extremity of the edge.
|
||||
float distance1 = isHorizontal ? (texCoord.x - uv1.x) : (texCoord.y - uv1.y);
|
||||
float distance2 = isHorizontal ? (uv2.x - texCoord.x) : (uv2.y - texCoord.y);
|
||||
|
||||
// In which direction is the extremity of the edge closer ?
|
||||
bool isDirection1 = distance1 < distance2;
|
||||
float distanceFinal = min(distance1, distance2);
|
||||
|
||||
// Length of the edge.
|
||||
float edgeThickness = (distance1 + distance2);
|
||||
|
||||
// UV offset: read in the direction of the closest side of the edge.
|
||||
// Read in the direction of the closest side of the edge.
|
||||
float pixelOffset = - distanceFinal / edgeThickness + 0.5;
|
||||
|
||||
// Is the luma at center smaller than the local average ?
|
||||
bool isLumaCenterSmaller = lumaCenter < lumaLocalAverage;
|
||||
bool ispixelLumCenterSmaller = pixelLumCenter < pixelLumLocalAverage;
|
||||
|
||||
// If the luma at center is smaller than at its neighbour, the delta luma at
|
||||
// If the pixelLum at center is smaller than at its neighbour, the delta pixelLum at
|
||||
// each end should be positive (same variation).
|
||||
// (in the direction of the closer side of the edge.)
|
||||
bool correctVariation = ((isDirection1 ? lumaEnd1 : lumaEnd2) < 0.0) != isLumaCenterSmaller;
|
||||
bool correctVariation = ((isDirection1 ? pixelLumEnd1 : pixelLumEnd2) < 0.0) != ispixelLumCenterSmaller;
|
||||
|
||||
// If the luma variation is incorrect, do not offset.
|
||||
// If the pixelLum variation is incorrect, do not offset.
|
||||
float finalOffset = correctVariation ? pixelOffset : 0.0;
|
||||
|
||||
// ============================
|
||||
// Subpixel antialiasing:
|
||||
// ============================
|
||||
// Sub-pixel shifting
|
||||
// Full weighted average of the luma over the 3x3 neighborhood.
|
||||
float lumaAverage = (1.0/12.0) * (2.0 * (lumaDownUp + lumaLeftRight) +
|
||||
lumaLeftCorners + lumaRightCorners);
|
||||
// Ratio of the delta between the global average and the center luma, over the luma range in the 3x3 neighborhood.
|
||||
float subPixelOffset1 = clamp(abs(lumaAverage - lumaCenter) / lumaRange, 0.0, 1.0);
|
||||
float subPixelOffset2 = (-2.0 * subPixelOffset1 + 3.0) * subPixelOffset1 * subPixelOffset1;
|
||||
// Compute a sub-pixel offset based on this delta.
|
||||
float pixelLumAverage = (1.0/12.0) * (2.0 * (pixelLumDownUp + pixelLumLeftRight) +
|
||||
pixelLumLeftCorners + pixelLumRightCorners);
|
||||
|
||||
float subPixelOffset1 = clamp(abs(pixelLumAverage - pixelLumCenter) / pixelLumRange, 0.0, 1.0);
|
||||
float subPixelOffset2 = (-2.0 * subPixelOffset1 + 3.0) * subPixelOffset1 * subPixelOffset1;
|
||||
float subPixelOffsetFinal = subPixelOffset2 * subPixelOffset2 * SUBPIXEL_QUALITY;
|
||||
|
||||
// Pick the biggest of the two offsets.
|
||||
// Biggest of the two offsets.
|
||||
finalOffset = max(finalOffset, subPixelOffsetFinal);
|
||||
|
||||
// Compute the final UV coordinates.
|
||||
vec2 finalUv = texCoord;
|
||||
vec2 finalUV = texCoord;
|
||||
if (isHorizontal) {
|
||||
finalUv.y += finalOffset * stepLength;
|
||||
finalUV.y += finalOffset * stepLength;
|
||||
} else {
|
||||
finalUv.x += finalOffset * stepLength;
|
||||
finalUV.x += finalOffset * stepLength;
|
||||
}
|
||||
|
||||
// Read the color at the new UV coordinates, and use it.
|
||||
aaFinalColor = texture(renderedTexture, finalUv);
|
||||
aaFinalColor = texture(renderedTexture, finalUV);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* *
|
||||
* 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__
|
||||
|
||||
in vec4 position;
|
||||
|
||||
out vec2 texCoord;
|
||||
out vec3 vPosition;
|
||||
out vec4 worldPosition;
|
||||
|
||||
void main() {
|
||||
gl_Position = position;
|
||||
texCoord = 0.5 + position.xy * 0.5;
|
||||
|
||||
vPosition = position.xyz;
|
||||
worldPosition = position;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* *
|
||||
* 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) out vec4 finalColor;
|
||||
|
||||
flat in vec3 vPosition;
|
||||
|
||||
void main() {
|
||||
finalColor = vec4(0.5 * vPosition + 0.5, 1.0);
|
||||
}
|
||||
@@ -53,7 +53,9 @@ void main() {
|
||||
vec2 texCoord = vec2(gl_FragCoord.xy / windowSize);
|
||||
|
||||
vec4 exitColorTexture = texture(exitColorTexture, texCoord);
|
||||
if (exitColorTexture.a < 1.0) {
|
||||
|
||||
// if we don't have an exit, discard the ray
|
||||
if (exitColorTexture.a < 1.0 || exitColorTexture.rgb == vec3(0.0)) {
|
||||
discard;
|
||||
}
|
||||
|
||||
@@ -66,6 +68,10 @@ void main() {
|
||||
vec3 entryPos;
|
||||
float entryDepth;
|
||||
getEntry(entryPos, entryDepth);
|
||||
// if we don't have an entry, discard the ray
|
||||
if (entryPos == vec3(0.0)) {
|
||||
discard;
|
||||
}
|
||||
|
||||
vec3 position = entryPos;
|
||||
vec3 diff = exitPos - entryPos;
|
||||
@@ -73,9 +79,6 @@ void main() {
|
||||
vec3 direction = normalize(diff);
|
||||
float raycastDepth = length(diff);
|
||||
|
||||
int i, j;
|
||||
float tmp;
|
||||
|
||||
float geoDepth = denormalizeFloat(texelFetch(mainDepthTexture, ivec2(gl_FragCoord), 0).x);
|
||||
float geoRatio = clamp((geoDepth - entryDepth) / (exitDepth - entryDepth), 0.0, 1.0);
|
||||
raycastDepth = geoRatio * raycastDepth;
|
||||
@@ -96,11 +99,14 @@ void main() {
|
||||
vec3 accumulatedAlpha = vec3(0.0);
|
||||
|
||||
|
||||
for (steps = 0; (accumulatedAlpha.r < ALPHA_LIMIT || accumulatedAlpha.g < ALPHA_LIMIT ||
|
||||
accumulatedAlpha.b < ALPHA_LIMIT) && steps < RAYCAST_MAX_STEPS; ++steps) {
|
||||
if (currentDepth + nextStepSize * jitterFactor > raycastDepth) {
|
||||
aaOpacity -= opacityDecay;
|
||||
}
|
||||
for (steps = 0;
|
||||
(accumulatedAlpha.r < ALPHA_LIMIT || accumulatedAlpha.g < ALPHA_LIMIT ||
|
||||
accumulatedAlpha.b < ALPHA_LIMIT) && steps < RAYCAST_MAX_STEPS;
|
||||
++steps)
|
||||
{
|
||||
// if (currentDepth + nextStepSize * jitterFactor > raycastDepth) {
|
||||
// aaOpacity -= opacityDecay;
|
||||
// }
|
||||
bool shortStepSize = nextStepSize < raycastDepth / 10000000000.0;
|
||||
|
||||
if (shortStepSize) {
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2019 *
|
||||
* *
|
||||
* 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) out vec4 finalColor;
|
||||
|
||||
uniform float blackoutFactor;
|
||||
uniform int nAaSamples;
|
||||
uniform sampler2DMS mainColorTexture;
|
||||
|
||||
void main() {
|
||||
vec4 color = vec4(0.0);
|
||||
for (int i = 0; i < nAaSamples; i++) {
|
||||
color += texelFetch(mainColorTexture, ivec2(gl_FragCoord), i);
|
||||
}
|
||||
|
||||
color /= nAaSamples;
|
||||
color.rgb *= blackoutFactor;
|
||||
|
||||
finalColor = vec4(color.rgb, 1.0);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ const mat3 XYZ2RGB = mat3(
|
||||
|
||||
// Gamma correction for linear RGB to sRGB
|
||||
// See wiki: https://en.wikipedia.org/wiki/SRGB#The_sRGB_transfer_function_.28.22gamma.22.29
|
||||
const float gammaF(const float u) {
|
||||
float gammaF(const float u) {
|
||||
if (u < 0.0031308) {
|
||||
return 12.92 * u;
|
||||
} else {
|
||||
|
||||
@@ -104,10 +104,7 @@ namespace openspace {
|
||||
|
||||
class Scene;
|
||||
|
||||
OpenSpaceEngine::OpenSpaceEngine()
|
||||
: _scene(nullptr)
|
||||
, _loadingScreen(nullptr)
|
||||
{
|
||||
OpenSpaceEngine::OpenSpaceEngine() {
|
||||
FactoryManager::initialize();
|
||||
FactoryManager::ref().addFactory(
|
||||
std::make_unique<ghoul::TemplateFactory<Renderable>>(),
|
||||
@@ -164,19 +161,20 @@ void OpenSpaceEngine::registerPathTokens() {
|
||||
ghoul::filesystem::FileSystem::TokenClosingBraces;
|
||||
LDEBUG(fmt::format("Registering path {}: {}", fullKey, path.second));
|
||||
|
||||
const bool override = (fullKey == "${BASE}");
|
||||
if (override) {
|
||||
const bool overrideBase = (fullKey == "${BASE}");
|
||||
if (overrideBase) {
|
||||
LINFO(fmt::format("Overriding base path with '{}'", path.second));
|
||||
}
|
||||
|
||||
const bool overrideTemporary = (fullKey == "${TEMPORARY}");
|
||||
|
||||
using Override = ghoul::filesystem::FileSystem::Override;
|
||||
FileSys.registerPathToken(
|
||||
std::move(fullKey),
|
||||
std::move(path.second),
|
||||
Override(override)
|
||||
Override(overrideBase || overrideTemporary)
|
||||
);
|
||||
}
|
||||
|
||||
LTRACE("OpenSpaceEngine::initialize(end)");
|
||||
}
|
||||
|
||||
@@ -808,6 +806,7 @@ void OpenSpaceEngine::deinitialize() {
|
||||
);
|
||||
}
|
||||
global::sessionRecording.deinitialize();
|
||||
global::versionChecker.cancel();
|
||||
|
||||
global::deinitialize();
|
||||
|
||||
|
||||
@@ -40,42 +40,39 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
const uint32_t ProtocolVersion = 3;
|
||||
const size_t MaxLatencyDiffs = 64;
|
||||
const char* _loggerCat = "ExternInteraction";
|
||||
constexpr const uint32_t ProtocolVersion = 3;
|
||||
constexpr const size_t MaxLatencyDiffs = 64;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo BufferTimeInfo = {
|
||||
"BufferTime",
|
||||
"Buffer Time",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo BufferTimeInfo = {
|
||||
"BufferTime",
|
||||
"Buffer Time",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TimeKeyFrameInfo = {
|
||||
"TimeKeyframeInterval",
|
||||
"Time keyframe interval",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo TimeKeyFrameInfo = {
|
||||
"TimeKeyframeInterval",
|
||||
"Time keyframe interval",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo CameraKeyFrameInfo = {
|
||||
"CameraKeyframeInterval",
|
||||
"Camera Keyframe interval",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TimeToleranceInfo = {
|
||||
"TimeTolerance",
|
||||
"Time tolerance",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo CameraKeyFrameInfo = {
|
||||
"CameraKeyframeInterval",
|
||||
"Camera Keyframe interval",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TimeToleranceInfo = {
|
||||
"TimeTolerance",
|
||||
"Time tolerance",
|
||||
"" // @TODO Missing documentation
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ExternInteraction::ExternInteraction()
|
||||
: properties::PropertyOwner({ "ExternInteration", "External Interaction" })
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void ExternInteraction::cameraInteraction(datamessagestructures::CameraKeyframe kf) {
|
||||
interaction::KeyframeNavigator::CameraPose pose;
|
||||
|
||||
@@ -369,7 +369,7 @@ void OrbitalNavigator::resetVelocities() {
|
||||
_websocketStates.resetVelocities();
|
||||
_scriptStates.resetVelocities();
|
||||
|
||||
if (shouldFollowAnchorRotation()) {
|
||||
if (shouldFollowAnchorRotation(_camera->positionVec3())) {
|
||||
_followRotationInterpolator.end();
|
||||
}
|
||||
else {
|
||||
@@ -459,6 +459,7 @@ void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) {
|
||||
anchorNodeRotationDiff = interpolateRotationDifferential(
|
||||
deltaTime,
|
||||
_followRotationInterpolationTime,
|
||||
pose.position,
|
||||
anchorNodeRotationDiff
|
||||
);
|
||||
|
||||
@@ -701,7 +702,8 @@ void OrbitalNavigator::setRetargetInterpolationTime(float durationInSeconds) {
|
||||
_retargetInterpolationTime = durationInSeconds;
|
||||
}
|
||||
|
||||
bool OrbitalNavigator::shouldFollowAnchorRotation() const {
|
||||
bool OrbitalNavigator::shouldFollowAnchorRotation(const glm::dvec3& cameraPosition) const
|
||||
{
|
||||
if (!_anchorNode) {
|
||||
return false;
|
||||
}
|
||||
@@ -709,7 +711,7 @@ bool OrbitalNavigator::shouldFollowAnchorRotation() const {
|
||||
const glm::dmat4 modelTransform = _anchorNode->modelTransform();
|
||||
const glm::dmat4 inverseModelTransform = _anchorNode->inverseModelTransform();
|
||||
const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform *
|
||||
glm::dvec4(_camera->positionVec3(), 1.0));
|
||||
glm::dvec4(cameraPosition, 1.0));
|
||||
|
||||
const SurfacePositionHandle positionHandle =
|
||||
_anchorNode->calculateSurfacePositionHandle(cameraPositionModelSpace);
|
||||
@@ -719,7 +721,7 @@ bool OrbitalNavigator::shouldFollowAnchorRotation() const {
|
||||
) * _followAnchorNodeRotationDistance;
|
||||
|
||||
const double distanceToCamera =
|
||||
glm::distance(_camera->positionVec3(), _anchorNode->worldPosition());
|
||||
glm::distance(cameraPosition, _anchorNode->worldPosition());
|
||||
|
||||
return distanceToCamera < maximumDistanceForRotation;
|
||||
}
|
||||
@@ -1277,10 +1279,12 @@ glm::dvec3 OrbitalNavigator::pushToSurface(double minHeightAboveGround,
|
||||
|
||||
glm::dquat OrbitalNavigator::interpolateRotationDifferential(double deltaTime,
|
||||
double interpolationTime,
|
||||
const glm::dvec3 cameraPosition,
|
||||
const glm::dquat& rotationDiff)
|
||||
{
|
||||
// Interpolate with a negative delta time if distance is too large to follow
|
||||
const double interpolationSign = shouldFollowAnchorRotation() ? 1.0 : -1.0;
|
||||
const double interpolationSign =
|
||||
shouldFollowAnchorRotation(cameraPosition) ? 1.0 : -1.0;
|
||||
|
||||
_followRotationInterpolator.setInterpolationTime(static_cast<float>(
|
||||
interpolationTime
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <ghoul/misc/invariants.h>
|
||||
#include <ghoul/misc/stringconversion.h>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <numeric>
|
||||
|
||||
|
||||
@@ -50,10 +50,6 @@
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "FramebufferRenderer";
|
||||
|
||||
constexpr const std::array<const char*, 2> UniformNames = {
|
||||
"mainColorTexture", "blackoutFactor"
|
||||
};
|
||||
|
||||
constexpr const std::array<const char*, 7> HDRUniformNames = {
|
||||
"hdrFeedingTexture", "blackoutFactor", "hdrExposure", "gamma",
|
||||
"Hue", "Saturation", "Value"
|
||||
@@ -320,17 +316,6 @@ void FramebufferRenderer::initialize() {
|
||||
// Sets back to default FBO
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO);
|
||||
|
||||
_resolveProgram = ghoul::opengl::ProgramObject::Build(
|
||||
"Framebuffer Resolve",
|
||||
absPath("${SHADERS}/framebuffer/resolveframebuffer.vert"),
|
||||
absPath("${SHADERS}/framebuffer/resolveframebuffer.frag")
|
||||
);
|
||||
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_resolveProgram,
|
||||
_uniformCache,
|
||||
UniformNames
|
||||
);
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_hdrFilteringProgram,
|
||||
_hdrUniformCache,
|
||||
@@ -475,15 +460,6 @@ void FramebufferRenderer::update() {
|
||||
updateDeferredcastData();
|
||||
}
|
||||
|
||||
if (_resolveProgram->isDirty()) {
|
||||
_resolveProgram->rebuildFromFile();
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_resolveProgram,
|
||||
_uniformCache,
|
||||
UniformNames
|
||||
);
|
||||
}
|
||||
|
||||
if (_hdrFilteringProgram->isDirty()) {
|
||||
_hdrFilteringProgram->rebuildFromFile();
|
||||
|
||||
|
||||
@@ -309,6 +309,12 @@ RenderEngine::RenderEngine()
|
||||
addProperty(_showVersionInfo);
|
||||
addProperty(_showCameraInfo);
|
||||
|
||||
// @TODO (maci 2019-08-23) disabling FXAA on
|
||||
// MacOS for now until we have fix or MSAA option.
|
||||
#ifdef __APPLE__
|
||||
_enableFXAA = false;
|
||||
#endif
|
||||
|
||||
_enableFXAA.onChange([this]() {
|
||||
if (_renderer) {
|
||||
_renderer->enableFXAA(_enableFXAA);
|
||||
@@ -935,6 +941,14 @@ void RenderEngine::setGlobalBlackOutFactor(float opacity) {
|
||||
_globalBlackOutFactor = opacity;
|
||||
}
|
||||
|
||||
float RenderEngine::hdrExposure() const {
|
||||
return _hdrExposure;
|
||||
}
|
||||
|
||||
bool RenderEngine::isHdrDisabled() const {
|
||||
return _disableHDRPipeline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a program object for rendering with the used renderer
|
||||
*/
|
||||
@@ -1075,7 +1089,7 @@ void RenderEngine::setRenderer(std::unique_ptr<Renderer> renderer) {
|
||||
|
||||
_renderer = std::move(renderer);
|
||||
_renderer->setResolution(renderingResolution());
|
||||
_renderer->enableFXAA(true);
|
||||
_renderer->enableFXAA(_enableFXAA);
|
||||
_renderer->setHDRExposure(_hdrExposure);
|
||||
_renderer->initialize();
|
||||
}
|
||||
|
||||
@@ -500,7 +500,9 @@ void ScreenSpaceRenderable::createShaders() {
|
||||
ghoul::Dictionary rendererData = {
|
||||
{ "fragmentRendererPath", "${SHADERS}/framebuffer/renderframebuffer.frag" },
|
||||
{ "windowWidth" , res.x },
|
||||
{ "windowHeight" , res.y }
|
||||
{ "windowHeight" , res.y },
|
||||
{ "hdrExposure", global::renderEngine.hdrExposure() },
|
||||
{ "disableHDR", global::renderEngine.isHdrDisabled() }
|
||||
};
|
||||
|
||||
dict.setValue("rendererData", rendererData);
|
||||
|
||||
@@ -123,11 +123,13 @@ std::unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
|
||||
));
|
||||
return nullptr;
|
||||
}
|
||||
result->addPropertySubOwner(result->_transform.translation.get());
|
||||
LDEBUG(fmt::format(
|
||||
"Successfully created ephemeris for '{}'", result->identifier()
|
||||
));
|
||||
}
|
||||
if (result->_transform.translation) {
|
||||
result->addPropertySubOwner(result->_transform.translation.get());
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(KeyTransformRotation)) {
|
||||
ghoul::Dictionary rotationDictionary;
|
||||
@@ -139,11 +141,13 @@ std::unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
|
||||
));
|
||||
return nullptr;
|
||||
}
|
||||
result->addPropertySubOwner(result->_transform.rotation.get());
|
||||
LDEBUG(fmt::format(
|
||||
"Successfully created rotation for '{}'", result->identifier()
|
||||
));
|
||||
}
|
||||
if (result->_transform.rotation) {
|
||||
result->addPropertySubOwner(result->_transform.rotation.get());
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(KeyTransformScale)) {
|
||||
ghoul::Dictionary scaleDictionary;
|
||||
@@ -155,9 +159,11 @@ std::unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
|
||||
));
|
||||
return nullptr;
|
||||
}
|
||||
result->addPropertySubOwner(result->_transform.scale.get());
|
||||
LDEBUG(fmt::format("Successfully created scale for '{}'", result->identifier()));
|
||||
}
|
||||
if (result->_transform.scale) {
|
||||
result->addPropertySubOwner(result->_transform.scale.get());
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(KeyTimeFrame)) {
|
||||
ghoul::Dictionary timeFrameDictionary;
|
||||
|
||||
@@ -65,7 +65,7 @@ int progressCallback(void* userData, int64_t nTotalDownloadBytes,
|
||||
HttpRequest* r = reinterpret_cast<HttpRequest*>(userData);
|
||||
return r->_onProgress(
|
||||
HttpRequest::Progress{
|
||||
true,
|
||||
nTotalDownloadBytes > 0,
|
||||
static_cast<size_t>(nTotalDownloadBytes),
|
||||
static_cast<size_t>(nDownloadedBytes)
|
||||
}
|
||||
|
||||
@@ -35,6 +35,10 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
VersionChecker::~VersionChecker() {
|
||||
cancel();
|
||||
}
|
||||
|
||||
void VersionChecker::requestLatestVersion(const std::string& url) {
|
||||
HttpRequest::RequestOptions opt;
|
||||
opt.requestTimeoutSeconds = 0;
|
||||
@@ -53,6 +57,15 @@ void VersionChecker::requestLatestVersion(const std::string& url) {
|
||||
_request->start(opt);
|
||||
}
|
||||
|
||||
void VersionChecker::cancel() {
|
||||
if (!_request) {
|
||||
return;
|
||||
}
|
||||
_request->cancel();
|
||||
_request->wait();
|
||||
_request = nullptr;
|
||||
}
|
||||
|
||||
bool VersionChecker::hasLatestVersionInfo() {
|
||||
if (_latestVersion.has_value()) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user