Skip to content

Detect UV2 for AO textures#106786

Open
TitanNano wants to merge 1 commit intogodotengine:masterfrom
TitanNano:jovan/detect_ao_uv2
Open

Detect UV2 for AO textures#106786
TitanNano wants to merge 1 commit intogodotengine:masterfrom
TitanNano:jovan/detect_ao_uv2

Conversation

@TitanNano
Copy link
Contributor

When the occlusionTexture in a GLTF document uses a texCoord index other than 0 the FLAG_AO_ON_UV2 should be enabled. This allows using the second set of UV coordinates for occlusion textures.

@TitanNano TitanNano requested a review from a team as a code owner May 24, 2025 22:49
@fire
Copy link
Member

fire commented May 24, 2025

Are you aware of the recently merged to assign texture channels arbitrarily pr

@fire
Copy link
Member

fire commented May 24, 2025

The pattern can be done for uv channels (texcoords) #99676

@TitanNano
Copy link
Contributor Author

The pattern can be done for uv channels (texcoords) #99676

You would like to have the ability to remap UV coordinates for every kind of texture, right? I can look into what is done in that PR.

@TitanNano
Copy link
Contributor Author

@fire I looked into the linked PR and thought about your comment.

I think implementing UV channel remapping is quite orthogonal to this PR. As it stands right now, the GLTF importer does not correctly import the UV channel of the occlusion map. This should be fixed for textures where the StandartMaterial3D supports using the secondary UV channel. (It can be argued that his PR should also support the correct import of the UV channel of emission textures).

Adding the ability to remap the UV channel would be a neat additional feature, but I would argue that is a new feature and not a fix to the default import behavior. Remapping would need to have the options {Disabled, UV1, UV2} where Disabled imports the UV channel as it was specified in the GLTF document.

Did I miss something here?

@fire
Copy link
Member

fire commented May 25, 2025

My point is that in gltf tex coordinate 1 is arbitrarily assigned to uv2 but theres 0 to 7 tex coordinates. So I wanted a second opinion how to resolve this.

@TitanNano
Copy link
Contributor Author

TitanNano commented May 25, 2025

Thanks for elaborating.

My point is that in gltf tex coordinate 1 is arbitrarily assigned to uv2 but theres 0 to 7

It's not arbitrary, though. TEXCOORD_0 and TEXCOORD_1 are already being imported as Godots UV and UV2.

if (a.has("TEXCOORD_0")) {
array[Mesh::ARRAY_TEX_UV] = _decode_accessor_as_vec2(p_state, a["TEXCOORD_0"], true, indices_mapping);
}
if (a.has("TEXCOORD_1")) {
array[Mesh::ARRAY_TEX_UV2] = _decode_accessor_as_vec2(p_state, a["TEXCOORD_1"], true, indices_mapping);
}

Perhaps if the UV channels 2 - 7 are encountered, though, a warning or error should be emitted, as this cannot be correctly imported.

@BlueCube3310
Copy link
Contributor

I'm assuming this is related to #96748

@TitanNano
Copy link
Contributor Author

@BlueCube3310 yes, that PR looks like a more complete version of my changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants