Skip to content

Commit d7468ce

Browse files
committed
Add TE support for texture gamma on legacy content.
This is a work around for legacy content to ensure that users can get alpha blending for their stuff closer to what it used to be. This is mainly focused on the messaging end and plumbing.
1 parent ae0433f commit d7468ce

File tree

11 files changed

+138
-7
lines changed

11 files changed

+138
-7
lines changed

indra/llprimitive/llprimitive.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ S32 LLPrimitive::setTEBumpmap(const U8 index, const U8 bump)
385385
return mTextureList.setBumpMap(index, bump);
386386
}
387387

388+
S32 LLPrimitive::setTEAlphaGamma(const U8 index, const U8 gamma)
389+
{
390+
return mTextureList.setAlphaGamma(index, gamma);
391+
}
392+
388393
S32 LLPrimitive::setTEBumpShiny(const U8 index, const U8 bump_shiny)
389394
{
390395
updateNumBumpmap(index, bump_shiny);
@@ -1213,6 +1218,7 @@ bool LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
12131218
S16 offset_t[MAX_TES];
12141219
S16 image_rot[MAX_TES];
12151220
U8 bump[MAX_TES];
1221+
U8 alpha_gamma[MAX_TES];
12161222
U8 media_flags[MAX_TES];
12171223
U8 glow[MAX_TES];
12181224
U8 material_data[MAX_TES*16];
@@ -1251,6 +1257,7 @@ bool LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
12511257
offset_t[face_index] = (S16) ll_round((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ;
12521258
image_rot[face_index] = (S16) ll_round(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR));
12531259
bump[face_index] = te->getBumpShinyFullbright();
1260+
alpha_gamma[face_index] = te->getAlphaGamma();
12541261
media_flags[face_index] = te->getMediaTexGen();
12551262
glow[face_index] = (U8) ll_round((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF));
12561263

@@ -1278,7 +1285,10 @@ bool LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
12781285
*cur_ptr++ = 0;
12791286
cur_ptr += packTEField(cur_ptr, (U8 *)glow, 1 ,last_face_index, MVT_U8);
12801287
*cur_ptr++ = 0;
1281-
cur_ptr += packTEField(cur_ptr, (U8 *)material_data, 16, last_face_index, MVT_LLUUID);
1288+
cur_ptr += packTEField(cur_ptr, (U8 *) material_data, 16, last_face_index, MVT_LLUUID);
1289+
*cur_ptr++ = 0;
1290+
*cur_ptr++ = 0x01;
1291+
cur_ptr += packTEField(cur_ptr, (U8 *) alpha_gamma, 1, last_face_index, MVT_U8);
12821292
}
12831293
mesgsys->addBinaryDataFast(_PREHASH_TextureEntry, packed_buffer, (S32)(cur_ptr - packed_buffer));
12841294

@@ -1298,6 +1308,7 @@ bool LLPrimitive::packTEMessage(LLDataPacker &dp) const
12981308
S16 offset_t[MAX_TES];
12991309
S16 image_rot[MAX_TES];
13001310
U8 bump[MAX_TES];
1311+
U8 alpha_gamma[MAX_TES];
13011312
U8 media_flags[MAX_TES];
13021313
U8 glow[MAX_TES];
13031314
U8 material_data[MAX_TES*16];
@@ -1336,6 +1347,7 @@ bool LLPrimitive::packTEMessage(LLDataPacker &dp) const
13361347
offset_t[face_index] = (S16) ll_round((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ;
13371348
image_rot[face_index] = (S16) ll_round(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR));
13381349
bump[face_index] = te->getBumpShinyFullbright();
1350+
alpha_gamma[face_index] = te->getAlphaGamma();
13391351
media_flags[face_index] = te->getMediaTexGen();
13401352
glow[face_index] = (U8) ll_round((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF));
13411353

@@ -1363,7 +1375,10 @@ bool LLPrimitive::packTEMessage(LLDataPacker &dp) const
13631375
*cur_ptr++ = 0;
13641376
cur_ptr += packTEField(cur_ptr, (U8 *)glow, 1 ,last_face_index, MVT_U8);
13651377
*cur_ptr++ = 0;
1366-
cur_ptr += packTEField(cur_ptr, (U8 *)material_data, 16, last_face_index, MVT_LLUUID);
1378+
cur_ptr += packTEField(cur_ptr, (U8 *) material_data, 16, last_face_index, MVT_LLUUID);
1379+
*cur_ptr++ = 0;
1380+
*cur_ptr++ = 0x01;
1381+
cur_ptr += packTEField(cur_ptr, (U8 *) alpha_gamma, 1, last_face_index, MVT_U8);
13671382
}
13681383

13691384
dp.packBinaryData(packed_buffer, (S32)(cur_ptr - packed_buffer), "TextureEntry");
@@ -1420,7 +1435,8 @@ S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name
14201435
unpack_TEField<S16>(tec.image_rot, tec.face_count, cur_ptr, buffer_end, MVT_S16) &&
14211436
unpack_TEField<U8>(tec.bump, tec.face_count, cur_ptr, buffer_end, MVT_U8) &&
14221437
unpack_TEField<U8>(tec.media_flags, tec.face_count, cur_ptr, buffer_end, MVT_U8) &&
1423-
unpack_TEField<U8>(tec.glow, tec.face_count, cur_ptr, buffer_end, MVT_U8)))
1438+
unpack_TEField<U8>(tec.glow, tec.face_count, cur_ptr, buffer_end, MVT_U8) &&
1439+
unpack_TEField<U8>(tec.alpha_gamma, tec.face_count, cur_ptr, buffer_end, MVT_U8)))
14241440
{
14251441
LL_WARNS("TEXTUREENTRY") << "Failure parsing Texture Entry Message due to malformed TE Field! Dropping changes on the floor. " << LL_ENDL;
14261442
return 0;
@@ -1456,6 +1472,7 @@ S32 LLPrimitive::applyParsedTEMessage(LLTEContents& tec)
14561472
retval |= setTEMediaTexGen(i, tec.media_flags[i]);
14571473
retval |= setTEGlow(i, (F32)tec.glow[i] / (F32)0xFF);
14581474
retval |= setTEMaterialID(i, tec.material_ids[i]);
1475+
retval |= setTEAlphaGamma(i, tec.alpha_gamma[i]);
14591476

14601477
// Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f)
14611478
// as all zeros. However, the subtraction and addition must be done in unsigned

indra/llprimitive/llprimitive.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ struct LLTEContents
411411
S16 offset_t[MAX_TES];
412412
S16 image_rot[MAX_TES];
413413
U8 bump[MAX_TES];
414+
U8 alpha_gamma[MAX_TES];
414415
U8 media_flags[MAX_TES];
415416
U8 glow[MAX_TES];
416417
LLMaterialID material_ids[MAX_TES];
@@ -482,6 +483,7 @@ class LLPrimitive : public LLXform
482483
virtual S32 setTEBumpShiny(const U8 te, const U8 bump);
483484
virtual S32 setTEMediaTexGen(const U8 te, const U8 media);
484485
virtual S32 setTEBumpmap(const U8 te, const U8 bump);
486+
virtual S32 setTEAlphaGamma(const U8 te, const U8 alphagamma);
485487
virtual S32 setTETexGen(const U8 te, const U8 texgen);
486488
virtual S32 setTEShiny(const U8 te, const U8 shiny);
487489
virtual S32 setTEFullbright(const U8 te, const U8 fullbright);

indra/llprimitive/llprimtexturelist.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,15 @@ S32 LLPrimTextureList::setBumpMap(const U8 index, const U8 bump)
305305
return TEM_CHANGE_NONE;
306306
}
307307

308+
S32 LLPrimTextureList::setAlphaGamma(const U8 index, const U8 gamma)
309+
{
310+
if (index < mEntryList.size())
311+
{
312+
return mEntryList[index]->setAlphaGamma(gamma);
313+
}
314+
return TEM_CHANGE_NONE;
315+
}
316+
308317
S32 LLPrimTextureList::setBumpShiny(const U8 index, const U8 bump_shiny)
309318
{
310319
if (index < mEntryList.size())

indra/llprimitive/llprimtexturelist.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class LLPrimTextureList
9999
S32 setMediaTexGen(const U8 index, const U8 media);
100100
S32 setBumpMap(const U8 index, const U8 bump);
101101
S32 setBumpShiny(const U8 index, const U8 bump_shiny);
102+
S32 setAlphaGamma(const U8 index, const U8 gamma);
102103
S32 setTexGen(const U8 index, const U8 texgen);
103104
S32 setShiny(const U8 index, const U8 shiny);
104105
S32 setFullbright(const U8 index, const U8 t);

indra/llprimitive/lltextureentry.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "v4color.h"
3535

3636
const U8 DEFAULT_BUMP_CODE = 0; // no bump or shininess
37+
const U8 DEFAULT_ALPHA_GAMMA = 100; // Gamma 1 (linear) for alpha blending
3738

3839
const LLTextureEntry LLTextureEntry::null;
3940

@@ -64,15 +65,15 @@ LLTextureEntry::LLTextureEntry()
6465
, mSelected(false)
6566
, mMaterialUpdatePending(false)
6667
{
67-
init(LLUUID::null,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE);
68+
init(LLUUID::null, 1.f, 1.f, 0.f, 0.f, 0.f, DEFAULT_BUMP_CODE, DEFAULT_ALPHA_GAMMA);
6869
}
6970

7071
LLTextureEntry::LLTextureEntry(const LLUUID& tex_id)
7172
: mMediaEntry(NULL)
7273
, mSelected(false)
7374
, mMaterialUpdatePending(false)
7475
{
75-
init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE);
76+
init(tex_id, 1.f, 1.f, 0.f, 0.f, 0.f, DEFAULT_BUMP_CODE, DEFAULT_ALPHA_GAMMA);
7677
}
7778

