Tweaked naming a bit, also white space.

Will wait for a response from @graham_linden regarding moving the sRGB conversion functions in llmath.h to llrender.
meow-7.2.2
Geenz 2019-03-29 11:57:45 -07:00
parent f3ea75cfa9
commit 0272c47e5a
12 changed files with 149 additions and 152 deletions

View File

@ -540,21 +540,21 @@ inline void ll_remove_outliers(std::vector<VEC_TYPE>& data, F32 k)
// This converts from a non-linear sRGB floating point value (0..1) to a linear value.
// Useful for gamma correction and such. Note: any values passed through this should not be serialized. You should also ideally cache the output of this.
inline float sRGBtoLinear(const float val) {
if (val < 0.0031308f) {
return val * 12.92f;
}
else {
return 1.055f * pow(val, 1.0f / 2.4f) - 0.055f;
}
if (val < 0.0031308f) {
return val * 12.92f;
}
else {
return 1.055f * pow(val, 1.0f / 2.4f) - 0.055f;
}
}
inline float linearTosRGB(const float val) {
if (val < 0.04045f) {
return val / 12.92f;
}
else {
return pow((val + 0.055f) / 1.055f, 2.4f);
}
if (val < 0.04045f) {
return val / 12.92f;
}
else {
return pow((val + 0.055f) / 1.055f, 2.4f);
}
}
// Include simd math header

View File

@ -657,14 +657,14 @@ void LLColor4::clamp()
}
inline const LLColor4 srgbColor4(const LLColor4 &a) {
LLColor4 srgbColor;
LLColor4 srgbColor;
srgbColor.mV[0] = linearTosRGB(a.mV[0]);
srgbColor.mV[1] = linearTosRGB(a.mV[1]);
srgbColor.mV[2] = linearTosRGB(a.mV[2]);
srgbColor.mV[3] = a.mV[3];
srgbColor.mV[0] = linearTosRGB(a.mV[0]);
srgbColor.mV[1] = linearTosRGB(a.mV[1]);
srgbColor.mV[2] = linearTosRGB(a.mV[2]);
srgbColor.mV[3] = a.mV[3];
return srgbColor;
return srgbColor;
}
#endif

View File

@ -536,14 +536,14 @@ inline F32 LLVector4::normVec(void)
// Because apparently some parts of the viewer use this for color info.
inline const LLVector4 srgbVector4(const LLVector4 &a) {
LLVector4 srgbColor;
LLVector4 srgbColor;
srgbColor.mV[0] = linearTosRGB(a.mV[0]);
srgbColor.mV[1] = linearTosRGB(a.mV[1]);
srgbColor.mV[2] = linearTosRGB(a.mV[2]);
srgbColor.mV[3] = a.mV[3];
srgbColor.mV[0] = linearTosRGB(a.mV[0]);
srgbColor.mV[1] = linearTosRGB(a.mV[1]);
srgbColor.mV[2] = linearTosRGB(a.mV[2]);
srgbColor.mV[3] = a.mV[3];
return srgbColor;
return srgbColor;
}

View File

@ -133,7 +133,7 @@ class LLLightParams : public LLNetworkData
{
protected:
LLColor4 mColor; // alpha = intensity
LLColor4 msRGBColor; // Only used in deferred (for now?)
LLColor4 mSRGBColor; // Only used in deferred (for now?)
F32 mRadius;
F32 mFalloff;
F32 mCutoff;
@ -150,14 +150,14 @@ public:
operator LLSD() const { return asLLSD(); }
bool fromLLSD(LLSD& sd);
void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); msRGBColor = srgbColor4(mColor); }
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 getsRGBColor() const { return msRGBColor; }
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; }

View File

@ -87,9 +87,9 @@ void LLCubeMap::initGL()
for (int i = 0; i < 6; i++)
{
mImages[i] = new LLImageGL(RESOLUTION, RESOLUTION, 4, FALSE);
if (mIssRGB) {
mImages[i]->setExplicitFormat(GL_SRGB8_ALPHA8, GL_RGBA);
}
if (mIssRGB) {
mImages[i]->setExplicitFormat(GL_SRGB8_ALPHA8, GL_RGBA);
}
mImages[i]->setTarget(mTargets[i], LLTexUnit::TT_CUBE_MAP);
mRawImages[i] = new LLImageRaw(RESOLUTION, RESOLUTION, 4);
mImages[i]->createGLTexture(0, mRawImages[i], texname);

View File

@ -184,47 +184,47 @@ void LLImageGL::cleanupClass()
//static
S32 LLImageGL::dataFormatBits(S32 dataformat)
{
switch (dataformat)
{
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return 4;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 4;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return 8;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 8;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return 8;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return 8;
case GL_LUMINANCE: return 8;
case GL_ALPHA: return 8;
case GL_COLOR_INDEX: return 8;
case GL_LUMINANCE_ALPHA: return 16;
case GL_RGB: return 24;
case GL_SRGB: return 24;
case GL_RGB8: return 24;
case GL_RGBA: return 32;
case GL_SRGB_ALPHA: return 32;
case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac
default:
LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL;
return 0;
}
switch (dataformat)
{
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return 4;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 4;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return 8;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 8;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return 8;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return 8;
case GL_LUMINANCE: return 8;
case GL_ALPHA: return 8;
case GL_COLOR_INDEX: return 8;
case GL_LUMINANCE_ALPHA: return 16;
case GL_RGB: return 24;
case GL_SRGB: return 24;
case GL_RGB8: return 24;
case GL_RGBA: return 32;
case GL_SRGB_ALPHA: return 32;
case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac
default:
LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL;
return 0;
}
}
//static
S32 LLImageGL::dataFormatBytes(S32 dataformat, S32 width, S32 height)
{
switch (dataformat)
{
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
if (width < 4) width = 4;
if (height < 4) height = 4;
break;
default:
break;
}
switch (dataformat)
{
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
if (width < 4) width = 4;
if (height < 4) height = 4;
break;
default:
break;
}
S32 bytes ((width*height*dataFormatBits(dataformat)+7)>>3);
S32 aligned = (bytes+3)&~3;
return aligned;
@ -669,19 +669,19 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
LL_RECORD_BLOCK_TIME(FTM_SET_IMAGE);
bool is_compressed = false;
switch (mFormatPrimary)
{
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
is_compressed = true;
break;
default:
break;
}
switch (mFormatPrimary)
{
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
is_compressed = true;
break;
default:
break;
}
@ -1255,18 +1255,18 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt
case GL_RGB8:
intformat = GL_COMPRESSED_RGB;
break;
case GL_SRGB:
case GL_SRGB8:
intformat = GL_COMPRESSED_SRGB;
break;
case GL_SRGB:
case GL_SRGB8:
intformat = GL_COMPRESSED_SRGB;
break;
case GL_RGBA:
case GL_RGBA8:
intformat = GL_COMPRESSED_RGBA;
break;
case GL_SRGB_ALPHA:
case GL_SRGB8_ALPHA8:
intformat = GL_COMPRESSED_SRGB_ALPHA;
break;
case GL_SRGB_ALPHA:
case GL_SRGB8_ALPHA8:
intformat = GL_COMPRESSED_SRGB_ALPHA;
break;
case GL_LUMINANCE:
case GL_LUMINANCE8:
intformat = GL_COMPRESSED_LUMINANCE;
@ -1824,30 +1824,30 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
}
mAlphaStride = -1 ;
switch (mFormatPrimary)
{
case GL_LUMINANCE:
case GL_ALPHA:
mAlphaStride = 1;
break;
case GL_LUMINANCE_ALPHA:
mAlphaStride = 2;
break;
case GL_RGB:
case GL_SRGB:
mNeedsAlphaAndPickMask = FALSE ;
mIsMask = FALSE;
return ; //no alpha channel.
case GL_RGBA:
case GL_SRGB_ALPHA:
mAlphaStride = 4;
break;
case GL_BGRA_EXT:
mAlphaStride = 4;
break;
default:
break;
}
switch (mFormatPrimary)
{
case GL_LUMINANCE:
case GL_ALPHA:
mAlphaStride = 1;
break;
case GL_LUMINANCE_ALPHA:
mAlphaStride = 2;
break;
case GL_RGB:
case GL_SRGB:
mNeedsAlphaAndPickMask = FALSE;
mIsMask = FALSE;
return; //no alpha channel.
case GL_RGBA:
case GL_SRGB_ALPHA:
mAlphaStride = 4;
break;
case GL_BGRA_EXT:
mAlphaStride = 4;
break;
default:
break;
}
mAlphaOffset = -1 ;
if (mFormatType == GL_UNSIGNED_BYTE)
@ -2030,13 +2030,13 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in)
freePickMask();
if (mFormatType != GL_UNSIGNED_BYTE ||
mFormatPrimary != GL_RGBA ||
mFormatPrimary != GL_SRGB_ALPHA)
{
//cannot generate a pick mask for this texture
return;
}
if (mFormatType != GL_UNSIGNED_BYTE ||
mFormatPrimary != GL_RGBA ||
mFormatPrimary != GL_SRGB_ALPHA)
{
//cannot generate a pick mask for this texture
return;
}
#ifdef SHOW_ASSERT
const U32 pickSize = createPickMask(width, height);

View File

@ -1193,7 +1193,7 @@ void LLRender::syncLightState()
shader->uniform3fv(LLShaderMgr::LIGHT_DIRECTION, 8, direction[0].mV);
shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV);
shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV);
shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, srgbColor4(mAmbientLightColor).mV);
shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV);
shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0);
shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV);
}

View File

@ -503,7 +503,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor());
sun_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV);
sun_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV);
sun_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
LLFacePool::LLOverrideFaceColor color_override(this, color);
@ -553,9 +553,9 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
F32 moon_brightness = (float)psky->getMoonBrightness();
moon_shader->uniform1f(LLShaderMgr::MOON_BRIGHTNESS, moon_brightness);
moon_shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, gSky.mVOSkyp->getMoon().getColor().mV);
moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV);
moon_shader->uniform1f(LLShaderMgr::MOON_BRIGHTNESS, moon_brightness);
moon_shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, gSky.mVOSkyp->getMoon().getColor().mV);
moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV);
moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
LLFacePool::LLOverrideFaceColor color_override(this, color);

View File

@ -207,12 +207,12 @@ void LLSkyTex::create(const F32 brightness)
void LLSkyTex::createGLImage(S32 which)
{
if (LLPipeline::RenderDeferred) {
mTexture[which]->setExplicitFormat(GL_SRGB8_ALPHA8, GL_RGBA);
}
else {
mTexture[which]->setExplicitFormat(GL_RGBA8, GL_RGBA);
}
if (LLPipeline::RenderDeferred) {
mTexture[which]->setExplicitFormat(GL_SRGB8_ALPHA8, GL_RGBA);
}
else {
mTexture[which]->setExplicitFormat(GL_RGBA8, GL_RGBA);
}
mTexture[which]->createGLTexture(0, mImageRaw[which], 0, TRUE, LLGLTexture::LOCAL);
mTexture[which]->setAddressMode(LLTexUnit::TAM_CLAMP);
}
@ -619,10 +619,10 @@ void LLVOSky::initCubeMap()
}
else if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)
{
bool wantsRGB = LLPipeline::RenderDeferred;
bool wantsRGB = LLPipeline::RenderDeferred;
mCubeMap = new LLCubeMap(wantsRGB);
mCubeMap->init(images);
mCubeMap = new LLCubeMap(wantsRGB);
mCubeMap->init(images);
}
gGL.getTexUnit(0)->disable();
}

View File

@ -3239,17 +3239,17 @@ LLColor3 LLVOVolume::getLightColor() const
}
}
LLColor3 LLVOVolume::getLightsRGBColor() 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);
}
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

View File

@ -251,7 +251,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.
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;

View File

@ -8368,7 +8368,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_
shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff);
shader.uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV);
shader.uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, srgbColor4(mMoonDiffuse).mV);
shader.uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV);
LLEnvironment& environment = LLEnvironment::instance();
shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0);
@ -8705,7 +8705,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)
const F32* c = center.getF32ptr();
F32 s = volume->getLightRadius()*1.5f;
LLColor3 col = volume->getLightsRGBColor();
LLColor3 col = volume->getLightSRGBColor();
if (col.magVecSquared() < 0.001f)
{
@ -8797,10 +8797,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)
setupSpotLight(gDeferredSpotLightProgram, drawablep);
LLColor3 col = volume->getLightsRGBColor();
/*col.mV[0] = powf(col.mV[0], 2.2f);
col.mV[1] = powf(col.mV[1], 2.2f);
col.mV[2] = powf(col.mV[2], 2.2f);*/
LLColor3 col = volume->getLightSRGBColor();
gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c);
gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);
@ -8888,7 +8885,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)
setupSpotLight(gDeferredMultiSpotLightProgram, drawablep);
LLColor3 col = volume->getLightsRGBColor();
LLColor3 col = volume->getLightSRGBColor();
gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v);
gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);