From 29a76c7d33438c142bb8858ed77a661fc382e435 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sat, 2 Jan 2021 21:11:13 +0100 Subject: [PATCH] Coding style pass on shader code --- .../atmosphere/shaders/atmosphere_common.glsl | 24 +- .../shaders/atmosphere_deferred_fs.glsl | 30 +- .../shaders/atmosphere_deferred_vs.glsl | 3 +- .../atmosphere/shaders/deltaE_calc_fs.glsl | 3 +- .../atmosphere/shaders/deltaJ_calc_fs.glsl | 6 +- .../atmosphere/shaders/deltaJ_calc_gs.glsl | 8 +- .../atmosphere/shaders/deltaS_calc_fs.glsl | 2 +- .../atmosphere/shaders/deltaS_calc_gs.glsl | 8 +- .../atmosphere/shaders/deltaS_calc_vs.glsl | 2 +- .../shaders/deltaS_sup_calc_fs.glsl | 2 +- .../shaders/deltaS_sup_calc_gs.glsl | 8 +- .../shaders/deltaS_sup_calc_vs.glsl | 2 +- .../shaders/inScattering_calc_fs.glsl | 9 +- .../shaders/inScattering_calc_gs.glsl | 8 +- .../shaders/inScattering_calc_vs.glsl | 2 +- .../shaders/inScattering_sup_calc_fs.glsl | 4 +- .../shaders/inScattering_sup_calc_gs.glsl | 8 +- .../shaders/inScattering_sup_calc_vs.glsl | 2 +- .../shaders/irradiance_calc_fs.glsl | 2 +- .../shaders/irradiance_calc_vs.glsl | 2 +- .../shaders/irradiance_final_fs.glsl | 2 +- .../shaders/irradiance_sup_calc_fs.glsl | 3 +- .../shaders/irradiance_sup_calc_vs.glsl | 2 +- .../shaders/transmittance_calc_fs.glsl | 7 +- modules/base/shaders/axes_fs.glsl | 1 - modules/base/shaders/grid_fs.glsl | 1 - modules/base/shaders/grid_vs.glsl | 2 - .../digitaluniverse/shaders/billboard_gs.glsl | 2 +- .../shaders/billboardpolygon_fs.glsl | 4 +- .../shaders/billboardpolygon_gs.glsl | 5 +- .../digitaluniverse/shaders/points_gs.glsl | 5 +- .../shaders/points_sprite_fs.glsl | 1 - modules/exoplanets/shaders/orbitdisc_fs.glsl | 2 +- .../shaders/fieldlinessequence_fs.glsl | 3 +- .../shaders/fieldlinessequence_vs.glsl | 13 +- modules/gaia/shaders/gaia_billboard_fs.glsl | 1 - modules/gaia/shaders/gaia_billboard_ge.glsl | 3 +- .../gaia/shaders/gaia_billboard_nofbo_fs.glsl | 6 +- modules/gaia/shaders/gaia_point_fs.glsl | 5 +- modules/gaia/shaders/gaia_point_ge.glsl | 1 - modules/gaia/shaders/gaia_ssbo_vs.glsl | 26 +- .../gaia_tonemapping_billboard_fs.glsl | 1 - .../shaders/gaia_tonemapping_point_fs.glsl | 1 - modules/gaia/shaders/gaia_vbo_vs.glsl | 14 +- modules/galaxy/shaders/billboard_vs.glsl | 5 +- modules/galaxy/shaders/points_vs.glsl | 22 +- .../globebrowsing/shaders/renderer_fs.glsl | 552 +++++++++--------- modules/globebrowsing/shaders/rings_fs.glsl | 2 +- modules/iswa/shaders/datasphere_fs.glsl | 3 +- modules/multiresvolume/shaders/raycast.glsl | 6 +- modules/space/shaders/convolution_fs.glsl | 2 +- modules/space/shaders/debrisViz_vs.glsl | 7 - modules/space/shaders/psfToTexture_fs.glsl | 5 +- modules/space/shaders/star_ge.glsl | 1 - .../shaders/dilation_fs.glsl | 1 - .../renderablePlanetProjection_fs.glsl | 2 +- .../shaders/terminatorshadow_vs.glsl | 2 +- modules/toyvolume/shaders/boundsfs.glsl | 1 + modules/volume/shaders/boundsfs.glsl | 1 + .../webbrowser/shaders/screenspace_vs.glsl | 4 +- shaders/PowerScaling/powerScaling_fs.hglsl | 22 - shaders/PowerScaling/powerScaling_vs.hglsl | 17 +- shaders/abuffer/resolvehelpers.glsl | 10 +- shaders/floatoperations.glsl | 29 +- shaders/framebuffer/fxaa.frag | 2 +- 65 files changed, 435 insertions(+), 507 deletions(-) diff --git a/modules/atmosphere/shaders/atmosphere_common.glsl b/modules/atmosphere/shaders/atmosphere_common.glsl index c22b545337..fd0ca1eb2f 100644 --- a/modules/atmosphere/shaders/atmosphere_common.glsl +++ b/modules/atmosphere/shaders/atmosphere_common.glsl @@ -109,7 +109,7 @@ float invSamplesNu = 1.0f / float(SAMPLES_NU); float RtMinusRg = float(Rt - Rg); float invRtMinusRg = 1.0f / RtMinusRg; -float opticalDepth(const float localH, const float r, const float mu, const float d) { +float opticalDepth(float localH, float r, float mu, float d) { float invH = 1.0/localH; float a = sqrt((0.5 * invH)*r); vec2 a01 = a*vec2(mu, mu + d / r); @@ -120,7 +120,7 @@ float opticalDepth(const float localH, const float r, const float mu, const floa return sqrt((6.2831*H)*r) * exp((Rg-r)*invH) * (x + dot(y, vec2(1.0, -1.0))); } -vec3 analyticTransmittance(const float r, const float mu, const float d) { +vec3 analyticTransmittance(float r, float mu, float d) { if (ozoneLayerEnabled) { return exp(-betaRayleigh * opticalDepth(HR, r, mu, d) - betaOzoneExtinction * (0.0000006) * opticalDepth(HO, r, mu, d) - @@ -132,7 +132,7 @@ vec3 analyticTransmittance(const float r, const float mu, const float d) { } } -vec3 irradiance(sampler2D sampler, const float r, const float muSun) { +vec3 irradiance(sampler2D sampler, float r, float muSun) { float u_r = (r - Rg) * invRtMinusRg; float u_muSun = (muSun + 0.2) / (1.0 + 0.2); return texture(sampler, vec2(u_muSun, u_r)).rgb; @@ -152,7 +152,7 @@ vec3 irradiance(sampler2D sampler, const float r, const float muSun) { // until the planet's ground or top of atmosphere. --- // r := || vec(x) || e [0, Rt] // mu := cosine of the zeith angle of vec(v). Or mu = (vec(x) * vec(v))/r -float rayDistance(const float r, const float mu) { +float rayDistance(float r, float mu) { // The light ray starting at the observer in/on the atmosphere can // have to possible end points: the top of the atmosphere or the // planet ground. So the shortest path is the one we are looking for, @@ -225,7 +225,7 @@ void unmappingRAndMuSunIrradiance(out float r, out float muSun) { // nu := cosone of the angle between vec(s) and vec(v) // dhdH := it is a vec4. dhdH.x stores the dminT := Rt - r, dhdH.y stores the dH value (see paper), // dhdH.z stores dminG := r - Rg and dhdH.w stores dh (see paper). -void unmappingMuMuSunNu(const float r, vec4 dhdH, out float mu, out float muSun, out float nu) { +void unmappingMuMuSunNu(float r, vec4 dhdH, out float mu, out float muSun, out float nu) { // Window coordinates of pixel (uncentering also) float fragmentX = gl_FragCoord.x - 0.5f; float fragmentY = gl_FragCoord.y - 0.5f; @@ -277,7 +277,7 @@ void unmappingMuMuSunNu(const float r, vec4 dhdH, out float mu, out float muSun, // the ground or the top of atmosphere. -- // r := height of starting point vect(x) // mu := cosine of the zeith angle of vec(v). Or mu = (vec(x) * vec(v))/r -vec3 transmittanceLUT(const float r, const float mu) { +vec3 transmittanceLUT(float r, float mu) { // Given the position x (here the altitude r) and the view // angle v (here the cosine(v)= mu), we map this float u_r = sqrt((r - Rg) * invRtMinusRg); @@ -293,7 +293,7 @@ vec3 transmittanceLUT(const float r, const float mu) { // of Transmittance: T(a,b) = TableT(a,v)/TableT(b, v) -- // r := height of starting point vect(x) // mu := cosine of the zeith angle of vec(v). Or mu = (vec(x) * vec(v))/r -vec3 transmittance(const float r, const float mu, const float d) { +vec3 transmittance(float r, float mu, float d) { // Here we use the transmittance property: T(x,v) = T(x,d)*T(d,v) // to, given a distance d, calculates that transmittance along // that distance starting in x (hight r): T(x,d) = T(x,v)/T(d,v). @@ -326,7 +326,7 @@ vec3 transmittance(const float r, const float mu, const float d) { // -- Calculates Rayleigh phase function given the // scattering cosine angle mu -- // mu := cosine of the zeith angle of vec(v). Or mu = (vec(x) * vec(v))/r -float rayleighPhaseFunction(const float mu) { +float rayleighPhaseFunction(float mu) { //return (3.0f / (16.0f * M_PI)) * (1.0f + mu * mu); return 0.0596831036 * (1.0f + mu * mu); } @@ -334,7 +334,7 @@ float rayleighPhaseFunction(const float mu) { // -- Calculates Mie phase function given the // scattering cosine angle mu -- // mu := cosine of the zeith angle of vec(v). Or mu = (vec(x) * vec(v))/r -float miePhaseFunction(const float mu) { +float miePhaseFunction(float mu) { //return (3.0f / (8.0f * M_PI)) * // ( ( (1.0f - (mieG * mieG) ) * (1.0f + mu * mu) ) / // ( (2.0f + mieG * mieG) * @@ -356,9 +356,7 @@ float miePhaseFunction(const float mu) { // mu := cosine of the zeith angle of vec(v). Or mu = (vec(x) * vec(v))/r // muSun := cosine of the zeith angle of vec(s). Or muSun = (vec(s) * vec(v)) // nu := cosine of the angle between vec(s) and vec(v) -vec4 texture4D(sampler3D table, const float r, const float mu, - const float muSun, const float nu) -{ +vec4 texture4D(sampler3D table, float r, float mu, float muSun, float nu) { //float Rg2 = Rg * Rg; //float Rt2 = Rt * Rt; float r2 = r * r; @@ -403,7 +401,7 @@ vec4 texture4D(sampler3D table, const float r, const float mu, // lut := OpenGL texture2D sampler (the irradiance texture deltaE) // muSun := cosine of the zeith angle of vec(s). Or muSun = (vec(s) * vec(v)) // r := height of starting point vect(x) -vec3 irradianceLUT(sampler2D lut, const float muSun, const float r) { +vec3 irradianceLUT(sampler2D lut, float muSun, float r) { // See Bruneton paper and Coliene to understand the mapping float u_muSun = (muSun + 0.2f) / (1.0f + 0.2f); float u_r = (r - Rg) * invRtMinusRg; diff --git a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl index caaef43969..6e7872b129 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl @@ -106,12 +106,13 @@ uniform ShadowRenderingStruct shadowDataArray[numberOfShadows]; uniform int shadows; uniform bool hardShadows; -vec4 butterworthFunc(const float d, const float r, const float n) { +vec4 butterworthFunc(float d, float r, float n) { return vec4(vec3(sqrt(r/(r + pow(d, 2*n)))), 1.0); } -vec4 calcShadow(const ShadowRenderingStruct shadowInfoArray[numberOfShadows], const dvec3 position, - const bool ground) { +vec4 calcShadow(ShadowRenderingStruct shadowInfoArray[numberOfShadows], dvec3 position, + bool ground) +{ if (shadowInfoArray[0].isShadowing) { dvec3 pc = shadowInfoArray[0].casterPositionVec - position; dvec3 sc_norm = shadowInfoArray[0].sourceCasterVec; @@ -181,7 +182,7 @@ struct dRay { * intersection of the ray with atmosphere when the eye position * is inside atmosphere. */ -bool dAtmosphereIntersection(const dvec3 planetPosition, const dRay ray, const double atmRadius, +bool dAtmosphereIntersection(dvec3 planetPosition, dRay ray, double atmRadius, out bool inside, out double offset, out double maxLength ) { dvec3 l = planetPosition - ray.origin.xyz; double s = dot(l, ray.direction.xyz); @@ -281,10 +282,10 @@ void dCalculateRayRenderableGlobe(out dRay ray, * calculating the reflectance R[L]. */ vec3 inscatterRadiance(inout vec3 x, inout float t, inout float irradianceFactor, - const vec3 v, const vec3 s, out float r, out float mu, - out vec3 attenuation, const vec3 fragPosObj, out bool groundHit, - const double maxLength, const double pixelDepth, - const vec4 spaceColor, const float sunIntensity) { + vec3 v, vec3 s, out float r, out float mu, + out vec3 attenuation, vec3 fragPosObj, out bool groundHit, + double maxLength, double pixelDepth, + vec4 spaceColor, float sunIntensity) { const float INTERPOLATION_EPS = 0.004f; // precision const from Brunetton @@ -446,10 +447,10 @@ vec3 inscatterRadiance(inout vec3 x, inout float t, inout float irradianceFactor * mu := cosine of the zenith view angle * attenuationXtoX0 := transmittance T(x,x0) */ -vec3 groundColor(const vec3 x, const float t, const vec3 v, const vec3 s, const float r, - const float mu, const vec3 attenuationXtoX0, const vec4 groundColor, - const vec3 normal, const float irradianceFactor, - const float waterReflectance, const float sunIntensity) +vec3 groundColor(vec3 x, float t, vec3 v, vec3 s, float r, + float mu, vec3 attenuationXtoX0, vec4 groundColor, + vec3 normal, float irradianceFactor, + float waterReflectance, float sunIntensity) { vec3 reflectedRadiance = vec3(0.0f); @@ -524,8 +525,8 @@ vec3 groundColor(const vec3 x, const float t, const vec3 v, const vec3 s, const * mu := cosine of the zenith view angle * attenuation := transmittance T(x,x0) */ -vec3 sunColor(const vec3 x, const float t, const vec3 v, const vec3 s, const float r, - const float mu, const float irradianceFactor) { +vec3 sunColor(vec3 x, float t, vec3 v, vec3 s, float r, float mu, float irradianceFactor) +{ vec3 transmittance = (r <= Rt) ? ( mu < -sqrt(1.0f - Rg2/(r*r)) ? vec3(0.0f) : transmittanceLUT(r, mu)) : vec3(1.0f); // JCC: Change this function to a impostor texture with gaussian decay color weighted @@ -694,4 +695,3 @@ void main() { renderTarget = bColor; } } - diff --git a/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl index 5d609ded43..cbe4d8663f 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl @@ -29,8 +29,7 @@ layout(location = 0) in vec4 in_position; out vec3 interpolatedNDCPos; out vec2 texCoord; -void main() -{ +void main() { texCoord = 0.5 + in_position.xy * 0.5; interpolatedNDCPos = in_position.xyz; gl_Position = in_position; diff --git a/modules/atmosphere/shaders/deltaE_calc_fs.glsl b/modules/atmosphere/shaders/deltaE_calc_fs.glsl index cb93a3284b..fe0163b6b2 100644 --- a/modules/atmosphere/shaders/deltaE_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaE_calc_fs.glsl @@ -21,12 +21,13 @@ * 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 "atmosphere_common.glsl" out vec4 renderTableColor; -void main(void) { +void main() { renderTableColor = vec4(0.0, 0.0, 0.0, 1.0); } diff --git a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl index 4feb9ff872..badfa8934d 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl @@ -97,7 +97,7 @@ void inscatter(float r, float mu, float muSun, float nu, inout vec3 radianceJ) { // In order to integrate over 4PI, we scan the sphere using the spherical coordinates // previously defined - for ( int theta_i = 0; theta_i < INSCATTER_SPHERICAL_INTEGRAL_SAMPLES; ++theta_i ) { + for (int theta_i = 0; theta_i < INSCATTER_SPHERICAL_INTEGRAL_SAMPLES; ++theta_i) { float theta = (float(theta_i) + 0.5f) * stepTheta; float cosineTheta = cos(theta); float cosineTheta2 = cosineTheta * cosineTheta; @@ -133,7 +133,7 @@ void inscatter(float r, float mu, float muSun, float nu, inout vec3 radianceJ) { groundTransmittance = transmittance(Rg, muGround, distanceToGround); } //for ( int phi_i = 0; phi_i < 2*INSCATTER_SPHERICAL_INTEGRAL_SAMPLES; ++phi_i ) { - for ( int phi_i = 0; phi_i < INSCATTER_SPHERICAL_INTEGRAL_SAMPLES; ++phi_i ) { + for (int phi_i = 0; phi_i < INSCATTER_SPHERICAL_INTEGRAL_SAMPLES; ++phi_i) { float phi = (float(phi_i) + 0.5) * stepPhi; // spherical coordinates: dw = dtheta*dphi*sin(theta)*rho^2 // rho = 1, we are integrating over a unit sphere @@ -190,7 +190,7 @@ void inscatter(float r, float mu, float muSun, float nu, inout vec3 radianceJ) { } } -void main(void) { +void main() { // cosine variables to access deltaS textures float mu, muSun, nu; // InScattering Radiance to be calculated at diff --git a/modules/atmosphere/shaders/deltaJ_calc_gs.glsl b/modules/atmosphere/shaders/deltaJ_calc_gs.glsl index c68c70a4b3..aea1c7db4d 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_gs.glsl @@ -29,13 +29,11 @@ uniform int layer; layout (triangles) in; layout (triangle_strip, max_vertices = 3) out; -void main() -{ - int n; - for (n = 0; n < gl_in.length(); ++n) { +void main() { + for (int n = 0; n < gl_in.length(); ++n) { gl_Position = gl_in[n].gl_Position; gl_Layer = layer; EmitVertex(); } EndPrimitive(); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/deltaS_calc_fs.glsl b/modules/atmosphere/shaders/deltaS_calc_fs.glsl index b57dde9e8c..d337cb18bf 100644 --- a/modules/atmosphere/shaders/deltaS_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_fs.glsl @@ -33,7 +33,7 @@ uniform int layer; uniform sampler3D deltaSRTexture; uniform sampler3D deltaSMTexture; -void main(void) { +void main() { // First we convert the window's fragment coordinate to // texel coordinates vec3 rst = vec3(gl_FragCoord.xy, float(layer) + 0.5f) / diff --git a/modules/atmosphere/shaders/deltaS_calc_gs.glsl b/modules/atmosphere/shaders/deltaS_calc_gs.glsl index c68c70a4b3..aea1c7db4d 100644 --- a/modules/atmosphere/shaders/deltaS_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_gs.glsl @@ -29,13 +29,11 @@ uniform int layer; layout (triangles) in; layout (triangle_strip, max_vertices = 3) out; -void main() -{ - int n; - for (n = 0; n < gl_in.length(); ++n) { +void main() { + for (int n = 0; n < gl_in.length(); ++n) { gl_Position = gl_in[n].gl_Position; gl_Layer = layer; EmitVertex(); } EndPrimitive(); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/deltaS_calc_vs.glsl b/modules/atmosphere/shaders/deltaS_calc_vs.glsl index d5a1e43e38..1ca953fe3c 100644 --- a/modules/atmosphere/shaders/deltaS_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_vs.glsl @@ -28,4 +28,4 @@ layout(location = 0) in vec3 in_position; void main() { gl_Position = vec4(in_position, 1.0); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl index ab60653deb..31e6b6670f 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl @@ -32,7 +32,7 @@ uniform int layer; uniform sampler3D deltaSTexture; -void main(void) { +void main() { float x = gl_FragCoord.x - 0.5f; float y = gl_FragCoord.y - 0.5f; diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl index 41e9bed127..7cccacb76a 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl @@ -29,13 +29,11 @@ uniform int layer; layout (triangles) in; layout (triangle_strip, max_vertices = 3) out; -void main() -{ - int n; - for (n = 0; n < gl_in.length(); ++n) { +void main() { + for (int n = 0; n < gl_in.length(); ++n) { gl_Position = gl_in[n].gl_Position; gl_Layer = layer; EmitVertex(); } EndPrimitive(); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl index 255f2b1610..deb9073c8f 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl @@ -28,4 +28,4 @@ layout(location = 0) in vec3 in_position; void main() { gl_Position = vec4(in_position, 1.0); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/inScattering_calc_fs.glsl b/modules/atmosphere/shaders/inScattering_calc_fs.glsl index 544b2374a3..be7281bda3 100644 --- a/modules/atmosphere/shaders/inScattering_calc_fs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_fs.glsl @@ -33,8 +33,8 @@ uniform vec4 dhdH; //uniform sampler2D transmittanceTexture; -void integrand(const float r, const float mu, const float muSun, const float nu, - const float y, out vec3 S_R, out vec3 S_M) { +void integrand(float r, float mu, float muSun, float nu, + float y, out vec3 S_R, out vec3 S_M) { // The integral's integrand is the single inscattering radiance: // S[L0] = P_M*S_M[L0] + P_R*S_R[L0] // where S_M[L0] = T*(betaMScattering * exp(-h/H_M))*L0 and @@ -77,8 +77,7 @@ void integrand(const float r, const float mu, const float muSun, const float nu, } } -void inscatter(const float r, const float mu, const float muSun, const float nu, - out vec3 S_R, out vec3 S_M) { +void inscatter(float r, float mu, float muSun, float nu, out vec3 S_R, out vec3 S_M) { // Let's calculate S_M and S_R by integration along the eye ray path inside // the atmosphere, given a position r, a view angle (cosine) mu, a sun // position angle (cosine) muSun, and the angle (cosine) between the sun position @@ -108,7 +107,7 @@ void inscatter(const float r, const float mu, const float muSun, const float nu, S_M *= betaMieScattering * (rayDist / (2.0f * float(INSCATTER_INTEGRAL_SAMPLES))); } -void main(void) { +void main() { vec3 S_R; // First Order Rayleigh InScattering vec3 S_M; // First Order Mie InScattering float mu, muSun, nu; // parametrization angles diff --git a/modules/atmosphere/shaders/inScattering_calc_gs.glsl b/modules/atmosphere/shaders/inScattering_calc_gs.glsl index 1cb4db902e..823cd6a71e 100644 --- a/modules/atmosphere/shaders/inScattering_calc_gs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_gs.glsl @@ -29,13 +29,11 @@ uniform int layer; layout (triangles) in; layout (triangle_strip, max_vertices=3) out; -void main() -{ - int n; - for (n = 0; n < gl_in.length(); ++n) { +void main() { + for (int n = 0; n < gl_in.length(); ++n) { gl_Position = gl_in[n].gl_Position; gl_Layer = layer; EmitVertex(); } EndPrimitive(); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/inScattering_calc_vs.glsl b/modules/atmosphere/shaders/inScattering_calc_vs.glsl index d5a1e43e38..1ca953fe3c 100644 --- a/modules/atmosphere/shaders/inScattering_calc_vs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_vs.glsl @@ -28,4 +28,4 @@ layout(location = 0) in vec3 in_position; void main() { gl_Position = vec4(in_position, 1.0); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl index ab7c793384..81377100bc 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl @@ -35,7 +35,7 @@ uniform vec4 dhdH; uniform sampler3D deltaJTexture; // The integrand here is the f(y) of the trapezoidal rule: -vec3 integrand(const float r, const float mu, const float muSun, const float nu, const float dist) { +vec3 integrand(float r, float mu, float muSun, float nu, float dist) { // We can calculate r_i by the cosine law: r_i^2=dist^2 + r^2 - 2*r*dist*cos(PI-theta) float r_i = sqrt(r * r + dist * dist + 2.0f * r * dist * mu); // r_i can be found using the dot product: @@ -68,7 +68,7 @@ vec3 inscatter(float r, float mu, float muSun, float nu) { return inScatteringRadiance; } -void main(void) { +void main() { float mu = 0.0f, muSunun = 0.0f, nu = 0.0f; // Unmapping the variables from texture texels coordinates // to mapped coordinates diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl index 41e9bed127..7cccacb76a 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl @@ -29,13 +29,11 @@ uniform int layer; layout (triangles) in; layout (triangle_strip, max_vertices = 3) out; -void main() -{ - int n; - for (n = 0; n < gl_in.length(); ++n) { +void main() { + for (int n = 0; n < gl_in.length(); ++n) { gl_Position = gl_in[n].gl_Position; gl_Layer = layer; EmitVertex(); } EndPrimitive(); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl index 255f2b1610..deb9073c8f 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl @@ -28,4 +28,4 @@ layout(location = 0) in vec3 in_position; void main() { gl_Position = vec4(in_position, 1.0); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/irradiance_calc_fs.glsl b/modules/atmosphere/shaders/irradiance_calc_fs.glsl index 67a862b8b7..94ea44c834 100644 --- a/modules/atmosphere/shaders/irradiance_calc_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_calc_fs.glsl @@ -29,7 +29,7 @@ out vec4 renderTableColor; //uniform sampler2D transmittanceTexture; -void main(void) { +void main() { float muSun, r; unmappingRAndMuSun(r, muSun); // We are calculating the Irradiance for L0, i.e., diff --git a/modules/atmosphere/shaders/irradiance_calc_vs.glsl b/modules/atmosphere/shaders/irradiance_calc_vs.glsl index d5a1e43e38..1ca953fe3c 100644 --- a/modules/atmosphere/shaders/irradiance_calc_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_calc_vs.glsl @@ -28,4 +28,4 @@ layout(location = 0) in vec3 in_position; void main() { gl_Position = vec4(in_position, 1.0); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/irradiance_final_fs.glsl b/modules/atmosphere/shaders/irradiance_final_fs.glsl index 94dc168ab0..f21d74bdba 100644 --- a/modules/atmosphere/shaders/irradiance_final_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_final_fs.glsl @@ -30,7 +30,7 @@ out vec4 renderTableColor; uniform sampler2D deltaETexture; -void main(void) { +void main() { vec2 uv = gl_FragCoord.xy / vec2(OTHER_TEXTURES_W, OTHER_TEXTURES_H); // Update texture E with E plus deltaE textures. diff --git a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl index fcb27b7a9a..5ac81a7406 100644 --- a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl @@ -39,8 +39,7 @@ const float stepTheta = M_PI / (2.0f * float(IRRADIANCE_INTEGRAL_SAMPLES)); uniform sampler3D deltaSRTexture; uniform sampler3D deltaSMTexture; -void main(void) { - +void main() { float r = 0.0f; float muSun = 0.0f; // Unmapping the variables from texture texels coordinates diff --git a/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl b/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl index d5a1e43e38..1ca953fe3c 100644 --- a/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl @@ -28,4 +28,4 @@ layout(location = 0) in vec3 in_position; void main() { gl_Position = vec4(in_position, 1.0); -} \ No newline at end of file +} diff --git a/modules/atmosphere/shaders/transmittance_calc_fs.glsl b/modules/atmosphere/shaders/transmittance_calc_fs.glsl index 6e887667bc..0c1dddd0ff 100644 --- a/modules/atmosphere/shaders/transmittance_calc_fs.glsl +++ b/modules/atmosphere/shaders/transmittance_calc_fs.glsl @@ -35,7 +35,7 @@ out vec4 renderTableColor; // mu := cosine of the zeith angle of vec(v). Or mu = (vec(x) * vec(v))/r // H := Thickness of atmosphere if its density were uniform (can be used // for Rayleigh and Mie. -float opticalDepth(const float r, const float mu, const float H) { +float opticalDepth(float r, float mu, float H) { float r2 = r*r; // Is ray below horizon? The transmittance table will have only // the values for transmittance starting at r (x) until the @@ -71,9 +71,8 @@ float opticalDepth(const float r, const float mu, const float H) { } -void main(void) { +void main() { float r, muSun; - unmappingRAndMu(r, muSun); vec3 opDepth = vec3(0.0); @@ -88,5 +87,5 @@ void main(void) { betaRayleigh * opticalDepth(r, muSun, HR); } - renderTableColor = vec4( exp( -opDepth ), 0.0f ); + renderTableColor = vec4(exp(-opDepth), 0.0f); } diff --git a/modules/base/shaders/axes_fs.glsl b/modules/base/shaders/axes_fs.glsl index 037b07aac5..6bbcd9b84b 100644 --- a/modules/base/shaders/axes_fs.glsl +++ b/modules/base/shaders/axes_fs.glsl @@ -23,7 +23,6 @@ ****************************************************************************************/ #include "fragment.glsl" -#include "PowerScaling/powerScaling_fs.hglsl" in float vs_screenSpaceDepth; in vec4 vs_positionViewSpace; diff --git a/modules/base/shaders/grid_fs.glsl b/modules/base/shaders/grid_fs.glsl index 6e0e2cdcab..06d83fa764 100644 --- a/modules/base/shaders/grid_fs.glsl +++ b/modules/base/shaders/grid_fs.glsl @@ -23,7 +23,6 @@ ****************************************************************************************/ #include "fragment.glsl" -#include "PowerScaling/powerScaling_fs.hglsl" in float vs_depthClipSpace; in vec4 vs_positionViewSpace; diff --git a/modules/base/shaders/grid_vs.glsl b/modules/base/shaders/grid_vs.glsl index beb95e9059..30351ea566 100644 --- a/modules/base/shaders/grid_vs.glsl +++ b/modules/base/shaders/grid_vs.glsl @@ -24,8 +24,6 @@ #version __CONTEXT__ -#include "PowerScaling/powerScaling_vs.hglsl" - layout(location = 0) in vec3 in_position; out float vs_depthClipSpace; diff --git a/modules/digitaluniverse/shaders/billboard_gs.glsl b/modules/digitaluniverse/shaders/billboard_gs.glsl index 347a936ad8..e2f7fb4fc7 100644 --- a/modules/digitaluniverse/shaders/billboard_gs.glsl +++ b/modules/digitaluniverse/shaders/billboard_gs.glsl @@ -194,4 +194,4 @@ void main() { EmitVertex(); EndPrimitive(); -} \ No newline at end of file +} diff --git a/modules/digitaluniverse/shaders/billboardpolygon_fs.glsl b/modules/digitaluniverse/shaders/billboardpolygon_fs.glsl index eb3a64fb8c..bcea223fd0 100644 --- a/modules/digitaluniverse/shaders/billboardpolygon_fs.glsl +++ b/modules/digitaluniverse/shaders/billboardpolygon_fs.glsl @@ -21,13 +21,13 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ + #version __CONTEXT__ out vec4 finalColor; uniform vec3 polygonColor; -void main(void) { - +void main() { finalColor = vec4(polygonColor, 1.0 ); } diff --git a/modules/digitaluniverse/shaders/billboardpolygon_gs.glsl b/modules/digitaluniverse/shaders/billboardpolygon_gs.glsl index 37cdbbd65a..2bd88f5b90 100644 --- a/modules/digitaluniverse/shaders/billboardpolygon_gs.glsl +++ b/modules/digitaluniverse/shaders/billboardpolygon_gs.glsl @@ -32,8 +32,7 @@ uniform int sides; const float PI = 3.1415926; -void main() -{ +void main() { // for (int i = 0; i <= sides; i++) { // // Angle between each side in radians // float ang = PI * 2.0 / float(sides) * i; @@ -71,4 +70,4 @@ void main() EndPrimitive(); } -} \ No newline at end of file +} diff --git a/modules/digitaluniverse/shaders/points_gs.glsl b/modules/digitaluniverse/shaders/points_gs.glsl index 1a3899336f..dc074d0484 100644 --- a/modules/digitaluniverse/shaders/points_gs.glsl +++ b/modules/digitaluniverse/shaders/points_gs.glsl @@ -38,8 +38,7 @@ out float gs_screenSpaceDepth; const float PI = 3.1415926; -void main() -{ +void main() { gs_screenSpaceDepth = vs_screenSpaceDepth[0]; for (int i = 0; i <= sides; i++) { @@ -61,4 +60,4 @@ void main() //EmitVertex(); EndPrimitive(); -} \ No newline at end of file +} diff --git a/modules/digitaluniverse/shaders/points_sprite_fs.glsl b/modules/digitaluniverse/shaders/points_sprite_fs.glsl index 9aea46b03c..03fdcfd916 100644 --- a/modules/digitaluniverse/shaders/points_sprite_fs.glsl +++ b/modules/digitaluniverse/shaders/points_sprite_fs.glsl @@ -30,7 +30,6 @@ in float vs_screenSpaceDepth; uniform vec3 color; uniform float alphaValue; -// Sprite uniform sampler2D spriteTexture; Fragment getFragment() { diff --git a/modules/exoplanets/shaders/orbitdisc_fs.glsl b/modules/exoplanets/shaders/orbitdisc_fs.glsl index 7e62e31206..416536b69e 100644 --- a/modules/exoplanets/shaders/orbitdisc_fs.glsl +++ b/modules/exoplanets/shaders/orbitdisc_fs.glsl @@ -111,7 +111,7 @@ Fragment getFragment() { // Scale texture coordinate to handle asymmetric offset intervals float textureMid = offsetUpper / offsetIntervalSize; - if(textureCoord > textureMid) { + if (textureCoord > textureMid) { textureCoord = 0.5 + 0.5 * (textureCoord - textureMid) / (1.0 - textureMid); } else { diff --git a/modules/fieldlinessequence/shaders/fieldlinessequence_fs.glsl b/modules/fieldlinessequence/shaders/fieldlinessequence_fs.glsl index 518dd214f4..4afde1c7c2 100644 --- a/modules/fieldlinessequence/shaders/fieldlinessequence_fs.glsl +++ b/modules/fieldlinessequence/shaders/fieldlinessequence_fs.glsl @@ -29,6 +29,7 @@ in float vs_depth; uniform bool usingAdditiveBlending; + Fragment getFragment() { if (vs_color.a == 0) { discard; @@ -46,8 +47,6 @@ Fragment getFragment() { // TODO: Add the correct normal if necessary (JCC) frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0); - - if (usingAdditiveBlending) { frag.blend = BLEND_MODE_ADDITIVE; } diff --git a/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl b/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl index c6686ace94..75157cd9c9 100644 --- a/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl +++ b/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl @@ -72,18 +72,19 @@ vec4 getTransferFunctionColor() { return texture(colorTable, lookUpVal); } -bool isPartOfParticle(const double time, const int vertexId, const int particleSize, - const int particleSpeed, const int particleSpacing) { +bool isPartOfParticle(double time, int vertexId, int particleSize, + int particleSpeed, int particleSpacing) +{ int modulusResult = int(double(particleSpeed) * time + vertexId) % particleSpacing; return modulusResult > 0 && modulusResult <= particleSize; } void main() { - bool hasColor = true; if (usingMasking && (in_masking_scalar < maskingRange.x || - in_masking_scalar > maskingRange.y )) { + in_masking_scalar > maskingRange.y )) + { hasColor = false; } @@ -93,8 +94,8 @@ void main() { if (in_position.x < domainLimX.x || in_position.x > domainLimX.y || in_position.y < domainLimY.x || in_position.y > domainLimY.y || in_position.z < domainLimZ.x || in_position.z > domainLimZ.y || - radius < domainLimR.x || radius > domainLimR.y) { - + radius < domainLimR.x || radius > domainLimR.y) + { hasColor = false; } } diff --git a/modules/gaia/shaders/gaia_billboard_fs.glsl b/modules/gaia/shaders/gaia_billboard_fs.glsl index 53179cf086..fd11914e7e 100644 --- a/modules/gaia/shaders/gaia_billboard_fs.glsl +++ b/modules/gaia/shaders/gaia_billboard_fs.glsl @@ -60,7 +60,6 @@ vec3 color2rgb(float color) { } void main() { - // Assume all stars has equal luminosity as the Sun when no magnitude is loaded. float luminosity = 0.05; vec3 color = vec3(luminosity); diff --git a/modules/gaia/shaders/gaia_billboard_ge.glsl b/modules/gaia/shaders/gaia_billboard_ge.glsl index 7fc381e09e..fb894c44cc 100644 --- a/modules/gaia/shaders/gaia_billboard_ge.glsl +++ b/modules/gaia/shaders/gaia_billboard_ge.glsl @@ -67,7 +67,6 @@ const vec2 corners[4] = vec2[4]( void main() { - ge_brightness = vs_brightness[0]; ge_starDistFromSun = vs_starDistFromSun[0]; ge_cameraDistFromSun = vs_cameraDistFromSun[0]; @@ -80,7 +79,7 @@ void main() { float initStarSize = billboardSize; // Use magnitude for size boost as well. - if ( renderOption != RENDEROPTION_STATIC ) { + if (renderOption != RENDEROPTION_STATIC) { // DR1 magnitudes are [4, 20], but could be [-15, 20] according to this chart: // https://qph.fs.quoracdn.net/main-qimg-317a18e3b228efc7d7f67a1632a55961 // Negative magnitude => Giants diff --git a/modules/gaia/shaders/gaia_billboard_nofbo_fs.glsl b/modules/gaia/shaders/gaia_billboard_nofbo_fs.glsl index 3b439f1564..a350a561ae 100644 --- a/modules/gaia/shaders/gaia_billboard_nofbo_fs.glsl +++ b/modules/gaia/shaders/gaia_billboard_nofbo_fs.glsl @@ -57,7 +57,6 @@ vec3 color2rgb(float color) { } Fragment getFragment() { - // Assume all stars has equal luminosity as the Sun when no magnitude is loaded. float luminosity = 1.0; vec3 color = vec3(luminosity); @@ -70,7 +69,7 @@ Fragment getFragment() { } // Calculate the color and luminosity if we have the magnitude and B-V color. - if ( renderOption != RENDEROPTION_STATIC ) { + if (renderOption != RENDEROPTION_STATIC) { color = color2rgb(ge_brightness.y); ratioMultiplier = 0.5; @@ -95,7 +94,7 @@ Fragment getFragment() { color *= luminosity * pow(luminosityMultiplier, 3.0); // Decrease contributing brightness for stars in central cluster. - if ( ge_cameraDistFromSun > ge_starDistFromSun ) { + if (ge_cameraDistFromSun > ge_starDistFromSun) { float ratio = ge_starDistFromSun / ge_cameraDistFromSun; //color *= ratio * ratioMultiplier; } @@ -120,4 +119,3 @@ Fragment getFragment() { return frag; } - diff --git a/modules/gaia/shaders/gaia_point_fs.glsl b/modules/gaia/shaders/gaia_point_fs.glsl index 1277f9d589..a8402a6d02 100644 --- a/modules/gaia/shaders/gaia_point_fs.glsl +++ b/modules/gaia/shaders/gaia_point_fs.glsl @@ -57,14 +57,13 @@ vec3 color2rgb(float color) { } void main() { - // Assume all stars has equal luminosity as the Sun when no magnitude is loaded. float luminosity = 0.05; vec3 color = vec3(luminosity); float ratioMultiplier = 1.0; // Calculate the color and luminosity if we have the magnitude and B-V color. - if ( renderOption != RENDEROPTION_STATIC ) { + if (renderOption != RENDEROPTION_STATIC) { color = color2rgb(ge_brightness.y); ratioMultiplier = 0.01; @@ -89,7 +88,7 @@ void main() { color *= luminosity * pow(luminosityMultiplier, 3.0); // Decrease contributing brightness for stars in central cluster. - if ( ge_cameraDistFromSun > ge_starDistFromSun ) { + if (ge_cameraDistFromSun > ge_starDistFromSun) { float ratio = ge_starDistFromSun / ge_cameraDistFromSun; //color *= ratio * ratioMultiplier; } diff --git a/modules/gaia/shaders/gaia_point_ge.glsl b/modules/gaia/shaders/gaia_point_ge.glsl index f6dc071fd2..553917ec86 100644 --- a/modules/gaia/shaders/gaia_point_ge.glsl +++ b/modules/gaia/shaders/gaia_point_ge.glsl @@ -46,7 +46,6 @@ uniform float viewScaling; uniform float cutOffThreshold; void main() { - ge_brightness = vs_brightness[0]; ge_starDistFromSun = vs_starDistFromSun[0]; ge_cameraDistFromSun = vs_cameraDistFromSun[0]; diff --git a/modules/gaia/shaders/gaia_ssbo_vs.glsl b/modules/gaia/shaders/gaia_ssbo_vs.glsl index 00db0a2361..67b09bdbdd 100644 --- a/modules/gaia/shaders/gaia_ssbo_vs.glsl +++ b/modules/gaia/shaders/gaia_ssbo_vs.glsl @@ -67,8 +67,7 @@ uniform vec2 distThreshold; // Use binary search to find the chunk containing our star ID. int findChunkId(int left, int right, int id) { - - while ( left <= right ) { + while (left <= right) { int middle = (left + right) / 2; int firstStarInChunk = starsPerChunk[middle]; if (left == right || (firstStarInChunk <= id && id < starsPerChunk[middle+1])) { @@ -111,14 +110,15 @@ void main() { vec3 in_velocity = vec3(0.0); // Check if we should filter this star by position. - if ( (abs(posXThreshold.x) > EPS && in_position.x < posXThreshold.x) || + if ((abs(posXThreshold.x) > EPS && in_position.x < posXThreshold.x) || (abs(posXThreshold.y) > EPS && in_position.x > posXThreshold.y) || (abs(posYThreshold.x) > EPS && in_position.y < posYThreshold.x) || (abs(posYThreshold.y) > EPS && in_position.y > posYThreshold.y) || (abs(posZThreshold.x) > EPS && in_position.z < posZThreshold.x) || (abs(posZThreshold.y) > EPS && in_position.z > posZThreshold.y) || (abs(distThreshold.x - distThreshold.y) < EPS - && abs(length(in_position) - distThreshold.y) < EPS) ) { + && abs(length(in_position) - distThreshold.y) < EPS)) + { // Discard star in geometry shader. vs_gPosition = vec4(0.0); gl_Position = vec4(0.0); @@ -126,24 +126,25 @@ void main() { } - if ( renderOption != RENDEROPTION_STATIC ) { + if (renderOption != RENDEROPTION_STATIC) { int startOfCol = firstStarInChunk + nStarsInChunk * 3 + placeInChunk * 2; in_brightness = vec2(allData[startOfCol], allData[startOfCol + 1]); // Check if we should filter this star by magnitude or color. - if ( (abs(gMagThreshold.x - gMagThreshold.y) < EPS && abs(gMagThreshold.x - in_brightness.x) < EPS) || + if ((abs(gMagThreshold.x - gMagThreshold.y) < EPS && abs(gMagThreshold.x - in_brightness.x) < EPS) || (abs(gMagThreshold.x - 20.0f) > EPS && in_brightness.x < gMagThreshold.x) || (abs(gMagThreshold.y - 20.0f) > EPS && in_brightness.x > gMagThreshold.y) || (abs(bpRpThreshold.x - bpRpThreshold.y) < EPS && abs(bpRpThreshold.x - in_brightness.y) < EPS) || (abs(bpRpThreshold.x) > EPS && in_brightness.y < bpRpThreshold.x) || - (abs(bpRpThreshold.y) > EPS && in_brightness.y > bpRpThreshold.y) ) { + (abs(bpRpThreshold.y) > EPS && in_brightness.y > bpRpThreshold.y)) + { // Discard star in geometry shader. vs_gPosition = vec4(0.0); gl_Position = vec4(0.0); return; } - if ( renderOption == RENDEROPTION_MOTION ) { + if (renderOption == RENDEROPTION_MOTION) { int startOfVel = firstStarInChunk + nStarsInChunk * 5 + placeInChunk * 3; in_velocity = vec3(allData[startOfVel], allData[startOfVel + 1], allData[startOfVel + 2]); } @@ -157,10 +158,11 @@ void main() { objectPosition.xyz += time * in_velocity; // Thres moving stars by their new position. - float distPosition = length(objectPosition.xyz / (1000.0 * Parsec) ); - if ( (abs(distThreshold.x - distThreshold.y) > EPS && + float distPosition = length(objectPosition.xyz / (1000.0 * Parsec)); + if ((abs(distThreshold.x - distThreshold.y) > EPS && ((abs(distThreshold.x) > EPS && distPosition < distThreshold.x) || - (abs(distThreshold.y) > EPS && distPosition > distThreshold.y))) ) { + (abs(distThreshold.y) > EPS && distPosition > distThreshold.y)))) + { // Discard star in geometry shader. vs_gPosition = vec4(0.0); gl_Position = vec4(0.0); @@ -176,7 +178,7 @@ void main() { // Remove stars without position, happens when VBO chunk is stuffed with zeros. // Has to be done in Geometry shader because Vertices cannot be discarded here. - if ( length(in_position) > EPS ){ + if (length(in_position) > EPS){ vs_gPosition = vec4(model * objectPosition); gl_Position = vec4(projection * viewPosition); } diff --git a/modules/gaia/shaders/gaia_tonemapping_billboard_fs.glsl b/modules/gaia/shaders/gaia_tonemapping_billboard_fs.glsl index f84450bccf..f69f3e3b00 100644 --- a/modules/gaia/shaders/gaia_tonemapping_billboard_fs.glsl +++ b/modules/gaia/shaders/gaia_tonemapping_billboard_fs.glsl @@ -32,7 +32,6 @@ const float DEFAULT_DEPTH = 3.08567758e19; // 1000 Pc Fragment getFragment() { - vec4 color = vec4(0.0); // BILLBOARDS diff --git a/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl b/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl index 2bff48de8d..c6c0f45539 100644 --- a/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl +++ b/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl @@ -37,7 +37,6 @@ const float M_PI = 3.141592653589793238462; const float DEFAULT_DEPTH = 3.08567758e19; // 1000 Pc Fragment getFragment() { - vec4 color = vec4(0.0); // GL_POINTS diff --git a/modules/gaia/shaders/gaia_vbo_vs.glsl b/modules/gaia/shaders/gaia_vbo_vs.glsl index 281eea7157..e2e5cf1b29 100644 --- a/modules/gaia/shaders/gaia_vbo_vs.glsl +++ b/modules/gaia/shaders/gaia_vbo_vs.glsl @@ -59,7 +59,7 @@ void main() { vs_brightness = in_brightness; // Check if we should filter this star by position. Thres depending on original values. - if ( (abs(posXThreshold.x) > EPS && in_position.x < posXThreshold.x) || + if ((abs(posXThreshold.x) > EPS && in_position.x < posXThreshold.x) || (abs(posXThreshold.y) > EPS && in_position.x > posXThreshold.y) || (abs(posYThreshold.x) > EPS && in_position.y < posYThreshold.x) || (abs(posYThreshold.y) > EPS && in_position.y > posYThreshold.y) || @@ -73,7 +73,8 @@ void main() { (abs(gMagThreshold.y - 20.0f) > EPS && in_brightness.x > gMagThreshold.y) || (abs(bpRpThreshold.x - bpRpThreshold.y) < EPS && abs(bpRpThreshold.x - in_brightness.y) < EPS) || (abs(bpRpThreshold.x) > EPS && in_brightness.y < bpRpThreshold.x) || - (abs(bpRpThreshold.y) > EPS && in_brightness.y > bpRpThreshold.y))) ) { + (abs(bpRpThreshold.y) > EPS && in_brightness.y > bpRpThreshold.y)))) + { // Discard star in geometry shader. vs_gPosition = vec4(0.0); gl_Position = vec4(0.0); @@ -84,16 +85,17 @@ void main() { vec4 objectPosition = vec4(in_position * 1000 * Parsec, 1.0); // Add velocity if we've read any. - if ( renderOption == RENDEROPTION_MOTION ) { + if (renderOption == RENDEROPTION_MOTION) { // Velocity is already in [m/s]. objectPosition.xyz += time * in_velocity; } // Thres moving stars by their new position. float distPosition = length(objectPosition.xyz / (1000.0 * Parsec) ); - if ( (abs(distThreshold.x - distThreshold.y) > EPS && + if ((abs(distThreshold.x - distThreshold.y) > EPS && ((abs(distThreshold.x) > EPS && distPosition< distThreshold.x) || - (abs(distThreshold.y) > EPS && distPosition > distThreshold.y))) ) { + (abs(distThreshold.y) > EPS && distPosition > distThreshold.y)))) + { // Discard star in geometry shader. vs_gPosition = vec4(0.0); gl_Position = vec4(0.0); @@ -109,7 +111,7 @@ void main() { // Remove stars without position, happens when VBO chunk is stuffed with zeros. // Has to be done in Geometry shader because Vertices cannot be discarded here. - if ( length(in_position) > EPS ){ + if (length(in_position) > EPS) { vs_gPosition = vec4(model * objectPosition); gl_Position = vec4(projection * viewPosition); } diff --git a/modules/galaxy/shaders/billboard_vs.glsl b/modules/galaxy/shaders/billboard_vs.glsl index 813bd111c7..36e1cb8f56 100644 --- a/modules/galaxy/shaders/billboard_vs.glsl +++ b/modules/galaxy/shaders/billboard_vs.glsl @@ -30,7 +30,6 @@ layout(location = 1) in vec3 in_color; out vec3 vs_color; void main() { - vs_color = in_color; - - gl_Position = vec4(in_position, 1.0); + vs_color = in_color; + gl_Position = vec4(in_position, 1.0); } diff --git a/modules/galaxy/shaders/points_vs.glsl b/modules/galaxy/shaders/points_vs.glsl index bd5f43daca..9b7612e4c5 100644 --- a/modules/galaxy/shaders/points_vs.glsl +++ b/modules/galaxy/shaders/points_vs.glsl @@ -41,18 +41,18 @@ uniform dvec3 eyePosition; const double PARSEC = 3.08567756E16; void main() { - vs_position = vec4(in_position, 1.0); - dvec4 dpos = dvec4(vs_position); + vs_position = vec4(in_position, 1.0); + dvec4 dpos = dvec4(vs_position); - double distanceToStar = length((dpos.xyz - eyePosition)); - vs_starBrightness = clamp(float(8000*PARSEC/distanceToStar), 0.0, 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; + dpos.xyz *= 8.0; + dpos = modelMatrix * dpos; + dpos /= PARSEC; - vec4 positionScreenSpace = z_normalization(vec4(cameraViewProjectionMatrix * dpos)); - vs_color = in_color; - vs_screenSpaceDepth = positionScreenSpace.w; - gl_Position = positionScreenSpace; + vec4 positionScreenSpace = z_normalization(vec4(cameraViewProjectionMatrix * dpos)); + vs_color = in_color; + vs_screenSpaceDepth = positionScreenSpace.w; + gl_Position = positionScreenSpace; } diff --git a/modules/globebrowsing/shaders/renderer_fs.glsl b/modules/globebrowsing/shaders/renderer_fs.glsl index fe525ed874..09d291cc93 100644 --- a/modules/globebrowsing/shaders/renderer_fs.glsl +++ b/modules/globebrowsing/shaders/renderer_fs.glsl @@ -1,300 +1,300 @@ - /***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2021 * - * * - * 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-2021 * + * * + * 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. * + ****************************************************************************************/ - #include "fragment.glsl" +#include "fragment.glsl" - #include <${MODULE_GLOBEBROWSING}/shaders/tile.hglsl> - #include <${MODULE_GLOBEBROWSING}/shaders/texturetilemapping.hglsl> - #include <${MODULE_GLOBEBROWSING}/shaders/tileheight.hglsl> - #include "PowerScaling/powerScaling_fs.hglsl" +#include <${MODULE_GLOBEBROWSING}/shaders/tile.hglsl> +#include <${MODULE_GLOBEBROWSING}/shaders/texturetilemapping.hglsl> +#include <${MODULE_GLOBEBROWSING}/shaders/tileheight.hglsl> +#include "PowerScaling/powerScaling_fs.hglsl" - // Below are all the tiles that are used for contributing the actual fragment color +// Below are all the tiles that are used for contributing the actual fragment color - #if USE_COLORTEXTURE - uniform Layer ColorLayers[NUMLAYERS_COLORTEXTURE]; - #endif // USE_COLORTEXTURE +#if USE_COLORTEXTURE +uniform Layer ColorLayers[NUMLAYERS_COLORTEXTURE]; +#endif // USE_COLORTEXTURE - #if USE_NIGHTTEXTURE - uniform Layer NightLayers[NUMLAYERS_NIGHTTEXTURE]; - #endif // USE_NIGHTTEXTURE +#if USE_NIGHTTEXTURE +uniform Layer NightLayers[NUMLAYERS_NIGHTTEXTURE]; +#endif // USE_NIGHTTEXTURE - #if USE_OVERLAY - uniform Layer Overlays[NUMLAYERS_OVERLAY]; - #endif // USE_OVERLAY +#if USE_OVERLAY +uniform Layer Overlays[NUMLAYERS_OVERLAY]; +#endif // USE_OVERLAY - #if USE_WATERMASK - uniform Layer WaterMasks[NUMLAYERS_WATERMASK]; - #endif // USE_WATERMASK +#if USE_WATERMASK +uniform Layer WaterMasks[NUMLAYERS_WATERMASK]; +#endif // USE_WATERMASK - #if SHOW_HEIGHT_RESOLUTION - uniform vec2 vertexResolution; +#if SHOW_HEIGHT_RESOLUTION +uniform vec2 vertexResolution; +#endif + +//#if USE_NIGHTTEXTURE || USE_WATERMASK || PERFORM_SHADING +uniform vec3 lightDirectionCameraSpace; +//#endif + +#if PERFORM_SHADING +uniform float orenNayarRoughness; +#endif + +#if SHADOW_MAPPING_ENABLED + +#define NSSamplesMinusOne #{nShadowSamples} +#define NSSamples (NSSamplesMinusOne + 1) + +in vec4 shadowCoords; +uniform sampler2DShadow shadowMapTexture; +uniform float zFightingPercentage; +#endif + +#if USE_ECLIPSE_SHADOWS + + +#define NSEclipseShadowsMinusOne #{nEclipseShadows} +#define NSEclipseShadows (NSEclipseShadowsMinusOne + 1) + +/******************************************************************************* + ***** ALL CALCULATIONS FOR ECLIPSE ARE IN METERS AND IN WORLD SPACE SYSTEM **** + *******************************************************************************/ +struct ShadowRenderingStruct { + double xu, xp; + double rs, rc; + dvec3 sourceCasterVec; + dvec3 casterPositionVec; + bool isShadowing; +}; + +// Eclipse shadow data +// JCC: Remove and use dictionary to +// decides the number of shadows +uniform ShadowRenderingStruct shadowDataArray[NSEclipseShadows]; +uniform int shadows; +uniform bool hardShadows; + +vec4 calcShadow(const ShadowRenderingStruct shadowInfoArray[NSEclipseShadows], + const dvec3 position, const bool ground) +{ + #for i in 0..#{nEclipseShadows} + if (shadowInfoArray[#{i}].isShadowing) { + dvec3 pc = shadowInfoArray[#{i}].casterPositionVec - position; + dvec3 sc_norm = shadowInfoArray[#{i}].sourceCasterVec; + dvec3 pc_proj = dot(pc, sc_norm) * sc_norm; + dvec3 d = pc - pc_proj; + + + float length_d = float(length(d)); + double length_pc_proj = length(pc_proj); + + float r_p_pi = float(shadowInfoArray[#{i}].rc * (length_pc_proj + shadowInfoArray[#{i}].xp) / shadowInfoArray[#{i}].xp); + float r_u_pi = float(shadowInfoArray[#{i}].rc * (shadowInfoArray[#{i}].xu - length_pc_proj) / shadowInfoArray[#{i}].xu); + + if (length_d < r_u_pi) { // umbra + if (ground) { + #if USE_ECLIPSE_HARD_SHADOWS + return vec4(0.2, 0.2, 0.2, 1.0); + #else + // butterworthFunc + return vec4(vec3(sqrt(r_u_pi / (r_u_pi + pow(length_d, 2.0)))), 1.0); #endif - - //#if USE_NIGHTTEXTURE || USE_WATERMASK || PERFORM_SHADING - uniform vec3 lightDirectionCameraSpace; - //#endif - - #if PERFORM_SHADING - uniform float orenNayarRoughness; - #endif - - #if SHADOW_MAPPING_ENABLED - - #define NSSamplesMinusOne #{nShadowSamples} - #define NSSamples (NSSamplesMinusOne + 1) - - in vec4 shadowCoords; - uniform sampler2DShadow shadowMapTexture; - uniform float zFightingPercentage; - #endif - - #if USE_ECLIPSE_SHADOWS - - - #define NSEclipseShadowsMinusOne #{nEclipseShadows} - #define NSEclipseShadows (NSEclipseShadowsMinusOne + 1) - - /******************************************************************************* - ***** ALL CALCULATIONS FOR ECLIPSE ARE IN METERS AND IN WORLD SPACE SYSTEM **** - *******************************************************************************/ - struct ShadowRenderingStruct { - double xu, xp; - double rs, rc; - dvec3 sourceCasterVec; - dvec3 casterPositionVec; - bool isShadowing; - }; - - // Eclipse shadow data - // JCC: Remove and use dictionary to - // decides the number of shadows - uniform ShadowRenderingStruct shadowDataArray[NSEclipseShadows]; - uniform int shadows; - uniform bool hardShadows; - - vec4 calcShadow(const ShadowRenderingStruct shadowInfoArray[NSEclipseShadows], - const dvec3 position, const bool ground) - { - #for i in 0..#{nEclipseShadows} - if (shadowInfoArray[#{i}].isShadowing) { - dvec3 pc = shadowInfoArray[#{i}].casterPositionVec - position; - dvec3 sc_norm = shadowInfoArray[#{i}].sourceCasterVec; - dvec3 pc_proj = dot(pc, sc_norm) * sc_norm; - dvec3 d = pc - pc_proj; - - - float length_d = float(length(d)); - double length_pc_proj = length(pc_proj); - - float r_p_pi = float(shadowInfoArray[#{i}].rc * (length_pc_proj + shadowInfoArray[#{i}].xp) / shadowInfoArray[#{i}].xp); - float r_u_pi = float(shadowInfoArray[#{i}].rc * (shadowInfoArray[#{i}].xu - length_pc_proj) / shadowInfoArray[#{i}].xu); - - if (length_d < r_u_pi) { // umbra - if (ground) { - #if USE_ECLIPSE_HARD_SHADOWS - return vec4(0.2, 0.2, 0.2, 1.0); - #else - // butterworthFunc - return vec4(vec3(sqrt(r_u_pi / (r_u_pi + pow(length_d, 2.0)))), 1.0); - #endif - } - else { - #if USE_ECLIPSE_HARD_SHADOWS - return vec4(0.5, 0.5, 0.5, 1.0); - #else - return vec4(vec3(length_d / r_p_pi), 1.0); - #endif - } } - else if (length_d < r_p_pi) {// penumbra - #if USE_ECLIPSE_HARD_SHADOWS - return vec4(0.5, 0.5, 0.5, 1.0); - #else + else { + #if USE_ECLIPSE_HARD_SHADOWS + return vec4(0.5, 0.5, 0.5, 1.0); + #else return vec4(vec3(length_d / r_p_pi), 1.0); - #endif + #endif } } - - #endfor - return vec4(1.0); - } - #endif - - in vec4 fs_position; - in vec2 fs_uv; - in vec3 ellipsoidNormalCameraSpace; - in vec3 levelWeights; - in vec3 positionCameraSpace; - - #if USE_ACCURATE_NORMALS - in vec3 ellipsoidTangentThetaCameraSpace; - in vec3 ellipsoidTangentPhiCameraSpace; - #endif // USE_ACCURATE_NORMALS - - #if USE_ECLIPSE_SHADOWS - in vec3 positionWorldSpace; - #endif // USE_ECLIPSE_SHADOWS - - - - Fragment getFragment() { - Fragment frag; - frag.color = vec4(0.3, 0.3, 0.3, 1.0); - - vec3 normal = normalize(ellipsoidNormalCameraSpace); - - #if USE_ACCURATE_NORMALS - normal = getTileNormal( - fs_uv, - levelWeights, - normalize(ellipsoidNormalCameraSpace), - normalize(ellipsoidTangentThetaCameraSpace), - normalize(ellipsoidTangentPhiCameraSpace) - ); - #endif /// USE_ACCURATE_NORMALS - - #if USE_COLORTEXTURE - frag.color = calculateColor(frag.color, fs_uv, levelWeights, ColorLayers); - #endif // USE_COLORTEXTURE - - #if USE_WATERMASK - float waterReflectance = 0.0; - frag.color = calculateWater( - frag.color, - fs_uv, - levelWeights, - WaterMasks, - normal, - lightDirectionCameraSpace, // Should already be normalized - positionCameraSpace, - waterReflectance - ); - - #endif // USE_WATERMASK - - #if USE_NIGHTTEXTURE - frag.color = calculateNight( - frag.color, - fs_uv, - levelWeights, - NightLayers, - normalize(ellipsoidNormalCameraSpace), - lightDirectionCameraSpace // Should already be normalized - ); - - #endif // USE_NIGHTTEXTURE - - #if PERFORM_SHADING - frag.color = calculateShadedColor( - frag.color, - normal, - lightDirectionCameraSpace, - normalize(positionCameraSpace), - orenNayarRoughness - ); - #endif // PERFORM_SHADING - - #if USE_ECLIPSE_SHADOWS - frag.color *= calcShadow(shadowDataArray, dvec3(positionWorldSpace), true); - #endif - - #if USE_OVERLAY - frag.color = calculateOverlay(frag.color, fs_uv, levelWeights, Overlays); - #endif // USE_OVERLAY - - #if SHOW_HEIGHT_INTENSITIES - frag.color.rgb *= vec3(0.1); - - float untransformedHeight = getUntransformedTileVertexHeight(fs_uv, levelWeights); - float contourLine = fract(10.0 * untransformedHeight) > 0.98 ? 1.0 : 0.0; - frag.color.r += untransformedHeight; - frag.color.b = contourLine; - #endif - - #if SHOW_HEIGHT_RESOLUTION - frag.color += 0.0001 * calculateDebugColor(fs_uv, fs_position, vertexResolution); - #if USE_HEIGHTMAP - frag.color.r = min(frag.color.r, 0.8); - frag.color.r += tileResolution(fs_uv, HeightLayers[0].pile.chunkTile0) > 0.9 ? 1 : 0; - #endif - #endif - - // Other data - #if USE_WATERMASK - // Water reflectance is added to the G-Buffer. - frag.gNormal.w = waterReflectance; + else if (length_d < r_p_pi) {// penumbra + #if USE_ECLIPSE_HARD_SHADOWS + return vec4(0.5, 0.5, 0.5, 1.0); #else - frag.gNormal.w = 0.0; + return vec4(vec3(length_d / r_p_pi), 1.0); #endif - // 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 - } - else { - frag.gPosition = vec4(1.0); // in Camera Rig Space + } } - frag.depth = fs_position.w; + #endfor + return vec4(1.0); +} +#endif - #if SHOW_CHUNK_EDGES - const float BorderSize = 0.005; - const vec3 BorderColor = vec3(1.0, 0.0, 0.0); +in vec4 fs_position; +in vec2 fs_uv; +in vec3 ellipsoidNormalCameraSpace; +in vec3 levelWeights; +in vec3 positionCameraSpace; - vec2 uvOffset = fs_uv - vec2(0.5); - float thres = 0.5 - BorderSize * 0.5; - bool isBorder = abs(uvOffset.x) > thres || abs(uvOffset.y) > thres; - if (isBorder) { - frag.color.rgb += BorderColor; - } - #endif // SHOW_CHUNK_EDGES +#if USE_ACCURATE_NORMALS + in vec3 ellipsoidTangentThetaCameraSpace; + in vec3 ellipsoidTangentPhiCameraSpace; +#endif // USE_ACCURATE_NORMALS - #if SHADOW_MAPPING_ENABLED - float shadow = 1.0; - if (shadowCoords.w > 1) { - vec4 normalizedShadowCoords = shadowCoords; - normalizedShadowCoords.z = normalizeFloat(zFightingPercentage * normalizedShadowCoords.w); - normalizedShadowCoords.xy = normalizedShadowCoords.xy / normalizedShadowCoords.w; - normalizedShadowCoords.w = 1.0; +#if USE_ECLIPSE_SHADOWS +in vec3 positionWorldSpace; +#endif // USE_ECLIPSE_SHADOWS - float sum = 0; - #for i in 0..#{nShadowSamples} - sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, -NSSamples + #{i})); - sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, 0)); - sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, NSSamples - #{i})); - sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , -NSSamples + #{i})); - sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , NSSamples - #{i})); - sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, -NSSamples + #{i})); - sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, 0)); - sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, NSSamples - #{i})); - #endfor - sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(0, 0)); - shadow = sum / (8.0 * NSSamples + 1.f); - } - frag.color.xyz *= shadow < 0.99 ? clamp(shadow + 0.3, 0.0, 1.0) : shadow; + + +Fragment getFragment() { + Fragment frag; + frag.color = vec4(0.3, 0.3, 0.3, 1.0); + + vec3 normal = normalize(ellipsoidNormalCameraSpace); + +#if USE_ACCURATE_NORMALS + normal = getTileNormal( + fs_uv, + levelWeights, + normalize(ellipsoidNormalCameraSpace), + normalize(ellipsoidTangentThetaCameraSpace), + normalize(ellipsoidTangentPhiCameraSpace) + ); +#endif /// USE_ACCURATE_NORMALS + +#if USE_COLORTEXTURE + frag.color = calculateColor(frag.color, fs_uv, levelWeights, ColorLayers); +#endif // USE_COLORTEXTURE + +#if USE_WATERMASK + float waterReflectance = 0.0; + frag.color = calculateWater( + frag.color, + fs_uv, + levelWeights, + WaterMasks, + normal, + lightDirectionCameraSpace, // Should already be normalized + positionCameraSpace, + waterReflectance + ); + +#endif // USE_WATERMASK + +#if USE_NIGHTTEXTURE + frag.color = calculateNight( + frag.color, + fs_uv, + levelWeights, + NightLayers, + normalize(ellipsoidNormalCameraSpace), + lightDirectionCameraSpace // Should already be normalized + ); + +#endif // USE_NIGHTTEXTURE + +#if PERFORM_SHADING + frag.color = calculateShadedColor( + frag.color, + normal, + lightDirectionCameraSpace, + normalize(positionCameraSpace), + orenNayarRoughness + ); +#endif // PERFORM_SHADING + +#if USE_ECLIPSE_SHADOWS + frag.color *= calcShadow(shadowDataArray, dvec3(positionWorldSpace), true); +#endif + +#if USE_OVERLAY + frag.color = calculateOverlay(frag.color, fs_uv, levelWeights, Overlays); +#endif // USE_OVERLAY + +#if SHOW_HEIGHT_INTENSITIES + frag.color.rgb *= vec3(0.1); + + float untransformedHeight = getUntransformedTileVertexHeight(fs_uv, levelWeights); + float contourLine = fract(10.0 * untransformedHeight) > 0.98 ? 1.0 : 0.0; + frag.color.r += untransformedHeight; + frag.color.b = contourLine; +#endif + +#if SHOW_HEIGHT_RESOLUTION + frag.color += 0.0001 * calculateDebugColor(fs_uv, fs_position, vertexResolution); + #if USE_HEIGHTMAP + frag.color.r = min(frag.color.r, 0.8); + frag.color.r += tileResolution(fs_uv, HeightLayers[0].pile.chunkTile0) > 0.9 ? 1 : 0; #endif +#endif - return frag; + // Other data +#if USE_WATERMASK + // Water reflectance is added to the G-Buffer. + frag.gNormal.w = waterReflectance; +#else + frag.gNormal.w = 0.0; +#endif + // 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 } + else { + frag.gPosition = vec4(1.0); // in Camera Rig Space + } + + frag.depth = fs_position.w; + +#if SHOW_CHUNK_EDGES + const float BorderSize = 0.005; + const vec3 BorderColor = vec3(1.0, 0.0, 0.0); + + vec2 uvOffset = fs_uv - vec2(0.5); + float thres = 0.5 - BorderSize * 0.5; + bool isBorder = abs(uvOffset.x) > thres || abs(uvOffset.y) > thres; + if (isBorder) { + frag.color.rgb += BorderColor; + } +#endif // SHOW_CHUNK_EDGES + +#if SHADOW_MAPPING_ENABLED + float shadow = 1.0; + if (shadowCoords.w > 1) { + vec4 normalizedShadowCoords = shadowCoords; + normalizedShadowCoords.z = normalizeFloat(zFightingPercentage * normalizedShadowCoords.w); + normalizedShadowCoords.xy = normalizedShadowCoords.xy / normalizedShadowCoords.w; + normalizedShadowCoords.w = 1.0; + + float sum = 0; + #for i in 0..#{nShadowSamples} + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, -NSSamples + #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, 0)); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, NSSamples - #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , -NSSamples + #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , NSSamples - #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, -NSSamples + #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, 0)); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, NSSamples - #{i})); + #endfor + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(0, 0)); + shadow = sum / (8.0 * NSSamples + 1.f); + } + frag.color.xyz *= shadow < 0.99 ? clamp(shadow + 0.3, 0.0, 1.0) : shadow; +#endif + + return frag; +} diff --git a/modules/globebrowsing/shaders/rings_fs.glsl b/modules/globebrowsing/shaders/rings_fs.glsl index 24e5a8b649..d3fb2bc9e4 100644 --- a/modules/globebrowsing/shaders/rings_fs.glsl +++ b/modules/globebrowsing/shaders/rings_fs.glsl @@ -78,7 +78,7 @@ Fragment getFragment() { // shadow == 1.0 means it is not in shadow float shadow = 1.0; - if ( shadowCoords.z >= 0 ) { + if (shadowCoords.z >= 0) { vec4 normalizedShadowCoords = shadowCoords; normalizedShadowCoords.z = normalizeFloat(zFightingPercentage * normalizedShadowCoords.w); normalizedShadowCoords.xy = normalizedShadowCoords.xy / normalizedShadowCoords.w; diff --git a/modules/iswa/shaders/datasphere_fs.glsl b/modules/iswa/shaders/datasphere_fs.glsl index 18aa934c73..7c6d57670f 100644 --- a/modules/iswa/shaders/datasphere_fs.glsl +++ b/modules/iswa/shaders/datasphere_fs.glsl @@ -62,7 +62,8 @@ Fragment getFragment() { } diffuse = color; - } else { + } + else { for (int i = 0; i < numTextures; i++) { float v = texture(textures[i], vec2(vs_st.t, vs_st.s)).r; vec4 color = texture(transferFunctions[i], vec2(v, 0.0)); diff --git a/modules/multiresvolume/shaders/raycast.glsl b/modules/multiresvolume/shaders/raycast.glsl index ce7f76f3fe..cfed83b0c7 100644 --- a/modules/multiresvolume/shaders/raycast.glsl +++ b/modules/multiresvolume/shaders/raycast.glsl @@ -72,7 +72,8 @@ float stepSize#{id}(vec3 samplePos, vec3 dir) { return 0.01; if (true /*opacity_#{id} >= MULTIRES_OPACITY_THRESHOLD*/) { return stepSizeCoefficient_#{id}/float(maxNumBricksPerAxis_#{id})/float(paddedBrickDim_#{id}); - } else { + } + else { // return a number that is garantueed to be bigger than the whole volume return 2.0; } @@ -110,7 +111,8 @@ void sample#{id}(vec3 samplePos, vec3 dir, inout vec3 accumulatedColor, vec3 oneMinusFrontAlpha = vec3(1.0) - accumulatedAlpha; accumulatedColor += oneMinusFrontAlpha * contribution.rgb * contribution.a; accumulatedAlpha += oneMinusFrontAlpha * vec3(contribution.a); - } else { + } + else { maxStepSize = 2.0; } } diff --git a/modules/space/shaders/convolution_fs.glsl b/modules/space/shaders/convolution_fs.glsl index bef1ba74ee..c884ce1846 100644 --- a/modules/space/shaders/convolution_fs.glsl +++ b/modules/space/shaders/convolution_fs.glsl @@ -34,7 +34,7 @@ uniform int convolvedfTextureSize; uniform sampler2D psfTexture; uniform sampler2D shapeTexture; -void main(void) { +void main() { float fullColor = 0.0; // Kernel Center diff --git a/modules/space/shaders/debrisViz_vs.glsl b/modules/space/shaders/debrisViz_vs.glsl index 03eb925bcb..7ec4e86faf 100644 --- a/modules/space/shaders/debrisViz_vs.glsl +++ b/modules/space/shaders/debrisViz_vs.glsl @@ -49,7 +49,6 @@ out float vertexID_f; // out double tajm; void main() { - // tajm = inGameTime; /** The way the position and line fade is calculated is: * By using inGameTime, epoch and period of this orbit, @@ -91,10 +90,4 @@ void main() { vec4 vs_position = z_normalization( projectionTransform * viewSpacePosition); gl_Position = vs_position; vs_position_w = vs_position.w; - } - - - - - diff --git a/modules/space/shaders/psfToTexture_fs.glsl b/modules/space/shaders/psfToTexture_fs.glsl index 39ff47ccc1..288149d9b2 100644 --- a/modules/space/shaders/psfToTexture_fs.glsl +++ b/modules/space/shaders/psfToTexture_fs.glsl @@ -39,7 +39,7 @@ uniform float betaConstant; in vec2 psfCoords; -void main(void) { +void main() { vec4 fullColor = vec4(0.0, 0.0, 0.0, 1.0); if (psfMethod == 0) { // PSF Functions from paper: Physically-Based Galre Effects for Digital @@ -50,7 +50,8 @@ void main(void) { float f2 = 72.37/pow(theta + alphaConst, 2.0); float psf_p = p0Param * f0 + p1Param * f1 + p2Param * f2; fullColor = vec4(psf_p); - } else if (psfMethod == 1) { + } + else if (psfMethod == 1) { // Moffat float r = sqrt((psfCoords.y*psfCoords.y + psfCoords.x*psfCoords.x)) * 90.0; float alpha = FWHM / (2.f * sqrt(pow(2.f, 1.f/betaConstant) - 1)); diff --git a/modules/space/shaders/star_ge.glsl b/modules/space/shaders/star_ge.glsl index 5e81e33ab0..759927b7f1 100644 --- a/modules/space/shaders/star_ge.glsl +++ b/modules/space/shaders/star_ge.glsl @@ -186,5 +186,4 @@ void main() { EmitVertex(); EndPrimitive(); - } diff --git a/modules/spacecraftinstruments/shaders/dilation_fs.glsl b/modules/spacecraftinstruments/shaders/dilation_fs.glsl index b91f8b9fe2..18df1d1f08 100644 --- a/modules/spacecraftinstruments/shaders/dilation_fs.glsl +++ b/modules/spacecraftinstruments/shaders/dilation_fs.glsl @@ -77,7 +77,6 @@ vec3 gatherNeighboringColors() { else { return vec3(0.0); } - } void main() { diff --git a/modules/spacecraftinstruments/shaders/renderablePlanetProjection_fs.glsl b/modules/spacecraftinstruments/shaders/renderablePlanetProjection_fs.glsl index 76971686d7..dcba10ec68 100644 --- a/modules/spacecraftinstruments/shaders/renderablePlanetProjection_fs.glsl +++ b/modules/spacecraftinstruments/shaders/renderablePlanetProjection_fs.glsl @@ -44,7 +44,7 @@ uniform vec3 boresight; #define M_PI 3.14159265358979323846 -vec4 uvToModel(vec2 uv, vec3 radius, float segments){ +vec4 uvToModel(vec2 uv, vec3 radius, float segments) { float fj = uv.x * segments; float fi = (1.0 - uv.y) * segments; diff --git a/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl b/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl index 008a50fe2a..ac79d14c86 100644 --- a/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl +++ b/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl @@ -36,7 +36,7 @@ uniform mat4 modelViewProjectionTransform; uniform vec3 shadowColor; void main() { - if (mod(gl_VertexID,2) == 0.0) { + if (mod(gl_VertexID, 2) == 0.0) { vs_color = shadowColor; } else { diff --git a/modules/toyvolume/shaders/boundsfs.glsl b/modules/toyvolume/shaders/boundsfs.glsl index 0b875972f9..6905e234e4 100644 --- a/modules/toyvolume/shaders/boundsfs.glsl +++ b/modules/toyvolume/shaders/boundsfs.glsl @@ -28,6 +28,7 @@ in vec3 modelPosition; in vec4 viewPosition; + Fragment getFragment() { Fragment frag; frag.color = vec4(modelPosition + 0.5, 1.0); diff --git a/modules/volume/shaders/boundsfs.glsl b/modules/volume/shaders/boundsfs.glsl index 4259a6f7ab..32d585b4de 100644 --- a/modules/volume/shaders/boundsfs.glsl +++ b/modules/volume/shaders/boundsfs.glsl @@ -28,6 +28,7 @@ in vec4 positionLocalSpace; in vec4 positionCameraSpace; + Fragment getFragment() { vec4 position = positionCameraSpace; diff --git a/modules/webbrowser/shaders/screenspace_vs.glsl b/modules/webbrowser/shaders/screenspace_vs.glsl index f3369a8536..cb76445436 100644 --- a/modules/webbrowser/shaders/screenspace_vs.glsl +++ b/modules/webbrowser/shaders/screenspace_vs.glsl @@ -35,6 +35,6 @@ out vec4 vs_position; void main(){ vs_st = in_st; - vs_position = ViewProjectionMatrix * ModelTransform * in_position * vec4(1.0, -1.0, 1.0, 1.0); - gl_Position = vec4(vs_position); + vs_position = ViewProjectionMatrix * ModelTransform * in_position * vec4(1.0, -1.0, 1.0, 1.0); + gl_Position = vec4(vs_position); } diff --git a/shaders/PowerScaling/powerScaling_fs.hglsl b/shaders/PowerScaling/powerScaling_fs.hglsl index dff9584f9d..c09e68c724 100644 --- a/shaders/PowerScaling/powerScaling_fs.hglsl +++ b/shaders/PowerScaling/powerScaling_fs.hglsl @@ -31,26 +31,6 @@ #include "powerScalingMath.hglsl" -const float s_far = 27.0f; //= gl_DepthRange.far; // 40 -const float s_farcutoff = 12.0f; -const float s_nearcutoff = 7.00f; -const float s_near = 1.00f;// gl_DepthRange.near; // 0.1 - -vec4 psc_normlization(vec4 invec) { - - float xymax = max(invec.x,invec.y); - - if(invec.z > 0.0f || invec.z < 0.0f) { - return invec / abs(invec.z); - } else if (xymax != 0.0f) { - return invec / xymax; - } else { - return invec / -.0; - } -} - - - float pscDepth(vec4 position) { // For now: simply convert power scaled coordinates to a linear scale. // TODO: get rid of power scaled coordinates and use scale graph instead. @@ -58,6 +38,4 @@ float pscDepth(vec4 position) { return safeLength(pscToLinear(position)); } - - #endif diff --git a/shaders/PowerScaling/powerScaling_vs.hglsl b/shaders/PowerScaling/powerScaling_vs.hglsl index bd3572ac1f..d422a897bb 100644 --- a/shaders/PowerScaling/powerScaling_vs.hglsl +++ b/shaders/PowerScaling/powerScaling_vs.hglsl @@ -37,15 +37,6 @@ vec4 psc_to_meter(vec4 v1, vec2 v2) { return vec4(v1.xyz * factor, 1.0); } -vec4 psc_scaling(vec4 v1, vec2 v2) { - float ds = v2.y - v1.w; - if(ds >= 0) { - return vec4(v1.xyz * v2.x * pow(k,v1.w), v2.y); - } else { - return vec4(v1.xyz * v2.x * pow(k,v2.y), v1.w); - } -} - // vertexPosition is returned as the transformed vertex in OS Camera Rig Space in PSC vec4 pscTransform(inout vec4 vertexPosition, mat4 modelTransform) { vec3 local_vertex_pos = mat3(modelTransform) * vertexPosition.xyz; @@ -59,7 +50,13 @@ vec4 pscTransform(inout vec4 vertexPosition, mat4 modelTransform) { // rotate the camera vertexPosition.xyz = mat3(camrot) * vertexPosition.xyz; vec4 tmp = vertexPosition; - vertexPosition = psc_scaling(vertexPosition, scaling); + + float ds = scaling.y - vertexPosition.w; + if (ds >= 0) { + vertexPosition = vec4(vertexPosition.xyz * scaling.x * pow(k, vertexPosition.w), scaling.y); + } else { + vertexPosition = vec4(vertexPosition.xyz * scaling.x * pow(k, scaling.y), vertexPosition.w); + } // project using the rescaled coordinates, tmp = psc_to_meter(tmp, scaling); diff --git a/shaders/abuffer/resolvehelpers.glsl b/shaders/abuffer/resolvehelpers.glsl index c7bbefc8a0..f2b03b77be 100644 --- a/shaders/abuffer/resolvehelpers.glsl +++ b/shaders/abuffer/resolvehelpers.glsl @@ -53,7 +53,15 @@ uniform vec3 cameraPosInRaycaster#{index} #endif - +/** + * Normalize a vector + * Supporting huge vectors, where the square of any of the components is too large to be + * represent as a float. + */ +vec3 safeNormalize(vec3 v) { + float m = max(max(abs(v.x), abs(v.y)), abs(v.z)); + return normalize(v / m); +} uniform int nAaSamples; diff --git a/shaders/floatoperations.glsl b/shaders/floatoperations.glsl index 7fb62d77f3..b583c386c8 100644 --- a/shaders/floatoperations.glsl +++ b/shaders/floatoperations.glsl @@ -62,32 +62,7 @@ float safeLength(vec4 v) { } } -float safeLength(vec3 v) { - float m = max(max(abs(v.x), abs(v.y)), abs(v.z)); - if (m > 0.f) { - return length(v / m) * m; - } else { - return 0.f; - } -} - -float safeLength(vec2 v) { - float m = max(abs(v.x), abs(v.y)); - if (m > 0.f) { - return length(v / m) * m; - } else { - return 0.f; - } -} - -/** - * Normalize a vector - * Supporting huge vectors, where the square of any of the components is too large to be - * represent as a float. - */ -vec3 safeNormalize(vec3 v) { - float m = max(max(abs(v.x), abs(v.y)), abs(v.z)); - return normalize(v / m); -} +float safeLength(vec3 v) { return safeLength(vec4(v, 0.0)); } +float safeLength(vec2 v) { return safeLength(vec4(v, 0.0, 0.0)); } #endif // _FLOATOPERATIONS_GLSL_ diff --git a/shaders/framebuffer/fxaa.frag b/shaders/framebuffer/fxaa.frag index 17d51c2eb6..2a86d8b9ea 100644 --- a/shaders/framebuffer/fxaa.frag +++ b/shaders/framebuffer/fxaa.frag @@ -230,4 +230,4 @@ void main() { } aaFinalColor = texture(renderedTexture, finalUV); -} \ No newline at end of file +}