Skip to content
Snippets Groups Projects
Commit 4fde1adb authored by Graham Linden's avatar Graham Linden
Browse files

Fix star rendering issues in ALM.

parent cafea5d9
No related branches found
No related tags found
No related merge requests found
...@@ -94,6 +94,10 @@ void main() ...@@ -94,6 +94,10 @@ void main()
alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1;
alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1;
if (alpha1 < 0.001f)
{
discard;
}
// Compute alpha2, for self shadowing effect // Compute alpha2, for self shadowing effect
// (1 - alpha2) will later be used as percentage of incoming sunlight // (1 - alpha2) will later be used as percentage of incoming sunlight
......
...@@ -36,10 +36,12 @@ VARYING vec2 vary_texcoord0; ...@@ -36,10 +36,12 @@ VARYING vec2 vary_texcoord0;
uniform sampler2D diffuseMap; uniform sampler2D diffuseMap;
uniform float custom_alpha; uniform float custom_alpha;
uniform vec4 sunlight_color;
void main() void main()
{ {
vec4 col = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = texture2D(diffuseMap, vary_texcoord0.xy);
col.rgb *= vertex_color.rgb;
col.a *= custom_alpha; col.a *= custom_alpha;
frag_color = col; frag_color = col;
} }
...@@ -273,7 +273,7 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const ...@@ -273,7 +273,7 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const
{ {
LLGLSPipelineSkyBox gls_sky; LLGLSPipelineSkyBox gls_sky;
LLGLEnable blend(GL_BLEND); LLGLEnable blend(GL_BLEND);
gGL.setSceneBlendType(LLRender::BT_ALPHA); gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA);
// *LAPRAS // *LAPRAS
F32 star_alpha = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / (2.f + ((rand() >> 16)/65535.0f)); // twinkle twinkle F32 star_alpha = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / (2.f + ((rand() >> 16)/65535.0f)); // twinkle twinkle
...@@ -286,8 +286,12 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const ...@@ -286,8 +286,12 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const
} }
gDeferredStarProgram.bind(); gDeferredStarProgram.bind();
gGL.getTexUnit(0)->bind(gSky.mVOSkyp->getBloomTex());
gDeferredStarProgram.uniform1f(sCustomAlpha, star_alpha); gDeferredStarProgram.uniform1f(sCustomAlpha, star_alpha);
gSky.mVOWLSkyp->drawStars(); gSky.mVOWLSkyp->drawStars();
gDeferredStarProgram.unbind(); gDeferredStarProgram.unbind();
} }
...@@ -318,6 +322,10 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() ...@@ -318,6 +322,10 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
LLGLEnable blend_on(GL_BLEND); LLGLEnable blend_on(GL_BLEND);
gPipeline.disableLights(); gPipeline.disableLights();
LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
gGL.pushMatrix();
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_SUN]; LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_SUN];
F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor();
...@@ -427,7 +435,9 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() ...@@ -427,7 +435,9 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
{ {
moon_shader->unbind(); moon_shader->unbind();
} }
} }
gGL.popMatrix();
} }
void LLDrawPoolWLSky::renderDeferred(S32 pass) void LLDrawPoolWLSky::renderDeferred(S32 pass)
...@@ -438,11 +448,9 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) ...@@ -438,11 +448,9 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
} }
LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY); LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY);
const F32 camHeightLocal = LLEnvironment::instance().getCamHeight(); const F32 camHeightLocal = LLEnvironment::instance().getCamHeight();
LLGLSNoFog disableFog; LLGLSNoFog disableFog;
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
LLGLDisable clip(GL_CLIP_PLANE0); LLGLDisable clip(GL_CLIP_PLANE0);
gGL.setColorMask(true, false); gGL.setColorMask(true, false);
...@@ -453,39 +461,46 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) ...@@ -453,39 +461,46 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
if (gPipeline.canUseWindLightShaders()) if (gPipeline.canUseWindLightShaders())
{ {
if (gPipeline.useAdvancedAtmospherics())
{ {
renderSkyHazeDeferred(origin, camHeightLocal); // Disable depth-test for sky, but re-enable depth writes for the cloud
// rendering below so the cloud shader can write out depth for the stars to test against
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
if (gPipeline.useAdvancedAtmospherics())
{
renderSkyHazeDeferred(origin, camHeightLocal);
}
else
{
renderSkyHaze(origin, camHeightLocal);
}
renderHeavenlyBodies();
} }
else
{
renderSkyHaze(origin, camHeightLocal);
gGL.pushMatrix();
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
renderHeavenlyBodies(); renderSkyClouds(origin, camHeightLocal);
gGL.popMatrix();
}
} }
gGL.setColorMask(true, true); gGL.setColorMask(true, true);
} }
void LLDrawPoolWLSky::renderPostDeferred(S32 pass) void LLDrawPoolWLSky::renderPostDeferred(S32 pass)
{ {
const F32 camHeightLocal = LLEnvironment::instance().getCamHeight();
LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
gGL.pushMatrix();
LLGLSNoFog disableFog;
LLGLDisable clip(GL_CLIP_PLANE0);
LLGLSquashToFarClip far_clip(get_current_projection());
gGL.pushMatrix();
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
gGL.setColorMask(true, false);
// would be nice to do this here, but would need said bodies
// to render at a realistic distance for depth-testing against the clouds...
//renderHeavenlyBodies();
renderStarsDeferred(); renderStarsDeferred();
gGL.popMatrix(); gGL.popMatrix();
gGL.setColorMask(true, true);
renderSkyClouds(origin, camHeightLocal);
} }
void LLDrawPoolWLSky::render(S32 pass) void LLDrawPoolWLSky::render(S32 pass)
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "llenvironment.h" #include "llenvironment.h"
#include "llsettingssky.h" #include "llsettingssky.h"
const F32 LLVOWLSky::DISTANCE_TO_STARS = (HORIZON_DIST - 10.f)*0.25f; const F32 LLVOWLSky::DISTANCE_TO_STARS = (HORIZON_DIST - 10.f) * 0.8f;
const U32 LLVOWLSky::MIN_SKY_DETAIL = 3; const U32 LLVOWLSky::MIN_SKY_DETAIL = 3;
const U32 LLVOWLSky::MAX_SKY_DETAIL = 180; const U32 LLVOWLSky::MAX_SKY_DETAIL = 180;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment