TextureTransform: set material transform only when the extension is provided.
parent
4ad2368116
commit
2eed8b1820
|
@ -685,10 +685,13 @@ namespace glTF2
|
||||||
Ref<Texture> texture;
|
Ref<Texture> texture;
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
unsigned int texCoord = 0;
|
unsigned int texCoord = 0;
|
||||||
|
|
||||||
float offset[2];
|
bool textureTransformSupported = false;
|
||||||
float rotation;
|
struct TextureTransformExt {
|
||||||
float scale[2];
|
float offset[2];
|
||||||
|
float rotation;
|
||||||
|
float scale[2];
|
||||||
|
} TextureTransformExt_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NormalTextureInfo : TextureInfo
|
struct NormalTextureInfo : TextureInfo
|
||||||
|
|
|
@ -803,25 +803,26 @@ namespace {
|
||||||
inline void SetTextureProperties(Asset& r, Value* prop, TextureInfo& out) {
|
inline void SetTextureProperties(Asset& r, Value* prop, TextureInfo& out) {
|
||||||
if (r.extensionsUsed.KHR_texture_transform) {
|
if (r.extensionsUsed.KHR_texture_transform) {
|
||||||
if (Value *extensions = FindObject(*prop, "extensions")) {
|
if (Value *extensions = FindObject(*prop, "extensions")) {
|
||||||
if (Value *pKHR_texture_transform = FindObject(*extensions, "KHR_texture_transform")) {
|
out.textureTransformSupported = true;
|
||||||
|
if (Value *pKHR_texture_transform = FindObject(*extensions, "KHR_texture_transform")) {
|
||||||
if (Value *array = FindArray(*pKHR_texture_transform, "offset")) {
|
if (Value *array = FindArray(*pKHR_texture_transform, "offset")) {
|
||||||
out.offset[0] = (*array)[0].GetFloat();
|
out.TextureTransformExt_t.offset[0] = (*array)[0].GetFloat();
|
||||||
out.offset[1] = (*array)[1].GetFloat();
|
out.TextureTransformExt_t.offset[1] = (*array)[1].GetFloat();
|
||||||
} else {
|
} else {
|
||||||
out.offset[0] = 0;
|
out.TextureTransformExt_t.offset[0] = 0;
|
||||||
out.offset[1] = 0;
|
out.TextureTransformExt_t.offset[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ReadMember(*pKHR_texture_transform, "rotation", out.rotation)) {
|
if (!ReadMember(*pKHR_texture_transform, "rotation", out.TextureTransformExt_t.rotation)) {
|
||||||
out.rotation = 0;
|
out.TextureTransformExt_t.rotation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Value *array = FindArray(*pKHR_texture_transform, "scale")) {
|
if (Value *array = FindArray(*pKHR_texture_transform, "scale")) {
|
||||||
out.scale[0] = (*array)[0].GetFloat();
|
out.TextureTransformExt_t.scale[0] = (*array)[0].GetFloat();
|
||||||
out.scale[1] = (*array)[1].GetFloat();
|
out.TextureTransformExt_t.scale[1] = (*array)[1].GetFloat();
|
||||||
} else {
|
} else {
|
||||||
out.scale[0] = 1;
|
out.TextureTransformExt_t.scale[0] = 1;
|
||||||
out.scale[1] = 1;
|
out.TextureTransformExt_t.scale[1] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue