Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
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
Alchemy Viewer
Alchemy Viewer
Commits
e4dd9c1e
Commit
e4dd9c1e
authored
2 years ago
by
Cosmic Linden
Browse files
Options
Downloads
Patches
Plain Diff
SL-18634: Fix GLTF material texture transform not serializing when texture ID is null
parent
cdf248d9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/llprimitive/llgltfmaterial.cpp
+12
-9
12 additions, 9 deletions
indra/llprimitive/llgltfmaterial.cpp
indra/llprimitive/llgltfmaterial.h
+5
-3
5 additions, 3 deletions
indra/llprimitive/llgltfmaterial.h
with
17 additions
and
12 deletions
indra/llprimitive/llgltfmaterial.cpp
+
12
−
9
View file @
e4dd9c1e
...
@@ -61,6 +61,11 @@ LLMatrix3 LLGLTFMaterial::TextureTransform::asMatrix()
...
@@ -61,6 +61,11 @@ LLMatrix3 LLGLTFMaterial::TextureTransform::asMatrix()
return
offset
*
rotation
*
scale
;
return
offset
*
rotation
*
scale
;
}
}
bool
LLGLTFMaterial
::
TextureTransform
::
operator
==
(
const
TextureTransform
&
other
)
const
{
return
mOffset
==
other
.
mOffset
&&
mScale
==
other
.
mScale
&&
mRotation
==
other
.
mRotation
;
}
LLGLTFMaterial
::
LLGLTFMaterial
(
const
LLGLTFMaterial
&
rhs
)
LLGLTFMaterial
::
LLGLTFMaterial
(
const
LLGLTFMaterial
&
rhs
)
{
{
*
this
=
rhs
;
*
this
=
rhs
;
...
@@ -268,16 +273,14 @@ void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const
...
@@ -268,16 +273,14 @@ void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const
tinygltf
::
Material
&
material_out
=
model
.
materials
[
mat_index
];
tinygltf
::
Material
&
material_out
=
model
.
materials
[
mat_index
];
constexpr
bool
is_override
=
false
;
// set base color texture
// set base color texture
writeToTexture
(
model
,
material_out
.
pbrMetallicRoughness
.
baseColorTexture
,
GLTF_TEXTURE_INFO_BASE_COLOR
,
mBaseColorId
,
is_override
,
LLUUID
()
);
writeToTexture
(
model
,
material_out
.
pbrMetallicRoughness
.
baseColorTexture
,
GLTF_TEXTURE_INFO_BASE_COLOR
,
mBaseColorId
);
// set normal texture
// set normal texture
writeToTexture
(
model
,
material_out
.
normalTexture
,
GLTF_TEXTURE_INFO_NORMAL
,
mNormalId
,
is_override
,
LLUUID
()
);
writeToTexture
(
model
,
material_out
.
normalTexture
,
GLTF_TEXTURE_INFO_NORMAL
,
mNormalId
);
// set metallic-roughness texture
// set metallic-roughness texture
writeToTexture
(
model
,
material_out
.
pbrMetallicRoughness
.
metallicRoughnessTexture
,
GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS
,
mMetallicRoughnessId
,
is_override
,
LLUUID
()
);
writeToTexture
(
model
,
material_out
.
pbrMetallicRoughness
.
metallicRoughnessTexture
,
GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS
,
mMetallicRoughnessId
);
// set emissive texture
// set emissive texture
writeToTexture
(
model
,
material_out
.
emissiveTexture
,
GLTF_TEXTURE_INFO_EMISSIVE
,
mEmissiveId
,
is_override
,
LLUUID
()
);
writeToTexture
(
model
,
material_out
.
emissiveTexture
,
GLTF_TEXTURE_INFO_EMISSIVE
,
mEmissiveId
);
material_out
.
alphaMode
=
getAlphaMode
();
material_out
.
alphaMode
=
getAlphaMode
();
material_out
.
alphaCutoff
=
mAlphaCutoff
;
material_out
.
alphaCutoff
=
mAlphaCutoff
;
...
@@ -338,10 +341,11 @@ void gltf_allocate_texture_image(tinygltf::Model& model, T& texture_info, const
...
@@ -338,10 +341,11 @@ void gltf_allocate_texture_image(tinygltf::Model& model, T& texture_info, const
}
}
template
<
typename
T
>
template
<
typename
T
>
void
LLGLTFMaterial
::
writeToTexture
(
tinygltf
::
Model
&
model
,
T
&
texture_info
,
TextureInfo
texture_info_id
,
const
LLUUID
&
texture_id
,
bool
is_override
,
const
LLUUID
&
base_
texture_id
)
const
void
LLGLTFMaterial
::
writeToTexture
(
tinygltf
::
Model
&
model
,
T
&
texture_info
,
TextureInfo
texture_info_id
,
const
LLUUID
&
texture_id
)
const
{
{
LL_PROFILE_ZONE_SCOPED
;
LL_PROFILE_ZONE_SCOPED
;
if
(
texture_id
.
isNull
()
||
(
is_override
&&
texture_id
==
base_texture_id
))
const
TextureTransform
&
transform
=
mTextureTransform
[
texture_info_id
];
if
(
texture_id
.
isNull
()
&&
transform
==
sDefault
.
mTextureTransform
[
0
])
{
{
return
;
return
;
}
}
...
@@ -349,7 +353,6 @@ void LLGLTFMaterial::writeToTexture(tinygltf::Model& model, T& texture_info, Tex
...
@@ -349,7 +353,6 @@ void LLGLTFMaterial::writeToTexture(tinygltf::Model& model, T& texture_info, Tex
gltf_allocate_texture_image
(
model
,
texture_info
,
texture_id
.
asString
());
gltf_allocate_texture_image
(
model
,
texture_info
,
texture_id
.
asString
());
tinygltf
::
Value
::
Object
transform_map
;
tinygltf
::
Value
::
Object
transform_map
;
const
TextureTransform
&
transform
=
mTextureTransform
[
texture_info_id
];
transform_map
[
GLTF_FILE_EXTENSION_TRANSFORM_OFFSET
]
=
tinygltf
::
Value
(
tinygltf
::
Value
::
Array
({
transform_map
[
GLTF_FILE_EXTENSION_TRANSFORM_OFFSET
]
=
tinygltf
::
Value
(
tinygltf
::
Value
::
Array
({
tinygltf
::
Value
(
transform
.
mOffset
.
mV
[
VX
]),
tinygltf
::
Value
(
transform
.
mOffset
.
mV
[
VX
]),
tinygltf
::
Value
(
transform
.
mOffset
.
mV
[
VY
])
tinygltf
::
Value
(
transform
.
mOffset
.
mV
[
VY
])
...
...
This diff is collapsed.
Click to expand it.
indra/llprimitive/llgltfmaterial.h
+
5
−
3
View file @
e4dd9c1e
...
@@ -56,6 +56,8 @@ class LLGLTFMaterial : public LLRefCount
...
@@ -56,6 +56,8 @@ class LLGLTFMaterial : public LLRefCount
F32
mRotation
=
0.
f
;
F32
mRotation
=
0.
f
;
LLMatrix3
asMatrix
();
LLMatrix3
asMatrix
();
bool
operator
==
(
const
TextureTransform
&
other
)
const
;
};
};
enum
AlphaMode
enum
AlphaMode
...
@@ -149,14 +151,14 @@ class LLGLTFMaterial : public LLRefCount
...
@@ -149,14 +151,14 @@ class LLGLTFMaterial : public LLRefCount
static
LLVector2
getDefaultTextureScale
();
static
LLVector2
getDefaultTextureScale
();
static
F32
getDefaultTextureRotation
();
static
F32
getDefaultTextureRotation
();
static
void
hackOverrideUUID
(
LLUUID
&
id
);
static
void
hackOverrideUUID
(
LLUUID
&
id
);
static
void
applyOverrideUUID
(
LLUUID
&
dst_id
,
const
LLUUID
&
override_id
);
static
void
applyOverrideUUID
(
LLUUID
&
dst_id
,
const
LLUUID
&
override_id
);
// set mAlphaMode from string.
// set mAlphaMode from string.
// Anything otherthan "MASK" or "BLEND" sets mAlphaMode to ALPHA_MODE_OPAQUE
// Anything otherthan "MASK" or "BLEND" sets mAlphaMode to ALPHA_MODE_OPAQUE
void
setAlphaMode
(
const
std
::
string
&
mode
,
bool
for_override
=
false
);
void
setAlphaMode
(
const
std
::
string
&
mode
,
bool
for_override
=
false
);
const
char
*
getAlphaMode
()
const
;
const
char
*
getAlphaMode
()
const
;
// set the contents of this LLGLTFMaterial from the given json
// set the contents of this LLGLTFMaterial from the given json
...
@@ -185,6 +187,6 @@ class LLGLTFMaterial : public LLRefCount
...
@@ -185,6 +187,6 @@ class LLGLTFMaterial : public LLRefCount
void
setFromTexture
(
const
tinygltf
::
Model
&
model
,
const
T
&
texture_info
,
TextureInfo
texture_info_id
,
LLUUID
&
texture_id_out
);
void
setFromTexture
(
const
tinygltf
::
Model
&
model
,
const
T
&
texture_info
,
TextureInfo
texture_info_id
,
LLUUID
&
texture_id_out
);
template
<
typename
T
>
template
<
typename
T
>
void
writeToTexture
(
tinygltf
::
Model
&
model
,
T
&
texture_info
,
TextureInfo
texture_info_id
,
const
LLUUID
&
texture_id
,
bool
is_override
,
const
LLUUID
&
base_
texture_id
)
const
;
void
writeToTexture
(
tinygltf
::
Model
&
model
,
T
&
texture_info
,
TextureInfo
texture_info_id
,
const
LLUUID
&
texture_id
)
const
;
};
};
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