SL-18762 Fix for broken local lights on alpha when wearing a HUD attachment. Also fix stuck sun/moon and incidental decruft.
parent
c87c1a1fa4
commit
68c4ff7dce
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue