Unity-Technologies / Unity-Technologies/Unity.Mathematics

float3x4 in cg and float3x4 in unity math behave differently

Open
#79 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.4k
Forks
159
PR merge metrics
No merged PRs in 30d

Description

Consider:

float3x4 a = new float3x4();
a[2][3] = 1;

In unity math, this causes an error.

Error in unity: ArgumentException: index must be between[0...2]

In cg, there is no error.

I may be missing something, but a float4x3 array in unity seems to have the behavior of a float3x4 in cg.

In cg:

	float4x3 a;
	a[2][3] = 1;

will cause:
Shader error in 'Gen18.compute': array index out of bounds at kernel SolveSpringPairs at Gen18.compute(240) (on d3d11)

Whereas in Unity:

     float4x3 a = new float4x3();
        a[2][3] = 1;

causes no error.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the float3x4 and float4x3 indexing snippets from the issue and inspect the corresponding Unity.Mathematics matrix indexers. Compare their behavior with the reported Cg semantics; done means the intended indexing behavior is established and the inconsistent result is corrected or documented with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.