From ab02a6dfd42bb44bdfbdf5a97221c0abdfbe81e2 Mon Sep 17 00:00:00 2001
From: Ptolemy <ptolemy@lindenlab.com>
Date: Fri, 29 Jan 2021 18:41:04 -0800
Subject: [PATCH] SL-14706 Merge Sovereign Engineer's fix for stars not
 centered around camera: Stars render around center of sim instead of center
 of camera.

---
 doc/contributions.txt             |  1 +
 indra/newview/lldrawpoolwlsky.cpp | 13 +++++++++----
 indra/newview/lldrawpoolwlsky.h   |  4 ++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 81c44d2961b..9daddf6ddc7 100755
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -1355,6 +1355,7 @@ Sovereign Engineer
     OPEN-343
 	SL-11625
 	SL-14705
+	SL-14706
 	SL-14707
 SpacedOut Frye
 	VWR-34
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index d4e7f1600e7..0c3d8f3098f 100644
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -226,7 +226,7 @@ void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightL
     }
 }
 
-void LLDrawPoolWLSky::renderStars(void) const
+void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const
 {
     LLGLSPipelineBlendSkyBox gls_skybox(true, false);
 	
@@ -266,6 +266,7 @@ void LLDrawPoolWLSky::renderStars(void) const
     }
 
 	gGL.pushMatrix();
+	gGL.translatef(camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]);
 	gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f);
 	if (LLGLSLShader::sNoFixedFunction)
 	{
@@ -296,7 +297,7 @@ void LLDrawPoolWLSky::renderStars(void) const
 	}
 }
 
-void LLDrawPoolWLSky::renderStarsDeferred(void) const
+void LLDrawPoolWLSky::renderStarsDeferred(const LLVector3& camPosLocal) const
 {
 	LLGLSPipelineBlendSkyBox gls_sky(true, false);
 
@@ -337,6 +338,8 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const
         gGL.getTexUnit(1)->bind(tex_b);
     }
 
+	gGL.pushMatrix();
+	gGL.translatef(camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]);
     gDeferredStarProgram.uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
 
     if (LLPipeline::sReflectionRender)
@@ -355,6 +358,8 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const
     gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
 
     gDeferredStarProgram.unbind();
+
+	gGL.popMatrix();
 }
 
 void LLDrawPoolWLSky::renderSkyCloudsDeferred(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const
@@ -601,7 +606,7 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
     if (gPipeline.canUseWindLightShaders())
     {
         renderSkyHazeDeferred(origin, camHeightLocal);
-        renderStarsDeferred();
+        renderStarsDeferred(origin);
         renderHeavenlyBodies();
         renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader);
     }
@@ -620,7 +625,7 @@ void LLDrawPoolWLSky::render(S32 pass)
     LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
     
 	renderSkyHaze(origin, camHeightLocal);    
-    renderStars();
+    renderStars(origin);
     renderHeavenlyBodies();	
 	renderSkyClouds(origin, camHeightLocal, cloud_shader);
 
diff --git a/indra/newview/lldrawpoolwlsky.h b/indra/newview/lldrawpoolwlsky.h
index a4f176d6db7..324886ed42f 100644
--- a/indra/newview/lldrawpoolwlsky.h
+++ b/indra/newview/lldrawpoolwlsky.h
@@ -78,8 +78,8 @@ class LLDrawPoolWLSky : public LLDrawPool {
 	void renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const;
     void renderSkyCloudsDeferred(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const;
 
-    void renderStarsDeferred(void) const;
-	void renderStars(void) const;
+    void renderStarsDeferred(const LLVector3& camPosLocal) const;
+	void renderStars(const LLVector3& camPosLocal) const;
 	void renderHeavenlyBodies();    
 };
 
-- 
GitLab