summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/starsF.glsl8
-rw-r--r--indra/newview/lldrawpoolwlsky.cpp53
-rw-r--r--indra/newview/lldrawpoolwlsky.h8
3 files changed, 52 insertions, 17 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
index 029a98e16a..f397a4a151 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
@@ -28,19 +28,19 @@
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_data[3];
#else
-#define frag_data gl_FragData
+#define frag_color gl_FragColor
#endif
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
uniform sampler2D diffuseMap;
+uniform float custom_alpha;
void main()
{
vec4 col = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy);
+ col.a *= custom_alpha;
- frag_data[0] = col;
- frag_data[1] = vec4(0,0,0,0);
- frag_data[2] = vec4(0,0,1,0);
+ frag_color = col;
}
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index 69a7b13537..cf4d63149c 100644
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -45,6 +45,7 @@
#include "llatmosphere.h"
static LLStaticHashedString sCamPosLocal("camPosLocal");
+static LLStaticHashedString sCustomAlpha("custom_alpha");
static LLGLSLShader* cloud_shader = NULL;
static LLGLSLShader* sky_shader = NULL;
@@ -226,7 +227,6 @@ void LLDrawPoolWLSky::renderStars(void) const
if (LLGLSLShader::sNoFixedFunction)
{
gCustomAlphaProgram.bind();
- static LLStaticHashedString sCustomAlpha("custom_alpha");
gCustomAlphaProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]);
}
else
@@ -251,6 +251,28 @@ void LLDrawPoolWLSky::renderStars(void) const
}
}
+void LLDrawPoolWLSky::renderStarsDeferred(void) const
+{
+ LLGLSPipelineSkyBox gls_sky;
+ LLGLEnable blend(GL_BLEND);
+ gGL.setSceneBlendType(LLRender::BT_ALPHA);
+
+ // *LAPRAS
+ F32 star_alpha = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / (2.f + ((rand() >> 16)/65535.0f)); // twinkle twinkle
+
+ // If start_brightness is not set, exit
+ if(star_alpha < 0.001f)
+ {
+ LL_DEBUGS("SKY") << "star_brightness below threshold." << LL_ENDL;
+ return;
+ }
+
+ gDeferredStarProgram.bind();
+ gDeferredStarProgram.uniform1f(sCustomAlpha, star_alpha);
+ gSky.mVOWLSkyp->drawStars();
+ gDeferredStarProgram.unbind();
+}
+
void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal) const
{
if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex())
@@ -358,32 +380,37 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
{
renderSkyHaze(origin, camHeightLocal);
- LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
gGL.pushMatrix();
-
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
- gDeferredStarProgram.bind();
// *NOTE: have to bind moon textures here since register combiners blending in
// renderStars() requires something to be bound and we might as well only
// bind the moon textures once.
gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture(LLRender::DIFFUSE_MAP));
gGL.getTexUnit(1)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture(LLRender::ALTERNATE_DIFFUSE_MAP));
- renderHeavenlyBodies();
-
- renderStars();
-
- gDeferredStarProgram.unbind();
-
- gGL.popMatrix();
-
- renderSkyClouds(origin, camHeightLocal);
+ renderHeavenlyBodies();
}
}
gGL.setColorMask(true, true);
}
+void LLDrawPoolWLSky::renderPostDeferred(S32 pass)
+{
+ const F32 camHeightLocal = LLEnvironment::instance().getCamHeight();
+
+ LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
+ gGL.pushMatrix();
+
+ gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
+
+ renderStarsDeferred();
+
+ gGL.popMatrix();
+
+ renderSkyClouds(origin, camHeightLocal);
+}
+
void LLDrawPoolWLSky::render(S32 pass)
{
if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))
diff --git a/indra/newview/lldrawpoolwlsky.h b/indra/newview/lldrawpoolwlsky.h
index db08d9b99a..309efdbc5b 100644
--- a/indra/newview/lldrawpoolwlsky.h
+++ b/indra/newview/lldrawpoolwlsky.h
@@ -52,6 +52,12 @@ public:
/*virtual*/ void endDeferredPass(S32 pass);
/*virtual*/ void renderDeferred(S32 pass);
+
+ /*virtual*/ S32 getNumPostDeferredPasses() { return 1; }
+ /*virtual*/ void beginPostDeferredPass(S32 pass) {}
+ /*virtual*/ void endPostDeferredPass(S32 pass) {}
+ /*virtual*/ void renderPostDeferred(S32 pass);
+
/*virtual*/ LLViewerTexture *getDebugTexture();
/*virtual*/ void beginRenderPass( S32 pass );
/*virtual*/ void endRenderPass( S32 pass );
@@ -76,7 +82,9 @@ private:
void renderFsSky(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const;
void renderDome(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const;
void renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const;
+
void renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const;
+ void renderStarsDeferred(void) const;
void renderStars(void) const;
void renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal) const;