How to set Normal Texture Scale Value as a Vector ([1, -1])

35 views Asked by At

I'm using the gltf-json crate for this job. I want to be able to change the normal texture scale to [1, -1] to an asset that comes with [1, 1], however, the scale field is of type f32.

pub struct NormalTexture {
    pub index: Index<Texture>,
    pub scale: f32,
    pub tex_coord: u32,
    pub extensions: Option<NormalTexture>,
    pub extras: Extras,
}

Does anyone know if there's a workaround for this?

1

There are 1 answers

0
Don McCurdy On

This is based in the glTF specification, which requires a scalar value for material.normalTextureInfo.scale. No valid tool will be able to work around that, other than writing extras or a custom extension to the file.

An aside, I would note that depending on the client loading this file, the correct client interpretation of scale = 1 might turn out to be [1, -1], based on the UV conventions of the engine, presence of vertex tangents, etc. This occurs in the three.js glTF loader, for example.