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

fix: Fix compatibility breaks at three r157 on MToon #1304

Merged
merged 6 commits into from
Oct 6, 2023

Conversation

MtBlue81
Copy link
Contributor

@MtBlue81 MtBlue81 commented Oct 1, 2023

Problem

  • Update to r157 in three.js causes mtoon shader error.
    CleanShot 2023-10-01 at 14 30 38

Changes

Comment on lines 54 to 57
#if THREE_VRM_THREE_REVISION >= 157
uniform vec3 lightProbe[ 9 ];
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uniform vec3 lightProbe[ 9 ] is still defined in lights_pars_begin with a macro #if defined( USE_LIGHT_PROBES ), so I think it will cause a problem when we actually want to use light probes.

https://github.com/mrdoob/three.js/blob/r157/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js#L5-L9

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MtBlue81-san just notices that it's a change from mrdoob/three.js#26768

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit: 3cf43b9

@@ -711,7 +777,9 @@ void main() {

vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );

#if THREE_VRM_THREE_REVISION >= 133
#if THREE_VRM_THREE_REVISION >= 157
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(premise: https://github.com/pixiv/three-vrm/pull/1304/files#r1342518857)

so, we want to use #if defined( USE_LIGHT_PROBES ) here.
Having the macro #if THREE_VRM_THREE_REVISION >= 157 looks good

Copy link
Contributor Author

@MtBlue81 MtBlue81 Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit: 3cf43b9, 598a756

Comment on lines 619 to 620
vec3 geometryPosition = - vViewPosition;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
Copy link
Contributor

@0b5vr 0b5vr Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered why we don't have to define geometryNormal here, and I found that the existing vec3 geometryNormal = normal in <normal_fragment_begin> have been renamed to nonPerturbedNormal in r157.
For consistency, I would love if you can rename the existing geometryNormal in the same way and add the new geometryNormal here.

mrdoob/three.js@7bf83b8#diff-0ef3a127f3d8eaf75269887ebb9da53c45aa287c14fc79b687c3dcfcd5d95cd9R74

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit: 8088de1

Copy link
Contributor

@0b5vr 0b5vr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mostly awesome! I really appreciate your hard work, thank you...

Let me sum up the remaining changes I want to see before merging this:

  • The lightProbe, USE_LIGHT_PROBES issue
  • The geometryNormal / nonPerturbedNormal rename
  • The CLEARCOAT -> USE_CLEARCOAT rename

@0b5vr 0b5vr added the bug Something isn't working label Oct 3, 2023
@0b5vr 0b5vr added this to the next milestone Oct 3, 2023
@MtBlue81 MtBlue81 requested a review from 0b5vr October 3, 2023 06:01
Copy link
Contributor

@0b5vr 0b5vr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! We will hopefully release this in the next week.

@0b5vr 0b5vr merged commit 9353930 into pixiv:dev Oct 6, 2023
@MtBlue81 MtBlue81 deleted the remove_geometric_context branch October 8, 2023 00:31
@0b5vr
Copy link
Contributor

0b5vr commented Oct 12, 2023

We've released the change @ v2.0.6.
Thank you for the contribution again!

0b5vr added a commit that referenced this pull request Jan 10, 2024
also removed an impossible compat code path
@0b5vr 0b5vr mentioned this pull request Jan 10, 2024
0b5vr added a commit that referenced this pull request Jan 15, 2024
also removed an impossible compat code path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants