diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 742922dd22a829cafabd1258ca28fc9466a66cd8..45ed8748501ad0aaf3b097588cbe3c68aeacaaa7 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -137,6 +137,7 @@ class LLLightParams final : public LLNetworkData { protected: LLColor4 mColor; // alpha = intensity + LLColor4 mSRGBColor; // Only used in deferred (for now?) F32 mRadius; F32 mFalloff; F32 mCutoff; @@ -153,13 +154,14 @@ public: operator LLSD() const { return asLLSD(); } bool fromLLSD(LLSD& sd); - - void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); } + + void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); mSRGBColor = srgbColor4(mColor); } void setRadius(F32 radius) { mRadius = llclamp(radius, LIGHT_MIN_RADIUS, LIGHT_MAX_RADIUS); } void setFalloff(F32 falloff) { mFalloff = llclamp(falloff, LIGHT_MIN_FALLOFF, LIGHT_MAX_FALLOFF); } void setCutoff(F32 cutoff) { mCutoff = llclamp(cutoff, LIGHT_MIN_CUTOFF, LIGHT_MAX_CUTOFF); } - LLColor4 getColor() const { return mColor; } + LLColor4 getColor() const { return mColor; } + LLColor4 getSRGBColor() const { return mSRGBColor; } F32 getRadius() const { return mRadius; } F32 getFalloff() const { return mFalloff; } F32 getCutoff() const { return mCutoff; } diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp index fd87740befe3cb209f258515191e54709e31b418..81c5bf21bc6f9a499031825bd3a6aad0ad9660a4 100644 --- a/indra/llrender/llcubemap.cpp +++ b/indra/llrender/llcubemap.cpp @@ -43,20 +43,13 @@ const F32 epsilon = 1e-7f; const U16 RESOLUTION = 64; -#if LL_DARWIN -// mipmap generation on cubemap textures seems to be broken on the Mac for at least some cards. -// Since the cubemap is small (64x64 per face) and doesn't have any fine detail, turning off mipmaps is a usable workaround. -const BOOL use_cube_mipmaps = FALSE; -#else -const BOOL use_cube_mipmaps = FALSE; //current build works best without cube mipmaps -#endif - bool LLCubeMap::sUseCubeMaps = true; -LLCubeMap::LLCubeMap() +LLCubeMap::LLCubeMap(bool init_as_srgb) : mTextureStage(0), mTextureCoordStage(0), - mMatrixStage(0) + mMatrixStage(0), + mIssRGB(init_as_srgb) { mTargets[0] = GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB; mTargets[1] = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB; @@ -81,9 +74,14 @@ void LLCubeMap::initGL() for (auto i = 0; i < 6; ++i) { - mImages[i] = new LLImageGL(64, 64, 4, (use_cube_mipmaps? TRUE : FALSE)); + mImages[i] = new LLImageGL(RESOLUTION, RESOLUTION, 4, FALSE); + #if USE_SRGB_DECODE + if (mIssRGB) { + mImages[i]->setExplicitFormat(GL_SRGB8_ALPHA8, GL_RGBA); + } + #endif mImages[i]->setTarget(mTargets[i], LLTexUnit::TT_CUBE_MAP); - mRawImages[i] = new LLImageRaw(64, 64, 4); + mRawImages[i] = new LLImageRaw(RESOLUTION, RESOLUTION, 4); mImages[i]->createGLTexture(0, mRawImages[i], texname); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, texname); @@ -150,7 +148,7 @@ void LLCubeMap::initGLData() { for (int i = 0; i < 6; i++) { - mImages[i]->setSubImage(mRawImages[i], 0, 0, 64, 64); + mImages[i]->setSubImage(mRawImages[i], 0, 0, RESOLUTION, RESOLUTION); } } @@ -480,7 +478,7 @@ void LLCubeMap::paintIn(LLVector3 dir[4], const LLColor4U& col) td[offset + cc] = U8((td[offset + cc] + col.mV[cc]) * 0.5); } } - mImages[side]->setSubImage(mRawImages[side], 0, 0, 64, 64); + mImages[side]->setSubImage(mRawImages[side], 0, 0, RESOLUTION, RESOLUTION); } } diff --git a/indra/llrender/llcubemap.h b/indra/llrender/llcubemap.h index 5e29fb62f5818821cc9ba566579c6f4a2272c319..fb0d9414b788978f7317180b9d09d33c715b5f5f 100644 --- a/indra/llrender/llcubemap.h +++ b/indra/llrender/llcubemap.h @@ -37,7 +37,7 @@ class LLVector3; class LLCubeMap : public LLRefCount { public: - LLCubeMap(); + LLCubeMap(bool init_as_srgb); void init(const std::vector<LLPointer<LLImageRaw> >& rawimages); void initGL(); void initRawData(const std::vector<LLPointer<LLImageRaw> >& rawimages); @@ -79,6 +79,7 @@ protected: S32 mTextureStage; S32 mTextureCoordStage; S32 mMatrixStage; + bool mIssRGB; }; #endif diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index f27d2a3e3575f2ab055204af8e6667afb5f8bc9b..dc473a9436d850c78224b66ce2d3e5d950d117df 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -299,7 +299,8 @@ void LLSkyTex::createGLImage(S32 which) void LLSkyTex::bindTexture(BOOL curr) { - gGL.getTexUnit(0)->bind(mTexture[getWhich(curr)], true); + int tex = getWhich(curr); + gGL.getTexUnit(0)->bind(mTexture[tex], true); } /*************************************** @@ -440,15 +441,17 @@ void LLVOSky::initCubeMap() { images.emplace_back(side.getImageRaw()); } - if (mCubeMap) + + if (!mCubeMap && gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) { - mCubeMap->init(images); + mCubeMap = new LLCubeMap(false); } - else if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) + + if (mCubeMap) { - mCubeMap = new LLCubeMap(); mCubeMap->init(images); } + gGL.getTexUnit(0)->disable(); } @@ -1853,9 +1856,8 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, F32 dt_tex = dtReflection(P, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); - dt = dt_tex; - TEX0tt = LLVector2(0, dt); - TEX1tt = LLVector2(1, dt); + TEX0tt = LLVector2(0, dt_tex); + TEX1tt = LLVector2(1, dt_tex); quads++; } else diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 314f32fcbc9fbe4fca1acd99f4104872827c4f50..f253dc8033044d652894f73c1debaf25f0784ba5 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3303,6 +3303,19 @@ LLColor3 LLVOVolume::getLightColor() const } } +LLColor3 LLVOVolume::getLightSRGBColor() const +{ + const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); + if (param_block) + { + return LLColor3(param_block->getSRGBColor()) * param_block->getSRGBColor().mV[3]; + } + else + { + return LLColor3(1, 1, 1); + } +} + LLUUID LLVOVolume::getLightTextureID() const { if (getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE)) diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 80101138302dfb369dbe0dfa2c22de3359ef5ec3..00566ced070967f4cc613747b0e56c81f86c2d68 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -255,6 +255,7 @@ public: BOOL getIsLight() const; LLColor3 getLightBaseColor() const; // not scaled by intensity LLColor3 getLightColor() const; // scaled by intensity + LLColor3 getLightSRGBColor() const; // Used to get the (cached) light color in sRGB color space. Also scaled by intensity. LLUUID getLightTextureID() const; bool isLightSpotlight() const; LLVector3 getSpotLightParams() const;