AmplifyCreations / AmplifyShaderEditor-Feedback

4 stars 0 forks source link

Invalid preview of the Dot Product Node #338

Closed OwenTheProgrammer closed 3 weeks ago

OwenTheProgrammer commented 1 month ago

Amplify Version: 1.9.6.3

I've come across this one a couple times, but it seems like the dot product nodes preview is incorrect for float inputs and float4 inputs.

Replication Steps

  1. Create a new amplify shader or shader function
  2. Add the dot product node
  3. Input any combination of inputs that arent the type float3
  4. Determine if the output value is correct (here im using a texture tiling to display the value as tiling count)

Expected Functionality

Following the component definition of the dot product:

dot(A.x, B.x) = A.x * B.x;
dot(A.xy, B.xy) = A.x * B.x + A.y * B.y;
dot(A.xyz, B.xyz) = A.x * B.x + A.y * B.y + A.z * B.z;
dot(A.xyzw, B.xyzw) = A.x * B.x + A.y * B.y + A.z * B.z + A.w * B.w;

Example of the problem

With all input values set to 1, the expected outputs from top to bottom are [1, 2, 3, 4]. We instead get [3, 2, 3, 3] here as shown by the tiling of the texture (and the hover debug tool ive been using) image

The shader code seems to generate correctly, which is good image image

My Observations

This seems to be an issue of the preview shader Preview_DotProductOpNode doing the dot product of _A.rgb and _B.rgb knowing this is the fragment structure, I suspect the problem is as such:

//float example
return dot(_A.rgb, _B.rgb);
return dot( (1, 1, 1).rgb, (1, 1, 1).rgb );
return A.r*B.r + A.g*B.g + A.b*B.b;
return 1 * 1 + 1 * 1 + 1 * 1;
return 3;

and such..