Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
XDG Integration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
JennaHuntsman
XDG Integration
Commits
dbc641ce
Commit
dbc641ce
authored
2 years ago
by
David Parks
Browse files
Options
Downloads
Patches
Plain Diff
SL-18861 Optimize away alpha channel on GLTF material imports.
parent
d27d23ab
No related branches found
Branches containing commit
No related tags found
2 merge requests
!3
Update to main branch
,
!2
Rebase onto current main branch
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
indra/llimage/llimage.cpp
+37
-0
37 additions, 0 deletions
indra/llimage/llimage.cpp
indra/llimage/llimage.h
+4
-0
4 additions, 0 deletions
indra/llimage/llimage.h
indra/newview/lltinygltfhelper.cpp
+1
-0
1 addition, 0 deletions
indra/newview/lltinygltfhelper.cpp
with
42 additions
and
0 deletions
indra/llimage/llimage.cpp
+
37
−
0
View file @
dbc641ce
...
...
@@ -989,6 +989,43 @@ void LLImageRaw::verticalFlip()
}
bool
LLImageRaw
::
optimizeAwayAlpha
()
{
if
(
getComponents
()
==
4
)
{
U8
*
data
=
getData
();
U32
pixels
=
getWidth
()
*
getHeight
();
// check alpha channel for all 255
for
(
U32
i
=
0
;
i
<
pixels
;
++
i
)
{
if
(
data
[
i
*
4
+
3
]
!=
255
)
{
return
false
;
}
}
// alpha channel is all 255, make a new copy of data without alpha channel
U8
*
new_data
=
(
U8
*
)
ll_aligned_malloc_16
(
getWidth
()
*
getHeight
()
*
3
);
for
(
U32
i
=
0
;
i
<
pixels
;
++
i
)
{
U32
di
=
i
*
3
;
U32
si
=
i
*
4
;
for
(
U32
j
=
0
;
j
<
3
;
++
j
)
{
new_data
[
di
+
j
]
=
data
[
si
+
j
];
}
}
setDataAndSize
(
new_data
,
getWidth
(),
getHeight
(),
3
);
return
true
;
}
return
false
;
}
void
LLImageRaw
::
expandToPowerOfTwo
(
S32
max_dim
,
bool
scale_image
)
{
// Find new sizes
...
...
This diff is collapsed.
Click to expand it.
indra/llimage/llimage.h
+
4
−
0
View file @
dbc641ce
...
...
@@ -208,6 +208,10 @@ class LLImageRaw : public LLImageBase
void
clear
(
U8
r
=
0
,
U8
g
=
0
,
U8
b
=
0
,
U8
a
=
255
);
void
verticalFlip
();
// if the alpha channel is all 100% opaque, delete it
// returns true if alpha channel was deleted
bool
optimizeAwayAlpha
();
static
S32
biasedDimToPowerOfTwo
(
S32
curr_dim
,
S32
max_dim
=
MAX_IMAGE_SIZE
);
static
S32
expandDimToPowerOfTwo
(
S32
curr_dim
,
S32
max_dim
=
MAX_IMAGE_SIZE
);
...
...
This diff is collapsed.
Click to expand it.
indra/newview/lltinygltfhelper.cpp
+
1
−
0
View file @
dbc641ce
...
...
@@ -160,6 +160,7 @@ LLImageRaw * LLTinyGLTFHelper::getTexture(const std::string & folder, const tiny
name
=
image
->
name
;
rawImage
=
new
LLImageRaw
(
&
image
->
image
[
0
],
image
->
width
,
image
->
height
,
image
->
component
);
rawImage
->
verticalFlip
();
rawImage
->
optimizeAwayAlpha
();
}
return
rawImage
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment