Skip to content

TSL: Support assignment to swizzled nodes without explicit call to toVar() #31638

@shotamatsuda

Description

@shotamatsuda

Description

#31459 introduced automatic use of toVar(), but assignments to swizzled nodes don't seem to be supported and result in malformed code without explicit calls to toVar(). This might be more of a feature request.

Examples

outputNode = Fn(() => {
  const a = vec3()
  a.zyx.assign(vec3(0, 1, 2))
  return a
})()

is transpiled to:

var nodeVar0 : vec3<f32>;

nodeVar0 = vec3<f32>( 0.0, 1.0, 2.0 );
vec3<f32>( 0.0, 0.0, 0.0 ).z = nodeVar0[ 0 ];
vec3<f32>( 0.0, 0.0, 0.0 ).y = nodeVar0[ 1 ];
vec3<f32>( 0.0, 0.0, 0.0 ).x = nodeVar0[ 2 ];

output.color = vec4<f32>( vec3<f32>( 0.0, 0.0, 0.0 ), 1.0 );

Reproduction steps

  1. Open the fiddle and see the output in the bottom right pane.

Code

See the code in the description and the fiddle below.

Live example

https://jsfiddle.net/shotamatsuda/qh4kasxb/

Screenshots

No response

Version

r179

Device

Desktop

Browser

Chrome

OS

MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugTSLThree.js Shading Language

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions