Skip to content

Commit

Permalink
USDZExporter: add MaterialBindingAPI schema, fix primvars:st data typ…
Browse files Browse the repository at this point in the history
…e, add colorspace for normal map (#26009)
  • Loading branch information
hybridherbst authored May 8, 2023
1 parent e6e95d5 commit faf95b2
Showing 1 changed file with 7 additions and 2 deletions.
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 : ''}
float2 inputs:st.connect = </Materials/Material_${ material.id }/Transform2d_${ mapType }.outputs:result>
token inputs:wrapS = "repeat"
token inputs:wrapT = "repeat"
Expand Down

0 comments on commit faf95b2

Please sign in to comment.