void LLWLParamManager::propagateParameters(void) { LLFastTimer ftm(FTM_UPDATE_WLPARAM); LLVector4 sunDir; LLVector4 moonDir; // set the sun direction from SunAngle and EastAngle F32 sinTheta = sin(mCurParams.getEastAngle()); F32 cosTheta = cos(mCurParams.getEastAngle()); F32 sinPhi = sin(mCurParams.getSunAngle()); F32 cosPhi = cos(mCurParams.getSunAngle()); sunDir.mV[0] = -sinTheta * cosPhi; sunDir.mV[1] = sinPhi; sunDir.mV[2] = cosTheta * cosPhi; sunDir.mV[3] = 0; moonDir = -sunDir; // is the normal from the sun or the moon if(sunDir.mV[1] >= 0) { mLightDir = sunDir; } else if(sunDir.mV[1] < 0 && sunDir.mV[1] > LLSky::NIGHTTIME_ELEVATION_COS) { // clamp v1 to 0 so sun never points up and causes weirdness on some machines LLVector3 vec(sunDir.mV[0], sunDir.mV[1], sunDir.mV[2]); vec.mV[1] = 0; vec.normVec(); mLightDir = LLVector4(vec, 0.f); } else { mLightDir = moonDir; } // calculate the clamp lightnorm for sky (to prevent ugly banding in sky // when haze goes below the horizon mClampedLightDir = sunDir; if (mClampedLightDir.mV[1] < -0.1f) { mClampedLightDir.mV[1] = -0.1f; } mCurParams.set("lightnorm", mLightDir); // bind the variables for all shaders only if we're using WindLight std::vector<LLGLSLShader*>::iterator shaders_iter=mShaderList.begin(); for(; shaders_iter != mShaderList.end(); ++shaders_iter) { (*shaders_iter)->mUniformsDirty = TRUE; } // get the cfr version of the sun's direction LLVector3 cfrSunDir(sunDir.mV[2], sunDir.mV[0], sunDir.mV[1]); // set direction and don't allow overriding gSky.setSunDirection(cfrSunDir, LLVector3(0,0,0)); gSky.setOverrideSun(TRUE); }
void LLWLParamManager::propagateParameters(void) { LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); LLVector4 sunDir; LLVector4 moonDir; // set the sun direction from SunAngle and EastAngle F32 sinTheta = sin(mCurParams.getEastAngle()); F32 cosTheta = cos(mCurParams.getEastAngle()); F32 sinPhi = sin(mCurParams.getSunAngle()); F32 cosPhi = cos(mCurParams.getSunAngle()); sunDir.mV[0] = -sinTheta * cosPhi; sunDir.mV[1] = sinPhi; sunDir.mV[2] = cosTheta * cosPhi; sunDir.mV[3] = 0; moonDir = -sunDir; // is the normal from the sun or the moon if(sunDir.mV[1] >= 0) { mLightDir = sunDir; } else if(sunDir.mV[1] < 0 && sunDir.mV[1] > NIGHTTIME_ELEVATION_COS) { // clamp v1 to 0 so sun never points up and causes weirdness on some machines LLVector3 vec(sunDir.mV[0], sunDir.mV[1], sunDir.mV[2]); vec.mV[1] = 0; vec.normVec(); mLightDir = LLVector4(vec, 0.f); } else { mLightDir = moonDir; } // calculate the clamp lightnorm for sky (to prevent ugly banding in sky // when haze goes below the horizon mClampedLightDir = sunDir; if (mClampedLightDir.mV[1] < -0.1f) { mClampedLightDir.mV[1] = -0.1f; } mCurParams.set("lightnorm", mLightDir); // bind the variables for all shaders only if we're using WindLight LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; end_shaders = LLViewerShaderMgr::instance()->endShaders(); for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) { if (shaders_iter->mProgramObject != 0 && (gPipeline.canUseWindLightShaders() || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) { shaders_iter->mUniformsDirty = TRUE; } } // get the cfr version of the sun's direction LLVector3 cfrSunDir(sunDir.mV[2], sunDir.mV[0], sunDir.mV[1]); // set direction and don't allow overriding gSky.setSunDirection(cfrSunDir, LLVector3(0,0,0)); gSky.setOverrideSun(TRUE); }