Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions examples/jsm/exporters/USDZExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ function buildXform( object, geometry, material ) {

return `def Xform "${ name }" (
prepend references = @./geometries/Geometry_${ geometry.id }.usda@</Geometry>
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
matrix4d xformOp:transform = ${ transform }
Expand Down Expand Up @@ -415,7 +416,7 @@ function buildPrimvars( attributes, count ) {
if ( attribute !== undefined ) {

string += `
float2[] primvars:st${ id } = [${ buildVector2Array( attribute, count )}] (
texCoord2f[] primvars:st${ id } = [${ buildVector2Array( attribute, count )}] (
interpolation = "vertex"
)`;

Expand Down Expand Up @@ -467,6 +468,10 @@ function buildMaterial( material, textures ) {

const uv = texture.channel > 0 ? 'st' + texture.channel : 'st';

const rawTextureExtra = `(
colorSpace = "Raw"
)`;

return `
def Shader "PrimvarReader_${ mapType }"
{
Expand All @@ -488,7 +493,7 @@ function buildMaterial( material, textures ) {
def Shader "Texture_${ texture.id }_${ mapType }"
{
uniform token info:id = "UsdUVTexture"
asset inputs:file = @textures/Texture_${ id }.${ isRGBA ? 'png' : 'jpg' }@
asset inputs:file = @textures/Texture_${ id }.${ isRGBA ? 'png' : 'jpg' }@ ${mapType === 'normal' ? rawTextureExtra : ''}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should something like this be required for metalness, roughness, and other maps?

Suggested change
asset inputs:file = @textures/Texture_${ id }.${ isRGBA ? 'png' : 'jpg' }@ ${mapType === 'normal' ? rawTextureExtra : ''}
asset inputs:file = @textures/Texture_${ id }.${ isRGBA ? 'png' : 'jpg' }@ ${texture.colorSpace === NoColorSpace ? rawTextureExtra : ''}

Note the import would need to be added at top of file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure but don't think so, I believe it's required for normals because these need to be scaled with 2 * N - 1 (the scale and bias here) and end up outside 0..1 range, so it may not apply to "simply linear" textures. I'll ask!

Copy link
Copy Markdown
Contributor Author

@hybridherbst hybridherbst May 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the docs it looks like it should -
https://openusd.org/release/spec_usdpreviewsurface.html#:~:text=sourceColorSpace%20%2D%20token%20%2D%20auto
I asked in the USD Working Group, will report back here.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I believe it should be what Don is saying. I'll merge and amend it.
We can revert if needed when we hear from the USD Working Group.

float2 inputs:st.connect = </Materials/Material_${ material.id }/Transform2d_${ mapType }.outputs:result>
token inputs:wrapS = "repeat"
token inputs:wrapT = "repeat"
Expand Down