Fixed Mars wrong radius. Added debug messages.

This commit is contained in:
Jonathas Costa
2017-05-12 17:53:48 -04:00
parent 587d5c8d75
commit 8d95bf05ce
5 changed files with 35 additions and 30 deletions

View File

@@ -67,8 +67,8 @@ return {
ScenePath = ".",
CommonFolder = "common",
Camera = {
Focus = "Earth",
--Focus = "Mars",
--Focus = "Earth",
Focus = "Mars",
--Position = {526781518487.171326, 257168309890.072144, -1381125204152.817383},
--Rotation = {-0.106166, 0.981574, -0.084545, 0.134513},
--Position = {-21230341452.764542, -75199905816.520981, 126295587136.952240},
@@ -82,7 +82,7 @@ return {
},
Modules = {
"sun",
"atmosphereearth",
--"atmosphereearth",
--"lodglobes/earth",
--"lodglobes/moon",
--"moon",

View File

@@ -37,8 +37,8 @@ return {
InteractionDepthBelowEllipsoid = 10000, -- Useful when having negative height map values
Atmosphere = {
-- Atmosphere radius in Km
AtmoshereRadius = 6410,
PlanetRadius = 6390.0,
AtmoshereRadius = 3416.0,
PlanetRadius = 3396.19,
PlanetAverageGroundReflectance = 0.1,
Rayleigh = {
Coefficients = {

View File

@@ -22,7 +22,7 @@ return {
Body = "MARS BARYCENTER",
Geometry = {
Type = "SimpleSphere",
Radius = 6.390E6,
Radius = 3.390E6,
Segments = 100
},
Textures = {

View File

@@ -229,7 +229,7 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData & renderData, const D
SpiceManager::ref().targetPosition("SUN", "SUN", "GALACTIC", {}, _time, lt);
glm::dvec4 sunPosObj = glm::inverse(_modelTransform) * glm::dvec4(sunPosWorld - renderData.position.dvec3(), 1.0);
program.setUniform("ellipsoidRadii", _ellipsoidRadii);
program.setUniform("ellipsoidRadii", _ellipsoidRadii);
//program.setUniform("sunPositionObj", sunPosObj);
program.setUniform("sunDirectionObj", glm::normalize(glm::dvec3(sunPosObj)));
@@ -248,13 +248,18 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData & renderData, const D
ghoul::opengl::TextureUnit inScatteringTableTextureUnit;
inScatteringTableTextureUnit.activate();
glBindTexture(GL_TEXTURE_3D, _inScatteringTableTexture);
program.setUniform("inscatterTexture", inScatteringTableTextureUnit);
program.setUniform("inscatterTexture", inScatteringTableTextureUnit);
// DEBUG:
//glm::dvec3 objP = glm::dvec3(renderData.position[0] * pow(10, renderData.position[3]),
// renderData.position[1] * pow(10, renderData.position[3]), renderData.position[2] * pow(10, renderData.position[3]));
//glm::dvec4 cameraP = glm::inverse(glm::dmat4(_modelTransform)) * glm::dvec4(-objP + renderData.camera.positionVec3(), 1.0);
glm::dvec3 objP = glm::dvec3(renderData.position[0] * pow(10, renderData.position[3]),
renderData.position[1] * pow(10, renderData.position[3]), renderData.position[2] * pow(10, renderData.position[3]));
glm::dvec4 cameraP = glm::inverse(glm::dmat4(_modelTransform)) * glm::dvec4(-objP + renderData.camera.positionVec3(), 1.0);
//std::cout << "====== Planet's position in KM: " << glm::to_string( objP/glm::dvec3(1000.0, 1000.0, 1000.0) ) << " =======" << std::endl;
//std::cout << "====== ModelTransform: " << glm::to_string(_modelTransform) << std::endl;
//std::cout << "====== Distance from Planet's ground in KM: " << glm::length(glm::dvec3(cameraP / glm::dvec4(1000.0, 1000.0, 1000.0, 1.0))) - _atmospherePlanetRadius << " =======" << std::endl;
//std::cout << "====== Camera Position: " << glm::to_string(renderData.camera.positionVec3()) << " =====" << std::endl;
//std::cout << "--- Ellipsoid Radii: " << glm::to_string(_ellipsoidRadii) << " ----" << std::endl;
}
void AtmosphereDeferredcaster::postRaycast(const RenderData & renderData, const DeferredcastData& deferredData,

View File

@@ -767,29 +767,29 @@ void main() {
bool intersectATM = false;
if ( ellipsoidRadii.x != 0.0 || ellipsoidRadii.y != 0.0 || ellipsoidRadii.z != 0.0) {
// Instead of ray-ellipsoid intersection lets transform the ray to a sphere:
dRay transfRay;
transfRay.origin = ray.origin;
transfRay.direction = ray.direction;
// if ( ellipsoidRadii.x != 0.0 || ellipsoidRadii.y != 0.0 || ellipsoidRadii.z != 0.0) {
// // Instead of ray-ellipsoid intersection lets transform the ray to a sphere:
// dRay transfRay;
// transfRay.origin = ray.origin;
// transfRay.direction = ray.direction;
transfRay.origin.x *= 1000.0/ellipsoidRadii.x;
transfRay.direction.x *= 1000.0/ellipsoidRadii.x;
transfRay.origin.z *= 1000.0/ellipsoidRadii.y;
transfRay.direction.z *= 1000.0/ellipsoidRadii.y;
transfRay.origin.y *= 1000.0/ellipsoidRadii.z;
transfRay.direction.y *= 1000.0/ellipsoidRadii.z;
transfRay.direction.xyz = normalize(transfRay.direction.xyz);
// transfRay.origin.x *= 1000.0/ellipsoidRadii.x;
// transfRay.direction.x *= 1000.0/ellipsoidRadii.x;
// transfRay.origin.y *= 1000.0/ellipsoidRadii.y;
// transfRay.direction.y *= 1000.0/ellipsoidRadii.y;
// transfRay.origin.z *= 1000.0/ellipsoidRadii.z;
// transfRay.direction.z *= 1000.0/ellipsoidRadii.z;
// transfRay.direction.xyz = normalize(transfRay.direction.xyz);
// intersectATM = dAtmosphereIntersection(planetPositionObjectCoords.xyz, transfRay, 1.0 + EPSILON,
// insideATM, offset, maxLength );
// intersectATM = dAtmosphereIntersection(planetPositionObjectCoords.xyz, transfRay, 1.0,
// insideATM, offset, maxLength );
intersectATM = dAtmosphereIntersection(planetPositionObjectCoords.xyz, transfRay, Rt+EPSILON,
insideATM, offset, maxLength );
} else {
intersectATM = dAtmosphereIntersection(planetPositionObjectCoords.xyz, ray, Rt-10*EPSILON,
// //intersectATM = dAtmosphereIntersection(planetPositionObjectCoords.xyz, transfRay, Rt+EPSILON,
// // insideATM, offset, maxLength );
// } else {
intersectATM = dAtmosphereIntersection(planetPositionObjectCoords.xyz, ray, Rt-10*EPSILON,
insideATM, offset, maxLength );
}
//}
if ( intersectATM ) {
// Now we check is if the atmosphere is occluded, i.e., if the distance to the pixel