Skip to content

TSL: transformDirection operation is incorrect #33309

@njarraud

Description

@njarraud

Description

When using the transformDirection operation I believe the inner operation is incorrect.

The generated wgsl code is -

normalize( ( direction * matrix ).xyz )

When it shall be -

normalize( ( matrix * direction ).xyz )

Function signature -

transformDirection( direction : Node.<(vec2|vec3|vec4)>, matrix : Node.<(mat2|mat3|mat4)> ) : Node

Reproduction steps

  1. Create a node material
  2. Use transformDirection node
  3. Display generated wgsl

Code

if ( method === MathNode.TRANSFORM_DIRECTION ) {

	// dir can be either a direction vector or a normal vector
	// upper-left 3x3 of matrix is assumed to be orthogonal

	let tA = aNode;
	let tB = bNode;

	if ( builder.isMatrix( tA.getNodeType( builder ) ) ) {

		tB = vec4( vec3( tB ), 0.0 );

	} else {

		tA = vec4( vec3( tA ), 0.0 );

	}

	const mulNode = mul( tA, tB ).xyz; // shall be const mulNode = mul( tB, tA ).xyz;

	outputNode = normalize( mulNode );

}

Live example

Self explanatory

Screenshots

No response

Version

r183

Device

No response

Browser

No response

OS

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    TSLThree.js Shading Language

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions