Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[F3D] Material Overflow Preview Fix #313

Closed
wants to merge 4 commits into from

Conversation

jesusyoshi54
Copy link
Collaborator

@jesusyoshi54 jesusyoshi54 commented Feb 27, 2024

Fixed the way overflow works on the color combiner.

  • Previous behavior was:
    • overflow [-0.5, 1.5) per cycle combined
  • New behavior is:
    • c overflows [-1.0, 1.0) on input
    • overflow [-0.5, 1.5) per cycle combined

On 2 cycle, the combiner doesn't actually do the special sign extension [-0.5, 1.5) on the first cycle's output unless it is for alpha compare, but since this will feed into inputs which are getting special sign extension on hardware it replicates the behavior properly.
This will come after #312

@Dragorn421
Copy link
Contributor

Dragorn421 commented Feb 27, 2024

to be clear,

overflow [-0.5, 1.5)

means "clamping into the [0, 1] range happens for values in range [-0.5, 1.5), values outside are not clamped properly" right? (not sure on the specifics of "not clamped properly")


On 2 cycle, the combiner doesn't actually do the special sign extension [-0.5, 1.5) on the first cycle's output unless it is for alpha compare, but since this will feed into inputs which are getting special sign extension on hardware it replicates the behavior properly.

can you clarify what is fast64 nodes behavior and what is hardware behavior here

@Dragorn421 Dragorn421 added this to the v2.2.1 milestone Feb 28, 2024
@Dragorn421
Copy link
Contributor

I am trying to review this, currently trying to make a test blend, but I stumbled upon

If you have a test blend already it'd be appreciated

@jesusyoshi54
Copy link
Collaborator Author

to be clear,

overflow [-0.5, 1.5)

means "clamping into the [0, 1] range happens for values in range [-0.5, 1.5), values outside are not clamped properly" right? (not sure on the specifics of "not clamped properly")

Values are coming out of the combiner have a special sign extension and clamp happening at those values, you can see that from AL source here with the definition of the clamp here.

So this means the output has values clamped to [0-1), with the overflow happening on [-0.5, 1.5). Anything [1-1.5) = 1, anything [-0.5-0] = 0.

On 2 cycle, the combiner doesn't actually do the special sign extension [-0.5, 1.5) on the first cycle's output unless it is for alpha compare, but since this will feed into inputs which are getting special sign extension on hardware it replicates the behavior properly.

can you clarify what is fast64 nodes behavior and what is hardware behavior here

I'll just go over this in steps. First the actual N64:

  • Inputs receive the sign extensions they're assigned. e.g. A, B, & D get special sign extension, C gets normal one
  • First cycle goes through the normal equation, gets right shifted by 8 (so that it is a s1.15 number).
  • If there is no second cycle, this gets the special clamping described above, otherwise the number goes straight to cycle 2.
  • Second cycle's inputs get the sign extensions assigned.
  • Second cycle's output gets the special clamping.

For Fast64 both cycles use the same nodes, so the formula is as follows:

  • C input receives normal sign extension
  • Combiner equation is calculated
  • Output gets special sign extension
  • Value is clamped [0-1) heading into blender (which is just fog/no fog for fast64).

@jesusyoshi54
Copy link
Collaborator Author

If you have a test blend already it'd be appreciated

You get the rendering bug when you feed a combined input of 256 into C input. It then undergoes normal sign extension and becomes negative. You can get a value of 256 by using 1.0 on the 1st cycle combiner.

So a 1st cycle value of 1, or (1-prim)*tex+prim, tex+prim etc. will result in a value of 256 output. Just anything where a value between 1-1.5 can be input into C.

@Dragorn421
Copy link
Contributor

has conflicts

@Dragorn421 Dragorn421 modified the milestones: v2.2.1, v2.2.2 Apr 13, 2024
@jesusyoshi54 jesusyoshi54 deleted the mat_clamp_fix branch April 21, 2024 09:23
@jesusyoshi54
Copy link
Collaborator Author

I messed up with my git history woops. Remade the branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants