Skip to content

Conversation

@wtlyu
Copy link
Contributor

@wtlyu wtlyu commented Dec 12, 2017

Fixes #12861

@wtlyu wtlyu mentioned this pull request Dec 12, 2017
14 tasks
@mrdoob
Copy link
Owner

mrdoob commented Dec 12, 2017

I don't know...

@wtlyu wtlyu force-pushed the eastpiger-patch-MTLLoader-equalizeTransparency branch from fff1a5f to e140664 Compare December 12, 2017 09:24
@wtlyu
Copy link
Contributor Author

wtlyu commented Dec 12, 2017

@mrdoob I have re-committed this modification. This modification won't change the default behavior of MTLLoader. Only add a new option to give us capability to switch the parsing of keyword Ts (Ts = 1 - d or Ts = d).

Related documents is also updated.

if ( n > 0 ) {

params.opacity = 1 - n;
if ( this.options && this.options.equalizeTransparency )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a code style issue. Please write it like this

if ( this.options && this.options.equalizeTransparency ) {

   params.opacity = n;

} else {

   params.opacity = 1 - n;

}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will update soon

@WestLangley
Copy link
Collaborator

Did you test this code?

@WestLangley
Copy link
Collaborator

Maybe

options.TrOneIsOpaque = true; // default is false

@wtlyu wtlyu force-pushed the eastpiger-patch-MTLLoader-equalizeTransparency branch 2 times, most recently from b4f9e56 to 9007c0b Compare December 12, 2017 16:46
@wtlyu wtlyu changed the title add equalizeTransparency option to MTLLoader add TrOneIsOpaque option to MTLLoader Dec 12, 2017
params.opacity = 1 - n;
if ( this.options && this.options.TrOneIsOpaque ) {

params.opacity = n;
Copy link
Collaborator

@WestLangley WestLangley Dec 12, 2017

Choose a reason for hiding this comment

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

params.transparent is set to true when options.TrOneIsOpaque = true and Tr = 1. ???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Emmmm... good comment. I didn't notice it. fix soon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

@wtlyu wtlyu force-pushed the eastpiger-patch-MTLLoader-equalizeTransparency branch from 9007c0b to 64ecc25 Compare December 13, 2017 16:58
<li>wrap: What type of wrapping to apply for textures. THREE.RepeatWrapping (default), THREE.ClampToEdgeWrapping, THREE.MirroredRepeatWrapping</li>
<li>normalizeRGB: RGBs need to be normalized to 0-1 from 0-255. Default: false, assumed to be already normalized</li>
<li>ignoreZeroRGBs: Ignore values of RGBs (Ka,Kd,Ks) that are all 0's. Default: false</li>
<li>TrOneIsOpaque: Use values 1 of Tr field for fully opaque. This option is useful for obj exported from 3ds MAX, vcglib or meshlab. Default: false</li>
Copy link
Owner

Choose a reason for hiding this comment

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

How about calling it invertTr or invertTrProperty?

@mrdoob
Copy link
Owner

mrdoob commented Dec 18, 2017

if ( this.options && this.options.invertTr ) n = 1 - n;

if ( n < 1 ) {

	params.opacity = n;
	params.transparent = true;

}

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 4, 2018

@eastpiger Any news on this PR?

@wtlyu wtlyu force-pushed the eastpiger-patch-MTLLoader-equalizeTransparency branch from 64ecc25 to ad90938 Compare January 16, 2018 09:21
@wtlyu
Copy link
Contributor Author

wtlyu commented Jan 16, 2018

Yep.

@mrdoob mrdoob merged commit b2fc3b4 into mrdoob:dev Jan 18, 2018
@mrdoob
Copy link
Owner

mrdoob commented Jan 18, 2018

Thanks!

@RSpace
Copy link

RSpace commented Mar 22, 2018

Merging this PR has made any obj model material with Tr 0.0000 specified in the mtl file completely transparent, where before it would be completely opaque. It's breaking quite a lot stuff out there.

The problem looks fairly obvious to me. It was fine to add

if ( this.options && this.options.invertTrProperty ) n = 1 - n;

but

					if ( n > 0 ) {

						params.opacity = 1 - n;
						params.transparent = true;

					}

should never have been changed to

					if ( n < 1 ) {

						params.opacity = n;
						params.transparent = true;

					}

which completely reverse the logic and makes invertTrProperty work reverse of what it should have.

I'd be happy to submit a PR to fix this, unless I'm missing something?

@mrdoob
Copy link
Owner

mrdoob commented Mar 24, 2018

Yes please. A PR would be great 👌

@WestLangley
Copy link
Collaborator

which completely reverse the logic and makes invertTrProperty work reverse of what it should have.

#12861 (comment) implies "what it should have" is not well-defined. (Are the docs correct?)

Consequently, this.options.invertTrProperty is not well-defined, either.

@RSpace
Copy link

RSpace commented Mar 24, 2018

@WestLangley Agreed. I have no need for this.options.invertTrProperty personally, and as such would be just a happy to submit a PR that simply reverts this PR and gets rid of this.options.invertTrProperty, as I would be to submit a PR that changes logic as described above, but still leaves the question of whether the logic behind this.options.invertTrProperty is correct open.

I assume this PR was merged for a good reason, but I'd prefer reverting it unless @eastpiger or someone else can chime in with a good explanation of what's going on here?

@WestLangley
Copy link
Collaborator

As implemented, Tr and d are, by default, interpreted the same: 0 is transparent, and 1 is opaque. However, as written, the documentation is not correct.

@wtlyu
Copy link
Contributor Author

wtlyu commented Mar 25, 2018

Hi all. I'm glad to make more explanation about this problem.

as I described in issue #12861, the definition of Tr option in .MTL file is confusing since it actually hasn't never been defined officially. There is a big controversy about it between academic and engineering application. I tried to ask Dr. John Burkardt, which holds the earliest webpage I can find given another different definition, and he didn't give a clear reason and answer about that. Since these two conflicting definition is both widely used in some big projects, (for example, d = Kr = 1 for opaque material is used in 3DS MAX and vcglib, which built meshLab, a good cloud point processing tool project), I give this PR to three.js hoping given a nondiscriminatory treat to them.

On the other hand. I do totally agree that this change is not supposed to break the back compatibility. I feel very very sorry to bother your work these days. Because that we had some discussion about how to introduce this feature properly and I made reset-and-recommit three times before it was merged. I used the suggestion given by mrdoob in the final version. Unfortunately, because of my carelessness, I didn't re-check the code here and it do make an inverse effect. Yes, @RSpace , you are right, that code treats the Tr option in the inverse way.

I will open a new PR fixing this soon.

and I do want to express my apologize of my careless, and I'm truly very very sorry to @mrdoob @WestLangley @RSpace as well as anyone who was confused by my mistake.

@RSpace
Copy link

RSpace commented Mar 31, 2018

@eastpiger Thanks for the clarification. We all make mistakes, and I'm thankful to everyone who contributes to three.js, making it the fantastic library it is today. Your PR #13685 fixes the issue for me :)

@mrdoob
Copy link
Owner

mrdoob commented Apr 3, 2018

and I do want to express my apologize of my careless, and I'm truly very very sorry to @mrdoob @WestLangley @RSpace as well as anyone who was confused by my mistake.

No worries!! 🙌

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.

5 participants