diff --git a/ext/ghoul b/ext/ghoul index 1ac2ee8f0d..a796b61604 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 1ac2ee8f0d630e3149b2ab51fdf78592025a4d5b +Subproject commit a796b61604af408329f5b605d39fe8b56b46df8a diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index d72c55729e..11d81184e1 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -213,50 +213,25 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData, program.setUniform(_uniformCache.cullAtmosphere, 0); program.setUniform(_uniformCache.Rg, _atmospherePlanetRadius); program.setUniform(_uniformCache.Rt, _atmosphereRadius); - program.setUniform( - _uniformCache.AverageGroundReflectance, - _planetAverageGroundReflectance - ); program.setUniform(_uniformCache.groundRadianceEmittion, _planetGroundRadianceEmittion); program.setUniform(_uniformCache.HR, _rayleighHeightScale); program.setUniform(_uniformCache.betaRayleigh, _rayleighScatteringCoeff); program.setUniform(_uniformCache.HM, _mieHeightScale); - program.setUniform(_uniformCache.betaMieScattering, _mieScatteringCoeff); program.setUniform(_uniformCache.betaMieExtinction, _mieExtinctionCoeff); program.setUniform(_uniformCache.mieG, _miePhaseConstant); program.setUniform(_uniformCache.sunRadiance, _sunRadianceIntensity); program.setUniform(_uniformCache.ozoneLayerEnabled, _ozoneEnabled); program.setUniform(_uniformCache.HO, _ozoneHeightScale); program.setUniform(_uniformCache.betaOzoneExtinction, _ozoneExtinctionCoeff); - - program.setUniform(_uniformCache.TRANSMITTANCE_W, _transmittance_table_width); - program.setUniform(_uniformCache.TRANSMITTANCE_H, _transmittance_table_height); - program.setUniform(_uniformCache.SKY_W, _irradiance_table_width); - program.setUniform(_uniformCache.SKY_H, _irradiance_table_height); - program.setUniform(_uniformCache.OTHER_TEXTURES_W, _delta_e_table_width); - program.setUniform(_uniformCache.OTHER_TEXTURES_H, _delta_e_table_height); program.setUniform(_uniformCache.SAMPLES_R, _r_samples); program.setUniform(_uniformCache.SAMPLES_MU, _mu_samples); program.setUniform(_uniformCache.SAMPLES_MU_S, _mu_s_samples); program.setUniform(_uniformCache.SAMPLES_NU, _nu_samples); - program.setUniform(_uniformCache2.ModelTransformMatrix, _modelTransform); - // Object Space glm::dmat4 inverseModelMatrix = glm::inverse(_modelTransform); program.setUniform(_uniformCache2.dInverseModelTransformMatrix, inverseModelMatrix); program.setUniform(_uniformCache2.dModelTransformMatrix, _modelTransform); - - /* - // The following scale comes from PSC transformations. - float fScaleFactor = renderData.camera.scaling().x * - pow(10.f, renderData.camera.scaling().y); - glm::dmat4 dfScaleCamTransf = glm::scale(glm::dvec3(fScaleFactor)); - program.setUniform( - "dInverseScaleTransformMatrix", - glm::inverse(dfScaleCamTransf) - ); - */ // Eye Space in OS to Eye Space in SGCT glm::dmat4 dSgctEye2OSEye = glm::inverse( @@ -288,7 +263,6 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData, program.setUniform(_uniformCache2.dInverseSGCTEyeToTmpRotTransformMatrix, dInverseCameraRotationToSgctEyeTransform); - program.setUniform(_uniformCache2.dObjpos, glm::dvec4(renderData.position.dvec3(), 1.0)); program.setUniform(_uniformCache2.dCampos, renderData.camera.positionVec3()); glm::dvec4 camPosObjCoords = inverseModelMatrix * glm::dvec4(renderData.camera.positionVec3(), 1.0); @@ -320,8 +294,6 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData, // Sun Position in Object Space program.setUniform(_uniformCache2.sunDirectionObj, glm::normalize(glm::dvec3(sunPosObj))); - program.setUniform(_uniformCache2.ellipsoidRadii, _ellipsoidRadii); - // Shadow calculations.. if (!_shadowConfArray.empty()) { std::vector shadowDataArray; @@ -461,38 +433,27 @@ void AtmosphereDeferredcaster::initializeCachedVariables(ghoul::opengl::ProgramO _uniformCache.cullAtmosphere = program.uniformLocation("cullAtmosphere"); _uniformCache.Rg = program.uniformLocation("Rg"); _uniformCache.Rt = program.uniformLocation("Rt"); - _uniformCache.AverageGroundReflectance = program.uniformLocation("AverageGroundReflectance"); _uniformCache.groundRadianceEmittion = program.uniformLocation("groundRadianceEmittion"); _uniformCache.HR = program.uniformLocation("HR"); _uniformCache.betaRayleigh = program.uniformLocation("betaRayleigh"); _uniformCache.HM = program.uniformLocation("HM"); - _uniformCache.betaMieScattering = program.uniformLocation("betaMieScattering"); _uniformCache.betaMieExtinction = program.uniformLocation("betaMieExtinction"); _uniformCache.mieG = program.uniformLocation("mieG"); _uniformCache.sunRadiance = program.uniformLocation("sunRadiance"); _uniformCache.ozoneLayerEnabled = program.uniformLocation("ozoneLayerEnabled"); _uniformCache.HO = program.uniformLocation("HO"); _uniformCache.betaOzoneExtinction = program.uniformLocation("betaOzoneExtinction"); - _uniformCache.TRANSMITTANCE_W = program.uniformLocation("TRANSMITTANCE_W"); - _uniformCache.TRANSMITTANCE_H = program.uniformLocation("TRANSMITTANCE_H"); - _uniformCache.SKY_W = program.uniformLocation("SKY_W"); - _uniformCache.SKY_H = program.uniformLocation("SKY_H"); - _uniformCache.OTHER_TEXTURES_W = program.uniformLocation("OTHER_TEXTURES_W"); - _uniformCache.OTHER_TEXTURES_H = program.uniformLocation("OTHER_TEXTURES_H"); _uniformCache.SAMPLES_R = program.uniformLocation("SAMPLES_R"); _uniformCache.SAMPLES_MU = program.uniformLocation("SAMPLES_MU"); _uniformCache.SAMPLES_MU_S = program.uniformLocation("SAMPLES_MU_S"); _uniformCache.SAMPLES_NU = program.uniformLocation("SAMPLES_NU"); - _uniformCache2.ModelTransformMatrix = program.uniformLocation("ModelTransformMatrix"); _uniformCache2.dInverseModelTransformMatrix = program.uniformLocation("dInverseModelTransformMatrix"); _uniformCache2.dModelTransformMatrix = program.uniformLocation("dModelTransformMatrix"); _uniformCache2.dInverseSgctProjectionToModelTransformMatrix = program.uniformLocation("dInverseSgctProjectionToModelTransformMatrix"); _uniformCache2.dInverseSGCTEyeToTmpRotTransformMatrix = program.uniformLocation("dInverseSGCTEyeToTmpRotTransformMatrix"); - _uniformCache2.dObjpos = program.uniformLocation("dObjpos"); _uniformCache2.dCampos = program.uniformLocation("dCampos"); _uniformCache2.dCamPosObj = program.uniformLocation("dCamPosObj"); _uniformCache2.sunDirectionObj = program.uniformLocation("sunDirectionObj"); - _uniformCache2.ellipsoidRadii = program.uniformLocation("ellipsoidRadii"); _uniformCache2.hardShadows = program.uniformLocation("hardShadows"); _uniformCache2.transmittanceTexture = program.uniformLocation("transmittanceTexture"); _uniformCache2.irradianceTexture = program.uniformLocation("irradianceTexture"); diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.h b/modules/atmosphere/rendering/atmospheredeferredcaster.h index ef2778c0cc..2fa9dd6d96 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.h +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.h @@ -129,16 +129,15 @@ private: std::unique_ptr _atmosphereProgramObject; std::unique_ptr _deferredAtmosphereProgramObject; - UniformCache(cullAtmosphere, Rg, Rt, AverageGroundReflectance, - groundRadianceEmittion, HR, betaRayleigh, HM, betaMieScattering, + UniformCache(cullAtmosphere, Rg, Rt, + groundRadianceEmittion, HR, betaRayleigh, HM, betaMieExtinction, mieG, sunRadiance, ozoneLayerEnabled, - HO, betaOzoneExtinction, TRANSMITTANCE_W, TRANSMITTANCE_H, - SKY_W, SKY_H, OTHER_TEXTURES_W, OTHER_TEXTURES_H, SAMPLES_R, + HO, betaOzoneExtinction, SAMPLES_R, SAMPLES_MU, SAMPLES_MU_S, SAMPLES_NU) _uniformCache; - UniformCache(ModelTransformMatrix, dInverseModelTransformMatrix, dModelTransformMatrix, + UniformCache(dInverseModelTransformMatrix, dModelTransformMatrix, dInverseSgctProjectionToModelTransformMatrix, dInverseSGCTEyeToTmpRotTransformMatrix, - dObjpos, dCampos, dCamPosObj, sunDirectionObj, ellipsoidRadii, + dCampos, dCamPosObj, sunDirectionObj, hardShadows, transmittanceTexture, irradianceTexture, inscatterTexture) _uniformCache2; diff --git a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl index 77b1fb2f83..dde78a93e0 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl @@ -89,11 +89,9 @@ uniform dmat4 dModelTransformMatrix; uniform dmat4 dInverseSGCTEyeToTmpRotTransformMatrix; uniform dmat4 dInverseSgctProjectionToModelTransformMatrix; -uniform dvec4 dObjpos; uniform dvec3 dCampos; uniform dvec4 dCamPosObj; uniform dvec3 sunDirectionObj; -uniform dvec3 ellipsoidRadii; /******************************************************************************* ***** ALL CALCULATIONS FOR ECLIPSE ARE IN METERS AND IN WORLD SPACE SYSTEM **** @@ -262,7 +260,6 @@ void dCalculateRayRenderableGlobe(in int mssaSample, out dRay ray, // JCC: Applying the inverse of the model transformation on the object postion in World // space results in imprecision. planetPositionObjectCoords = dvec4(0.0, 0.0, 0.0, 1.0); - //planetPositionObjectCoords = dInverseModelTransformMatrix * dvec4(dObjpos.xyz, 1.0); // Camera Position in Object Space cameraPositionInObject = dCamPosObj; @@ -594,19 +591,6 @@ void main() { bool intersectATM = false; - // Instead of ray-ellipsoid intersection lets transform the ray to a sphere: - //dRay transfRay; - //transfRay.origin = ray.origin; - //transfRay.direction = ray.direction; - - // transfRay.origin.z *= 1000.0/ellipsoidRadii.x; - // transfRay.direction.z *= 1000.0/ellipsoidRadii.x; - // transfRay.origin.x *= 1000.0/ellipsoidRadii.y; - // transfRay.direction.x *= 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); - intersectATM = dAtmosphereIntersection(planetPositionObjectCoords.xyz, ray, Rt - (ATM_EPSILON * 0.001), insideATM, offset, maxLength );