diff options
| author | Dave Parks <davep@lindenlab.com> | 2023-02-14 10:10:12 -0600 | 
|---|---|---|
| committer | Dave Parks <davep@lindenlab.com> | 2023-02-14 10:10:12 -0600 | 
| commit | 68c4ff7dce2bd519431238f6209238aba46dc0ba (patch) | |
| tree | 8b4135011990ebf30aa29dc511c47bdaa2d2c92d | |
| parent | c87c1a1fa433904a4e77b6993827f344805d77a1 (diff) | |
SL-18762 Fix for broken local lights on alpha when wearing a HUD attachment.  Also fix stuck sun/moon and incidental decruft.
| -rw-r--r-- | indra/llrender/llshadermgr.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/moonV.glsl | 6 | ||||
| -rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl | 20 | ||||
| -rw-r--r-- | indra/newview/lldrawpoolwlsky.cpp | 5 | ||||
| -rw-r--r-- | indra/newview/llviewershadermgr.cpp | 3 | ||||
| -rw-r--r-- | indra/newview/pipeline.cpp | 40 | ||||
| -rw-r--r-- | indra/newview/pipeline.h | 2 | 
7 files changed, 50 insertions, 27 deletions
| diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 7a7c5beb38..6cada320fa 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -679,7 +679,6 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev  		extra_code_text[extra_code_count++] = strdup("#define texture2D texture\n");  		extra_code_text[extra_code_count++] = strdup("#define textureCube texture\n");  		extra_code_text[extra_code_count++] = strdup("#define texture2DLod textureLod\n"); -		extra_code_text[extra_code_count++] = strdup("#define shadow2D(a,b) vec2(texture(a,b))\n");  		if (major_version > 1 || minor_version >= 40)  		{ //GLSL 1.40 replaces texture2DRect et al with texture diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl index 7b9aa0a4dc..032245a01c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl @@ -27,10 +27,10 @@ uniform mat4 texture_matrix0;  uniform mat4 modelview_matrix;  uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; +in vec3 position; +in vec2 texcoord0; -VARYING vec2 vary_texcoord0; +out vec2 vary_texcoord0;  void main()  { diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index cd49202f89..fffbdb913e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -59,12 +59,12 @@ float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul,      stc.xyz /= stc.w;      stc.z += offset * 2.0;      stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here -    float cs = shadow2D(shadowMap, stc.xyz).x; +    float cs = texture(shadowMap, stc.xyz).x;      float shadow = cs * 4.0; -    shadow += shadow2D(shadowMap, stc.xyz+vec3( 1.5/shadow_res.x,  0.5/shadow_res.y, 0.0)).x; -    shadow += shadow2D(shadowMap, stc.xyz+vec3( 0.5/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; -    shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.5/shadow_res.x, -0.5/shadow_res.y, 0.0)).x; -    shadow += shadow2D(shadowMap, stc.xyz+vec3(-0.5/shadow_res.x,  1.5/shadow_res.y, 0.0)).x; +    shadow += texture(shadowMap, stc.xyz+vec3( 1.5/shadow_res.x,  0.5/shadow_res.y, 0.0)).x; +    shadow += texture(shadowMap, stc.xyz+vec3( 0.5/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; +    shadow += texture(shadowMap, stc.xyz+vec3(-1.5/shadow_res.x, -0.5/shadow_res.y, 0.0)).x; +    shadow += texture(shadowMap, stc.xyz+vec3(-0.5/shadow_res.x,  1.5/shadow_res.y, 0.0)).x;      return clamp(shadow * 0.125, 0.0, 1.0);  #else      return 1.0; @@ -78,16 +78,16 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2      stc.z += spot_shadow_bias * bias_scale;      stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap -    float cs = shadow2D(shadowMap, stc.xyz).x; +    float cs = texture(shadowMap, stc.xyz).x;      float shadow = cs;      vec2 off = 1.0/proj_shadow_res;      off.y *= 1.5; -    shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x*2.0, off.y, 0.0)).x; -    shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x; -    shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x; -    shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x*2.0, -off.y, 0.0)).x; +    shadow += texture(shadowMap, stc.xyz+vec3(off.x*2.0, off.y, 0.0)).x; +    shadow += texture(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x; +    shadow += texture(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x; +    shadow += texture(shadowMap, stc.xyz+vec3(-off.x*2.0, -off.y, 0.0)).x;      return shadow*0.2;  #else      return 1.0; diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 8023435eba..59ed62f995 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -416,11 +416,14 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()  void LLDrawPoolWLSky::renderDeferred(S32 pass)  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY); -	if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) +	if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY) || gSky.mVOSkyp.isNull())  	{  		return;  	} +    // TODO: remove gSky.mVOSkyp and fold sun/moon into LLVOWLSky +    gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable); +      const F32 camHeightLocal = LLEnvironment::instance().getCamHeight();  	gGL.setColorMask(true, false); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 2775a98869..5d3da55499 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1633,8 +1633,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()          gDeferredSunProgram.mFeatures.hasShadows    = true;          gDeferredSunProgram.mFeatures.hasAmbientOcclusion = use_ao; -        gDeferredSunProgram.mName = "Deferred Sun Shader"; -		gDeferredSunProgram.mShaderFiles.clear(); +        gDeferredSunProgram.mShaderFiles.clear();  		gDeferredSunProgram.mShaderFiles.push_back(make_pair(vertex, GL_VERTEX_SHADER));  		gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER));  		gDeferredSunProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f911aea9cd..388dee00db 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2272,7 +2272,6 @@ bool LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3&  	}  	LLViewerCamera::sCurCameraID = saved_camera_id; -  	return res;  } @@ -3956,7 +3955,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion)      bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; -    setupHWLights(nullptr); +    setupHWLights();  	{  		LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("deferred pools"); @@ -4083,7 +4082,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)  	LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0);  	calcNearbyLights(camera); -	setupHWLights(NULL); +	setupHWLights();      gGL.setSceneBlendType(LLRender::BT_ALPHA);  	gGL.setColorMask(true, false); @@ -5452,7 +5451,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera)      LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;  	assertInitialized(); -	if (LLPipeline::sReflectionRender || gCubeSnapshot) +	if (LLPipeline::sReflectionRender || gCubeSnapshot || LLPipeline::sRenderingHUDs)  	{  		return;  	} @@ -5633,11 +5632,16 @@ void LLPipeline::calcNearbyLights(LLCamera& camera)  	}  } -void LLPipeline::setupHWLights(LLDrawPool* pool) +void LLPipeline::setupHWLights()  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;  	assertInitialized(); +    if (LLPipeline::sRenderingHUDs) +    { +        return; +    } +      LLEnvironment& environment = LLEnvironment::instance();      LLSettingsSky::ptr_t psky = environment.getCurrentSky(); @@ -8029,7 +8033,7 @@ void LLPipeline::renderDeferredLighting()          glh::matrix4f mat = copy_matrix(gGLModelView); -        setupHWLights(NULL);  // to set mSun/MoonDir; +        setupHWLights();  // to set mSun/MoonDir;          glh::vec4f tc(mSunDir.mV);          mat.mult_matrix_vec(tc); @@ -9236,6 +9240,24 @@ LLRenderTarget* LLPipeline::getSpotShadowTarget(U32 i)  static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow");  static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW_SPOT_RENDER("Spot Shadow Render"); +// helper class for disabling occlusion culling for the current stack frame +class LLDisableOcclusionCulling +{ +public: +    S32 mUseOcclusion; + +    LLDisableOcclusionCulling() +    { +        mUseOcclusion = LLPipeline::sUseOcclusion; +        LLPipeline::sUseOcclusion = 0; +    } + +    ~LLDisableOcclusionCulling() +    { +        LLPipeline::sUseOcclusion = mUseOcclusion; +    } +}; +  void LLPipeline::generateSunShadow(LLCamera& camera)  {  	if (!sRenderDeferred || RenderShadowDetail <= 0) @@ -9246,6 +9268,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)  	LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW);      LL_PROFILE_GPU_ZONE("generateSunShadow"); +    LLDisableOcclusionCulling no_occlusion; +  	bool skip_avatar_update = false;  	if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson)  	{ @@ -9479,7 +9503,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)  	F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] };  	if (mSunDiffuse == LLColor4::black) -	{ //sun diffuse is totally shadows don't matter +	{ //sun diffuse is totally black shadows don't matter  		LLGLDepthTest depth(GL_TRUE);  		for (S32 j = 0; j < 4; j++) @@ -9989,8 +10013,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera)                  LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); -                stop_glerror(); -                  //                  mSpotShadow[i].bindTarget(); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 282f28e736..85878dd21d 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -327,7 +327,7 @@ public:  	S32  getLightCount() const { return mLights.size(); }  	void calcNearbyLights(LLCamera& camera); -	void setupHWLights(LLDrawPool* pool); +	void setupHWLights();  	void setupAvatarLights(bool for_edit = false);  	void enableLights(U32 mask);  	void enableLightsStatic(); | 