7879
LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs)
@@ -95,6 +96,7 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs)
9596
mRotation = rhs.mRotation;
9697
mColor = rhs.mColor;
9798
mBump = rhs.mBump;
99+
mAlphaGamma = rhs.mAlphaGamma;
98100
mMediaFlags = rhs.mMediaFlags;
99101
mGlow = rhs.mGlow;
100102
mMaterialID = rhs.mMaterialID;
@@ -135,7 +137,7 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs)
135137
return *this;
136138
}
137139

138-
void LLTextureEntry::init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump)
140+
void LLTextureEntry::init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump, U8 alphagamma)
139141
{
140142
setID(tex_id);
141143

@@ -145,6 +147,7 @@ void LLTextureEntry::init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 of
145147
mOffsetT = offset_t;
146148
mRotation = rotation;
147149
mBump = bump;
150+
mAlphaGamma = alphagamma;
148151
mMediaFlags = 0x0;
149152
mGlow = 0;
150153
mMaterialID.clear();
@@ -181,6 +184,7 @@ bool LLTextureEntry::operator!=(const LLTextureEntry &rhs) const
181184
if (mRotation != rhs.mRotation) return(true);
182185
if (mColor != rhs.mColor) return (true);
183186
if (mBump != rhs.mBump) return (true);
187+
if (mAlphaGamma != rhs.mAlphaGamma) return (true);
184188
if (mMediaFlags != rhs.mMediaFlags) return (true);
185189
if (mGlow != rhs.mGlow) return (true);
186190
if (mMaterialID != rhs.mMaterialID) return (true);
@@ -197,6 +201,7 @@ bool LLTextureEntry::operator==(const LLTextureEntry &rhs) const
197201
if (mRotation != rhs.mRotation) return(false);
198202
if (mColor != rhs.mColor) return (false);
199203
if (mBump != rhs.mBump) return (false);
204+
if (mAlphaGamma != rhs.mAlphaGamma) return (false);
200205
if (mMediaFlags != rhs.mMediaFlags) return false;
201206
if (mGlow != rhs.mGlow) return false;
202207
if (mMaterialID != rhs.mMaterialID) return (false);
@@ -221,6 +226,7 @@ void LLTextureEntry::asLLSD(LLSD& sd) const
221226
sd["offsett"] = mOffsetT;
222227
sd["imagerot"] = mRotation;
223228
sd["bump"] = getBumpShiny();
229+
sd["alphagamma"] = getAlphaGamma();
224230
sd["fullbright"] = getFullbright();
225231
sd["media_flags"] = mMediaFlags;
226232
if (hasMedia()) {
@@ -274,6 +280,11 @@ bool LLTextureEntry::fromLLSD(const LLSD& sd)
274280
{
275281
setBumpShiny( sd[w].asInteger() );
276282
} else goto fail;
283+
w = "alphagamma";
284+
if (sd.has(w))
285+
{
286+
setAlphaGamma(sd[w].asInteger());
287+
} // else goto fail;
277288
w = "fullbright";
278289
if (sd.has(w))
279290
{
@@ -472,6 +483,16 @@ S32 LLTextureEntry::setBumpShinyFullbright(U8 bump)
472483
return TEM_CHANGE_NONE;
473484
}
474485

486+
S32 LLTextureEntry::setAlphaGamma(U8 alpha_gamma)
487+
{
488+
if (mAlphaGamma != alpha_gamma)
489+
{
490+
mAlphaGamma = alpha_gamma;
491+
return TEM_CHANGE_TEXTURE;
492+
}
493+
return TEM_CHANGE_NONE;
494+
}
495+
475496
S32 LLTextureEntry::setMediaTexGen(U8 media)
476497
{
477498
S32 result = TEM_CHANGE_NONE;

indra/llprimitive/lltextureentry.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class LLTextureEntry
103103
virtual LLTextureEntry* newBlank() const;
104104
virtual LLTextureEntry* newCopy() const;
105105

106-
void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump);
106+
void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump, U8 alphagamma);
107107

108108
bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; }
109109
bool isSelected() const { return mSelected; }
@@ -128,6 +128,8 @@ class LLTextureEntry
128128
S32 setBumpShiny(U8 bump);
129129
S32 setBumpShinyFullbright(U8 bump);
130130

