diff options
| author | Graham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com> | 2018-02-18 15:52:23 +0000 | 
|---|---|---|
| committer | Graham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com> | 2018-02-18 15:52:23 +0000 | 
| commit | 99b82d944937ce321f64aa91fb18ab2aedd3992a (patch) | |
| tree | f0bf6c2bf20bd3c79a9d07023c7344c279674b18 /indra/newview | |
| parent | e9edd37cdb39639e1ab24e2e63d4f83432282c88 (diff) | |
Atmospherics WIP
libatmosphere integrated in indra/llrender/llatmosphere.cpp
Still working on runtime shaders to use libatmosphere precomputed atmospherics textures
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/app_settings/logcontrol.xml | 2 | ||||
| -rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
| -rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl | 4 | ||||
| -rw-r--r-- | indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 4 | ||||
| -rw-r--r-- | indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl | 4 | ||||
| -rw-r--r-- | indra/newview/llappviewer.cpp | 7 | ||||
| -rw-r--r-- | indra/newview/lldrawpoolwlsky.cpp | 119 | ||||
| -rw-r--r-- | indra/newview/lldrawpoolwlsky.h | 2 | ||||
| -rw-r--r-- | indra/newview/llmeshrepository.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llviewershadermgr.cpp | 92 | ||||
| -rw-r--r-- | indra/newview/llviewershadermgr.h | 2 | ||||
| -rw-r--r-- | indra/newview/llviewertexture.cpp | 28 | ||||
| -rw-r--r-- | indra/newview/llviewertexture.h | 4 | ||||
| -rw-r--r-- | indra/newview/pipeline.cpp | 122 | ||||
| -rw-r--r-- | indra/newview/pipeline.h | 19 | 
15 files changed, 309 insertions, 113 deletions
| diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index ecd7c4bc36..380d7762d6 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -35,7 +35,7 @@  						</array>  					<key>tags</key>  						<array> -						</array> +              </array>  				</map>  				<map>  					<key>level</key><string>DEBUG</string> diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 4a4f4bfc61..d277a1158c 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10122,6 +10122,17 @@        <key>Value</key>        <integer>0</integer>      </map> +  <key>RenderUseAdvancedAtmospherics</key> +  <map> +    <key>Comment</key> +    <string>Use fancy precomputed atmospherics and stuff.</string> +    <key>Persist</key> +    <integer>1</integer> +    <key>Type</key> +    <string>Boolean</string> +    <key>Value</key> +    <integer>1</integer> +  </map>    <key>RenderUseTriStrips</key>    <map>      <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 03bdb754b5..7f1a8cce0d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -397,7 +397,9 @@ void main()  	float da = dot(norm.xyz, sun_dir.xyz);  	float final_da = max(0.0,da); -          final_da = min(final_da, 1.0f); +              final_da = min(final_da, 1.0f); + +// why an ad hoc gamma boost here? srgb_to_linear instead?  	      final_da = pow(final_da, 1.0/1.3);  	vec4 diffuse = texture2DRect(diffuseRect, tc); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index f7832521fa..cf076d156a 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -276,10 +276,6 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) {  		  + tmpAmbient)));  	//brightness of surface both sunlight and ambient -	/*setSunlitColor(pow(vec3(sunlight * .5), vec3(global_gamma)) * global_gamma); -	setAmblitColor(pow(vec3(tmpAmbient * .25), vec3(global_gamma)) * global_gamma); -	setAdditiveColor(pow(getAdditiveColor() * vec3(1.0 - temp1), vec3(global_gamma)) * global_gamma);*/ -  	setSunlitColor(vec3(sunlight * .5));  	setAmblitColor(vec3(tmpAmbient * .25));  	setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 81af1fdc8a..b2d9de6e73 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -238,8 +238,8 @@ void main()  	proj_tc.xyz /= proj_tc.w; -	float fa = falloff+1.0; -	float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); +	float fa = falloff + 1.0; +	float dist_atten = min(1.0 - (dist - 1.0 * (1.0 - fa)) / fa, 1.0);  	dist_atten *= dist_atten;  	dist_atten *= 2.0; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 95e5cbe09e..85ec2a6ebc 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -205,6 +205,7 @@  #include "llfloateroutfitsnapshot.h"  #include "llfloatersnapshot.h"  #include "llsidepanelinventory.h" +#include "llatmosphere.h"  // includes for idle() idleShutdown()  #include "llviewercontrol.h" @@ -1097,6 +1098,7 @@ bool LLAppViewer::init()  		}  	} +#if LL_RELEASE_FOR_DOWNLOAD  	char* PARENT = getenv("PARENT");  	if (! (PARENT && std::string(PARENT) == "SL_Launcher"))  	{ @@ -1109,6 +1111,7 @@ bool LLAppViewer::init()  		// him/herself in the foot.  		LLNotificationsUtil::add("RunLauncher");  	} +#endif  #if LL_WINDOWS  	if (gGLManager.mGLVersion < LLFeatureManager::getInstance()->getExpectedGLVersion()) @@ -1470,7 +1473,7 @@ bool LLAppViewer::frame()  					LLAppViewer::getImageDecodeThread()->pause();  				}  			} -			 +		  			if (mRandomizeFramerate)  			{  				ms_sleep(rand() % 200); @@ -1641,6 +1644,8 @@ void LLAppViewer::flushVFSIO()  bool LLAppViewer::cleanup()  { +    LLAtmosphere::cleanupClass(); +  	//ditch LLVOAvatarSelf instance  	gAgentAvatarp = NULL; diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index f10c116555..042d7d971a 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -42,6 +42,7 @@  #include "llrender.h"  #include "llenvironment.h"  +#include "llatmosphere.h"  LLPointer<LLViewerTexture> LLDrawPoolWLSky::sCloudNoiseTexture = NULL; @@ -125,38 +126,51 @@ void LLDrawPoolWLSky::endDeferredPass(S32 pass)  void LLDrawPoolWLSky::renderDome(F32 camHeightLocal, LLGLSLShader * shader) const  { -	LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - -	llassert_always(NULL != shader); - -	gGL.pushMatrix(); - -	//chop off translation -	if (LLPipeline::sReflectionRender && origin.mV[2] > 256.f) -	{ -		gGL.translatef(origin.mV[0], origin.mV[1], 256.f-origin.mV[2]*0.5f); -	} -	else -	{ -		gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); -	} +    llassert_always(NULL != shader); + +    static LLStaticHashedString sCamPosLocal("camPosLocal"); + +    LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + +    if (gPipeline.useAdvancedAtmospherics()) +    { +        // Draw WL Sky	w/ normal cam pos (where you are) for adv atmo sky +        sky_shader->uniform3f(sCamPosLocal, origin.mV[0], origin.mV[1], origin.mV[2]); + +//  TBD replace this with a FS tri pass, there's little point to the tess when you have fragment shaders... + +        gSky.mVOWLSkyp->drawDome(); +    } +    else +    { +	    gGL.pushMatrix(); + +	    //chop off translation +	    if (LLPipeline::sReflectionRender && origin.mV[2] > 256.f) +	    { +		    gGL.translatef(origin.mV[0], origin.mV[1], 256.f-origin.mV[2]*0.5f); +	    } +	    else +	    { +		    gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); +	    } -	// the windlight sky dome works most conveniently in a coordinate system -	// where Y is up, so permute our basis vectors accordingly. -	gGL.rotatef(120.f, 1.f / F_SQRT3, 1.f / F_SQRT3, 1.f / F_SQRT3); +	    // the windlight sky dome works most conveniently in a coordinate system +	    // where Y is up, so permute our basis vectors accordingly. +	    gGL.rotatef(120.f, 1.f / F_SQRT3, 1.f / F_SQRT3, 1.f / F_SQRT3); -	gGL.scalef(0.333f, 0.333f, 0.333f); +	    gGL.scalef(0.333f, 0.333f, 0.333f); -	gGL.translatef(0.f,-camHeightLocal, 0.f); +	    gGL.translatef(0.f,-camHeightLocal, 0.f); -	// Draw WL Sky	 -	static LLStaticHashedString sCamPosLocal("camPosLocal"); -	shader->uniform3f(sCamPosLocal, 0.f, camHeightLocal, 0.f); +	    // Draw WL Sky +	    shader->uniform3f(sCamPosLocal, 0.f, camHeightLocal, 0.f); -	gSky.mVOWLSkyp->drawDome(); +        gSky.mVOWLSkyp->drawDome(); -	gGL.popMatrix(); +	    gGL.popMatrix(); +    }  }  void LLDrawPoolWLSky::renderSkyHaze(F32 camHeightLocal) const @@ -167,6 +181,33 @@ void LLDrawPoolWLSky::renderSkyHaze(F32 camHeightLocal) const  		sky_shader->bind(); +        if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders() && gAtmosphere) +        { +            // bind precomputed textures necessary for calculating sun and sky luminance +            sky_shader->bindTexture(LLShaderMgr::TRANSMITTANCE_TEX, gAtmosphere->getTransmittance()); +            sky_shader->bindTexture(LLShaderMgr::SCATTER_TEX, gAtmosphere->getScattering()); +            sky_shader->bindTexture(LLShaderMgr::SINGLE_MIE_SCATTER_TEX, gAtmosphere->getSingleMieScattering()); + +            static float sunSize = (float)cos(0.0005); + +            sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); + +            static LLVector3 solDir(0.7f, 0.2f, 0.2f); + +            //neither of these appear to track with the env settings, would the real sun please stand up. +            //sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, gPipeline.mTransformedSunDir.mV); +            //sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, gSky.mVOSkyp->getSun().getDirection().mV); +            solDir.normalize(); + +            sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, solDir.mV); + +            // clouds are rendered along with sky in adv atmo +            if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && sCloudNoiseTexture.notNull()) +            { +                sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, sCloudNoiseTexture); +            } +        } +  		/// Render the skydome  		renderDome(camHeightLocal, sky_shader);	 @@ -190,8 +231,9 @@ void LLDrawPoolWLSky::renderStars(void) const  	// *NOTE: we divide by two here and GL_ALPHA_SCALE by two below to avoid  	// clamping and allow the star_alpha param to brighten the stars.  	LLColor4 star_alpha(LLColor4::black); +      // *LAPRAS -    star_alpha.mV[3] = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / 2.f; +    star_alpha.mV[3] = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / (2.f + ((rand() >> 16)/65535.0f)); // twinkle twinkle  	// If start_brightness is not set, exit  	if( star_alpha.mV[3] < 0.001 ) @@ -322,8 +364,10 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)  	renderSkyHaze(camHeightLocal); -	LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); -	gGL.pushMatrix(); +    if (!gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders()) +    { +	    LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); +	    gGL.pushMatrix();  		gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); @@ -340,13 +384,12 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)  		gDeferredStarProgram.unbind(); -	gGL.popMatrix(); +	    gGL.popMatrix(); +    }  	renderSkyClouds(camHeightLocal); - -	gGL.setColorMask(true, true); -	//gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - +     +    gGL.setColorMask(true, true);  }  void LLDrawPoolWLSky::render(S32 pass) @@ -367,8 +410,10 @@ void LLDrawPoolWLSky::render(S32 pass)  	renderSkyHaze(camHeightLocal); -	LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); -	gGL.pushMatrix(); +    if (!gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders()) +    { +	    LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); +	    gGL.pushMatrix();  		gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); @@ -380,9 +425,9 @@ void LLDrawPoolWLSky::render(S32 pass)  		renderHeavenlyBodies();  		renderStars(); -		 -	gGL.popMatrix(); +	    gGL.popMatrix(); +    }  	renderSkyClouds(camHeightLocal); diff --git a/indra/newview/lldrawpoolwlsky.h b/indra/newview/lldrawpoolwlsky.h index cd15c991ee..586219e4bc 100644 --- a/indra/newview/lldrawpoolwlsky.h +++ b/indra/newview/lldrawpoolwlsky.h @@ -39,6 +39,8 @@ public:  	static const U32 STAR_VERTEX_DATA_MASK =	LLVertexBuffer::MAP_VERTEX |  		LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXCOORD0; +    static const U32 ADV_ATMO_SKY_VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX; +  	LLDrawPoolWLSky(void);  	/*virtual*/ ~LLDrawPoolWLSky(); diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index df708013fc..6e89763ba2 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2507,7 +2507,7 @@ void LLMeshUploadThread::requestWholeModelFee()  		{  			ms_sleep(sleep_time);  			sleep_time = llmin(250U, sleep_time + sleep_time); -			mHttpRequest->update(0); +		    mHttpRequest->update(0);  		}  		if (isDiscarded())  		{ diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index e40d3da338..bec05fa263 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -44,6 +44,7 @@  #include "lljoint.h"  #include "llskinningutil.h"  #include "llenvironment.h" +#include "llatmosphere.h"  #ifdef LL_RELEASE_FOR_DOWNLOAD  #define UNIFORM_ERRS LL_WARNS_ONCE("Shader") @@ -92,6 +93,8 @@ LLGLSLShader	gDebugProgram;  LLGLSLShader	gClipProgram;  LLGLSLShader	gDownsampleDepthProgram;  LLGLSLShader	gDownsampleDepthRectProgram; +LLGLSLShader	gDownsampleMinMaxDepthRectProgram; +LLGLSLShader	gInscatterRectProgram;  LLGLSLShader	gAlphaMaskProgram;  LLGLSLShader	gBenchmarkProgram; @@ -474,7 +477,7 @@ void LLViewerShaderMgr::setShaders()  		S32 env_class = 2;  		S32 obj_class = 2;  		S32 effect_class = 2; -		S32 wl_class = 2; +		S32 wl_class = 3;  		S32 water_class = 2;  		S32 deferred_class = 0;  		S32 transform_class = gGLManager.mHasTransformFeedback ? 1 : 0; @@ -498,14 +501,13 @@ void LLViewerShaderMgr::setShaders()  			{ //no shadows  				deferred_class = 1;  			} - -			//make sure hardware skinning is enabled -			//gSavedSettings.setBOOL("RenderAvatarVP", TRUE); -			 -			//make sure atmospheric shaders are enabled -			//gSavedSettings.setBOOL("WindLightUseAtmosShaders", TRUE);  		} +        // clamp to WL class 2 if we have disabled adv atmo (class 3) +        if (!gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics")) +        { +            wl_class = llmin(wl_class, 2); +        }  		if (!(LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")  			  && gSavedSettings.getBOOL("WindLightUseAtmosShaders"))) @@ -515,7 +517,6 @@ void LLViewerShaderMgr::setShaders()  			wl_class = 1;  		} -		  		// Trigger a full rebuild of the fallback skybox / cubemap if we've toggled windlight shaders  		if (mVertexShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull())  		{ @@ -543,6 +544,7 @@ void LLViewerShaderMgr::setShaders()  			// Load all shaders to set max levels  			loaded = loadShadersEnvironment(); +			llassert(loaded);  			if (loaded)  			{ @@ -579,14 +581,10 @@ void LLViewerShaderMgr::setShaders()  				if (gSavedSettings.getBOOL("RenderAvatarVP") && loadShadersObject())  				{ //hardware skinning is enabled and rigged attachment shaders loaded correctly  					BOOL avatar_cloth = gSavedSettings.getBOOL("RenderAvatarCloth"); -					S32 avatar_class = 1; -				 -					// cloth is a class3 shader -					if(avatar_cloth) -					{ -						avatar_class = 3; -					} +					// cloth is a class3 shader +					S32 avatar_class = avatar_cloth ? 3 : 1; +				  					// Set the actual level  					mVertexShaderLevel[SHADER_AVATAR] = avatar_class;  					loadShadersAvatar(); @@ -699,6 +697,8 @@ void LLViewerShaderMgr::unloadShaders()  	gClipProgram.unload();  	gDownsampleDepthProgram.unload();  	gDownsampleDepthRectProgram.unload(); +	gDownsampleMinMaxDepthRectProgram.unload(); +    gInscatterRectProgram.unload();  	gBenchmarkProgram.unload();  	gAlphaMaskProgram.unload();  	gUIProgram.unload(); @@ -1954,15 +1954,19 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()  	{  		gDeferredWLSkyProgram.mName = "Deferred Windlight Sky Shader";  		//gWLSkyProgram.mFeatures.hasGamma = true; -		gDeferredWLSkyProgram.mShaderFiles.clear(); +        gDeferredWLSkyProgram.mShaderFiles.clear();  		gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyV.glsl", GL_VERTEX_SHADER_ARB));  		gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); -		gDeferredWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; +        gDeferredWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT];  		gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; +        if (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3) +        { +            gDeferredWLSkyProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); +        }  		success = gDeferredWLSkyProgram.createShader(NULL, NULL);  	} -	if (success) +    if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3))  	{  		gDeferredWLCloudProgram.mName = "Deferred Windlight Cloud Program";  		gDeferredWLCloudProgram.mShaderFiles.clear(); @@ -3267,16 +3271,6 @@ BOOL LLViewerShaderMgr::loadShadersInterface()  	if (success)  	{ -		gDownsampleDepthRectProgram.mName = "DownsampleDepthRect Shader"; -		gDownsampleDepthRectProgram.mShaderFiles.clear(); -		gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthV.glsl", GL_VERTEX_SHADER_ARB)); -		gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthRectF.glsl", GL_FRAGMENT_SHADER_ARB)); -		gDownsampleDepthRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; -		success = gDownsampleDepthRectProgram.createShader(NULL, NULL); -	} - -	if (success) -	{  		gAlphaMaskProgram.mName = "Alpha Mask Shader";  		gAlphaMaskProgram.mShaderFiles.clear();  		gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskV.glsl", GL_VERTEX_SHADER_ARB)); @@ -3302,9 +3296,43 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()  	{  		gWLSkyProgram.unload();  		gWLCloudProgram.unload(); +		gDownsampleMinMaxDepthRectProgram.unload(); +        gInscatterRectProgram.unload();  		return TRUE;  	} +    if (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3) +    { +        // Prepare precomputed atmospherics textures using libatmosphere +        LLAtmosphere::initClass(); +    } + +	// this shader uses gather so it can't live with the other basic shaders safely +	if (success) +	{ +		gDownsampleMinMaxDepthRectProgram.mName = "DownsampleMinMaxDepthRect Shader"; +		gDownsampleMinMaxDepthRectProgram.mShaderFiles.clear(); +		gDownsampleMinMaxDepthRectProgram.mShaderFiles.push_back(make_pair("windlight/downsampleMinMaxDepthV.glsl", GL_VERTEX_SHADER_ARB)); +		gDownsampleMinMaxDepthRectProgram.mShaderFiles.push_back(make_pair("windlight/downsampleMinMaxDepthRectF.glsl", GL_FRAGMENT_SHADER_ARB)); +		gDownsampleMinMaxDepthRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; +		success = gDownsampleMinMaxDepthRectProgram.createShader(NULL, NULL); +	} + +    // this shader uses gather so it can't live with the other basic shaders safely +    if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3)) +    { +        gInscatterRectProgram.mName = "Inscatter Shader"; +        gInscatterRectProgram.mShaderFiles.clear(); +        gInscatterRectProgram.mShaderFiles.push_back(make_pair("windlight/atmoV.glsl", GL_VERTEX_SHADER_ARB)); +        gInscatterRectProgram.mShaderFiles.push_back(make_pair("windlight/atmoF.glsl", GL_FRAGMENT_SHADER_ARB)); +        gInscatterRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT];        +        llassert(gAtmosphere != nullptr); +        gInscatterRectProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); +        success = gInscatterRectProgram.createShader(NULL, NULL); +    } + +    llassert(success); +  	if (success)  	{  		gWLSkyProgram.mName = "Windlight Sky Shader"; @@ -3314,10 +3342,16 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()  		gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyF.glsl", GL_FRAGMENT_SHADER_ARB));  		gWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT];  		gWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; +        if (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3) +        { +            gWLSkyProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); +        }  		success = gWLSkyProgram.createShader(NULL, NULL);  	} -	if (success) +    llassert(success); + +    if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3))  	{  		gWLCloudProgram.mName = "Windlight Cloud Program";  		//gWLCloudProgram.mFeatures.hasGamma = true; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 923aa522ad..10c60187f3 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -184,6 +184,8 @@ extern LLGLSLShader			gDebugProgram;  extern LLGLSLShader			gClipProgram;  extern LLGLSLShader			gDownsampleDepthProgram;  extern LLGLSLShader			gDownsampleDepthRectProgram; +extern LLGLSLShader			gDownsampleMinMaxDepthRectProgram; +extern LLGLSLShader			gInscatterRectProgram;  extern LLGLSLShader			gBenchmarkProgram;  //output tex0[tc0] + tex1[tc1] diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index e5a1bed48c..cbde0af9b3 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1176,12 +1176,12 @@ void LLViewerFetchedTexture::loadFromFastCache()  	{  		return; //no need to access the fast cache.  	} -	mInFastCacheList = FALSE; +    mInFastCacheList = FALSE;  	mRawImage = LLAppViewer::getTextureCache()->readFromFastCache(getID(), mRawDiscardLevel);  	if(mRawImage.notNull())  	{ -		mFullWidth = mRawImage->getWidth() << mRawDiscardLevel; +		mFullWidth  = mRawImage->getWidth()  << mRawDiscardLevel;  		mFullHeight = mRawImage->getHeight() << mRawDiscardLevel;  		setTexelsPerImage(); @@ -1196,20 +1196,20 @@ void LLViewerFetchedTexture::loadFromFastCache()  		else  		{              if (mBoostLevel == LLGLTexture::BOOST_ICON) +        { +            S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS; +            S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS; +            if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height))              { -                S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS; -                S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS; -                if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)) -                { -                    // scale oversized icon, no need to give more work to gl -                    mRawImage->scale(expected_width, expected_height); -                } +                // scale oversized icon, no need to give more work to gl +                mRawImage->scale(expected_width, expected_height); +            }              } -			mRequestedDiscardLevel = mDesiredDiscardLevel + 1; -			mIsRawImageValid = TRUE;			 -			addToCreateTexture(); -		} +		mRequestedDiscardLevel = mDesiredDiscardLevel + 1; +		mIsRawImageValid = TRUE;			 +		addToCreateTexture(); +	}  	}  } @@ -1965,7 +1965,7 @@ bool LLViewerFetchedTexture::updateFetch()  				mIsFetched = TRUE;  				tester->updateTextureLoadingStats(this, mRawImage, LLAppViewer::getTextureFetch()->isFromLocalCache(mID));  			} -			mRawDiscardLevel = fetch_discard; +            mRawDiscardLevel = fetch_discard;  			if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) &&  				(current_discard < 0 || mRawDiscardLevel < current_discard))  			{ diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index c9dea17f63..5bc274ee5b 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -225,8 +225,8 @@ public:  	static S8  sCameraMovingDiscardBias;  	static F32 sCameraMovingBias;  	static S32 sMaxSculptRez ; -	static S32 sMinLargeImageSize ; -	static S32 sMaxSmallImageSize ; +	static U32 sMinLargeImageSize ; +	static U32 sMaxSmallImageSize ;  	static BOOL sFreezeImageScalingDown ;//do not scale down image res if set.  	static F32  sCurrentTime ; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0ac1bfa3e7..849273df15 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -381,6 +381,7 @@ bool	LLPipeline::sRenderBump = true;  bool	LLPipeline::sBakeSunlight = false;  bool	LLPipeline::sNoAlpha = false;  bool	LLPipeline::sUseTriStrips = true; +bool	LLPipeline::sUseAdvancedAtmospherics = true;  bool	LLPipeline::sUseFarClip = true;  bool	LLPipeline::sShadowRender = false;  bool	LLPipeline::sWaterReflections = false; @@ -480,6 +481,7 @@ void LLPipeline::init()  	sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");  	sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");  	sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips"); +	sUseAdvancedAtmospherics = gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics");  	LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO");  	LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO");  	LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); @@ -981,7 +983,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)  			for (U32 i = 0; i < 4; i++)  			{  				if (!mShadow[i].allocate(sun_shadow_map_width,U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false; -				if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false; +				if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false;                  			}  		}  		else @@ -993,6 +995,13 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)  			}  		} +// for EEP atmospherics +		bool allocated_inscatter = mInscatter.allocate(resX >> 2, resY >> 2, GL_RGBA16F_ARB, FALSE, FALSE, LLTexUnit::TT_TEXTURE); +        	if (!allocated_inscatter) +        	{ +        	    return false; +        	} +  		U32 width = (U32) (resX*scale);  		U32 height = width; @@ -1229,6 +1238,8 @@ void LLPipeline::releaseScreenBuffers()  		mShadow[i].release();  		mShadowOcclusion[i].release();  	} + +	mInscatter.release();  } @@ -2646,6 +2657,65 @@ void LLPipeline::markOccluder(LLSpatialGroup* group)  	}  } +void LLPipeline::downsampleMinMaxDepthBuffer(LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space) +{ +	LLGLSLShader* last_shader = LLGLSLShader::sCurBoundShaderPtr; + +	LLGLSLShader* shader = NULL; + +	if (scratch_space) +	{ +		scratch_space->copyContents(source, +			0, 0, source.getWidth(), source.getHeight(), +			0, 0, scratch_space->getWidth(), scratch_space->getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); +	} + +	dest.bindTarget(); +	dest.clear(GL_COLOR_BUFFER_BIT); // dest should be an RG16F target + +	LLStrider<LLVector3> vert; +	mDeferredVB->getVertexStrider(vert); +	LLStrider<LLVector2> tc0; + +	vert[0].set(-1, 1, 0); +	vert[1].set(-1, -3, 0); +	vert[2].set(3, 1, 0); + +	if (source.getUsage() == LLTexUnit::TT_RECT_TEXTURE) +	{ +		shader = &gDownsampleMinMaxDepthRectProgram; +		shader->bind(); +		shader->uniform2f(sDelta, 1.f, 1.f); +		shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, source.getWidth(), source.getHeight()); +	} +	else +	{ +		shader = &gDownsampleMinMaxDepthRectProgram; +		shader->bind(); +		shader->uniform2f(sDelta, 1.f / source.getWidth(), 1.f / source.getHeight()); +		shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, 1.f, 1.f); +	} + +	gGL.getTexUnit(0)->bind(scratch_space ? scratch_space : &source, TRUE); + +	{ +		LLGLDepthTest depth(GL_FALSE, GL_FALSE, GL_ALWAYS); +		mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); +		mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); +	} + +	dest.flush(); + +	if (last_shader) +	{ +		last_shader->bind(); +	} +	else +	{ +		shader->unbind(); +	} +} +  void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space)  {  	LLGLSLShader* last_shader = LLGLSLShader::sCurBoundShaderPtr; @@ -8282,6 +8352,21 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n  		}  	} +    channel = shader.enableTexture(LLShaderMgr::INSCATTER_RT, LLTexUnit::TT_TEXTURE); +    stop_glerror(); +    if (channel > -1) +    { +        stop_glerror(); +        gGL.getTexUnit(channel)->bind(&mInscatter, TRUE); +        gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); +        gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); +        stop_glerror(); + +        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); +        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_ALWAYS); +        stop_glerror(); +    } +  	stop_glerror();  	F32 mat[16*6]; @@ -9095,6 +9180,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)  					}  				} +// pretty sure this doesn't work as expected since the shaders using 'shadow_ofset' all declare it as a single uniform float, no array or vec  				gDeferredSunProgram.uniform3fv(LLShaderMgr::DEFERRED_SHADOW_OFFSET, slice, offset);  				gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight()); @@ -9911,9 +9997,9 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)  						}  						else  						{ -						renderGeom(camera); -					} -				}	 +						    renderGeom(camera); +					    } +				    }	  				}	  				if (LLPipeline::sRenderDeferred && materials_in_water) @@ -10412,23 +10498,25 @@ bool LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector  		for (U32 j = 0; j < 3; ++j)  		{ -			if (p[j] < ext[0].mV[j] || -				p[j] > ext[1].mV[j]) +			if (p[j] < ext[0].mV[j] || p[j] > ext[1].mV[j])  			{  				found = false;  				break;  			}  		} -				 -		for (U32 j = 0; j < LLCamera::AGENT_PLANE_NO_USER_CLIP_NUM; ++j) +		 +		if (found) // don't bother testing user clip planes if we're already rejected...  		{ -			const LLPlane& cp = camera.getAgentPlane(j); -			F32 dist = cp.dist(pp[i]); -			if (dist > 0.05f) //point is above some plane, not contained -			{ -				found = false; -				break; -			} +		    for (U32 j = 0; j < LLCamera::AGENT_PLANE_NO_USER_CLIP_NUM; ++j) +		    { +			    const LLPlane& cp = camera.getAgentPlane(j); +			    F32 dist = cp.dist(pp[i]); +			    if (dist > 0.05f) //point is above some plane, not contained +			    { +				    found = false; +				    break; +			    } +		    }  		}  		if (found) @@ -11959,3 +12047,7 @@ void LLPipeline::restoreHiddenObject( const LLUUID& id )  	}  } +bool LLPipeline::useAdvancedAtmospherics() const +{ +    return sUseAdvancedAtmospherics; +}
\ No newline at end of file diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index c9670a60f2..6023a41ca2 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -168,6 +168,9 @@ public:  	// if source's depth buffer cannot be bound for reading, a scratch space depth buffer must be provided  	void		downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space = NULL); +	// Downsample depth buffer with gather and find local min/max depth values. Writes to a 16F RG render target. +	void		downsampleMinMaxDepthBuffer(LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space = NULL); +  	void		doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space = NULL);  	void		doOcclusion(LLCamera& camera);  	void		markNotCulled(LLSpatialGroup* group, LLCamera &camera); @@ -541,6 +544,8 @@ public:  	void updateCamera(bool reset = false); +	bool useAdvancedAtmospherics() const; +  	LLVector3				mFlyCamPosition;  	LLQuaternion			mFlyCamRotation; @@ -568,6 +573,7 @@ public:  	static bool				sBakeSunlight;  	static bool				sNoAlpha;  	static bool				sUseTriStrips; +	static bool				sUseAdvancedAtmospherics;  	static bool				sUseFarClip;  	static bool				sShadowRender;  	static bool				sWaterReflections; @@ -614,12 +620,13 @@ public:  	//sun shadow map  	LLRenderTarget			mShadow[6];  	LLRenderTarget			mShadowOcclusion[6]; -	std::vector<LLVector3>	mShadowFrustPoints[4]; -	LLVector4				mShadowError; -	LLVector4				mShadowFOV; -	LLVector3				mShadowFrustOrigin[4]; -	LLCamera				mShadowCamera[8]; -	LLVector3				mShadowExtents[4][2]; +	LLRenderTarget			mInscatter; +	std::vector<LLVector3>		mShadowFrustPoints[4]; +	LLVector4			mShadowError; +	LLVector4			mShadowFOV; +	LLVector3			mShadowFrustOrigin[4]; +	LLCamera			mShadowCamera[8]; +	LLVector3			mShadowExtents[4][2];  	glh::matrix4f			mSunShadowMatrix[6];  	glh::matrix4f			mShadowModelview[6];  	glh::matrix4f			mShadowProjection[6]; | 