131+
S32 setAlphaGamma(U8 alpha_gamma);
132+
131133
S32 setMediaFlags(U8 media_flags);
132134
S32 setTexGen(U8 texGen);
133135
S32 setMediaTexGen(U8 media);
@@ -156,6 +158,8 @@ class LLTextureEntry
156158
U8 getBumpShiny() const { return mBump & TEM_BUMP_SHINY_MASK; }
157159
U8 getBumpShinyFullbright() const { return mBump; }
158160

161+
U8 getAlphaGamma() const { return mAlphaGamma; }
162+
159163
U8 getMediaFlags() const { return mMediaFlags & TEM_MEDIA_MASK; }
160164
LLTextureEntry::e_texgen getTexGen() const { return LLTextureEntry::e_texgen(mMediaFlags & TEM_TEX_GEN_MASK); }
161165
U8 getMediaTexGen() const { return mMediaFlags; }
@@ -233,6 +237,7 @@ class LLTextureEntry
233237
LLColor4 mColor;
234238
U8 mBump; // Bump map, shiny, and fullbright
235239
U8 mMediaFlags; // replace with web page, movie, etc.
240+
U8 mAlphaGamma; // Fixed point gamma correction for alpha blending.
236241
F32 mGlow;
237242
bool mMaterialUpdatePending;
238243
LLMaterialID mMaterialID;

indra/newview/llpanelface.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ bool LLPanelFace::postBuild()
421421

422422
getChildSetCommitCallback(mCheckFullbright, "checkbox fullbright", [&](LLUICtrl*, const LLSD&) { onCommitFullbright(); });
423423

424+
425+
mLabelTexGen = getChild<LLTextBox>("alpha gamma");
426+
getChildSetCommitCallback(mComboAlphaGamma, "combobox alpha gamma", [&](LLUICtrl *, const LLSD &) { onCommitAlphaGamma(); });
427+
mComboAlphaGamma->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
428+
424429
mLabelTexGen = getChild<LLTextBox>("tex gen");
425430
getChildSetCommitCallback(mComboTexGen, "combobox texgen", [&](LLUICtrl*, const LLSD&) { onCommitTexGen(); });
426431
mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
@@ -553,6 +558,12 @@ void LLPanelFace::sendBump(U32 bumpiness)
553558
LLSelectMgr::getInstance()->selectionSetBumpmap( bump, mBumpyTextureCtrl->getImageItemID() );
554559
}
555560

561+
void LLPanelFace::sendAlphaGamma()
562+
{
563+
U8 alpha_gamma = (U8) mComboAlphaGamma->getCurrentIndex() << TEM_TEX_GEN_SHIFT;
564+
LLSelectMgr::getInstance()->selectionSetAlphaGamma(alpha_gamma);
565+
}
566+
556567
void LLPanelFace::sendTexGen()
557568
{
558569
U8 tex_gen = (U8)mComboTexGen->getCurrentIndex() << TEM_TEX_GEN_SHIFT;
@@ -2914,6 +2925,11 @@ void LLPanelFace::onCommitBump()
29142925
sendBump(mComboBumpiness->getCurrentIndex());
29152926
}
29162927

2928+
void LLPanelFace::onCommitAlphaGamma()
2929+
{
2930+
sendAlphaGamma();
2931+
}
2932+
29172933
void LLPanelFace::onCommitTexGen()
29182934
{
29192935
sendTexGen();

indra/newview/llpanelface.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class LLPanelFace : public LLPanel
146146
void sendColor(); // applies and sends color
147147
void sendAlpha(); // applies and sends transparency
148148
void sendBump(U32 bumpiness); // applies and sends bump map
149+
void sendAlphaGamma(); // applies and sends bump map
149150
void sendTexGen(); // applies and sends bump map
150151
void sendShiny(U32 shininess); // applies and sends shininess
151152
void sendFullbright(); // applies and sends full bright
@@ -234,6 +235,7 @@ class LLPanelFace : public LLPanel
234235
void onClickBtnDeleteMedia();
235236
void onClickBtnAddMedia();
236237
void onCommitBump();
238+
void onCommitAlphaGamma();
237239
void onCommitTexGen();
238240
void onCommitShiny();
239241
void onCommitAlphaMode();
@@ -304,6 +306,8 @@ class LLPanelFace : public LLPanel
304306
LLTextBox* mLabelTexGen { nullptr };
305307
LLComboBox* mComboTexGen { nullptr };
306308

309+
LLComboBox *mComboAlphaGamma {nullptr};
310+
307311
LLRadioGroup* mRadioMaterialType { nullptr };
308312
LLRadioGroup* mRadioPbrType { nullptr };
309313

indra/newview/llselectmgr.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,6 +2330,28 @@ void LLSelectMgr::selectionSetBumpmap(U8 bumpmap, const LLUUID &image_id)
23302330
getSelection()->applyToObjects(&sendfunc);
23312331
}
23322332

2333+
void LLSelectMgr::selectionSetAlphaGamma(U8 gamma)
2334+
{
2335+
struct f : public LLSelectedTEFunctor
2336+
{
2337+
U8 mAlphaGamma;
2338+
f(const U8 &t) : mAlphaGamma(t) {}
2339+
bool apply(LLViewerObject *object, S32 te)
2340+
{
2341+
if (object->permModify())
2342+
{
2343+
// update viewer side color in anticipation of update from simulator
2344+
object->setTEAlphaGamma(te, mAlphaGamma);
2345+
}
2346+
return true;
2347+
}
2348+
} setfunc(gamma);
2349+
getSelection()->applyToTEs(&setfunc);
2350+
2351+
LLSelectMgrSendFunctor sendfunc;
2352+
getSelection()->applyToObjects(&sendfunc);
2353+
}
2354+
23332355
void LLSelectMgr::selectionSetTexGen(U8 texgen)
23342356
{
23352357
struct f : public LLSelectedTEFunctor

indra/newview/llselectmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSimpleton<LLSelectMgr>
660660
bool selectionRevertTextures();
661661
void selectionRevertGLTFMaterials();
662662
void selectionSetBumpmap( U8 bumpmap, const LLUUID &image_id );
663+
void selectionSetAlphaGamma( U8 gamma );
663664
void selectionSetTexGen( U8 texgen );
664665
void selectionSetShiny( U8 shiny, const LLUUID &image_id );
665666
void selectionSetFullbright( U8 fullbright );

0 commit comments

Comments
 (0)