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

Inital PR for MeshStandardMaterial #7381

Merged
merged 1 commit into from Oct 20, 2015

Conversation

Projects
None yet
5 participants
@WestLangley
Copy link
Collaborator

commented Oct 20, 2015

This PR contains the plumbing necessary to support the addition of MeshStandardMaterial, an easy-to-use, pre-defined material.

This material will be physically-based, and support roughness and metalness. Also, a roughness map, a reflectivity map, and a metalness map (aka, a metalness workflow). It uses the GGX brdf, with GGX-Smith visibility term. It also uses an "environment brdf" to modulate the reflectance of the environment map. This is considerably more realistic than the "combine" methods we employ now.

Future enhancements will add image-based lighting support, and perhaps light probes.

The details of the model are not important at this point; that can be discussed/debated/changed later. The material can also be renamed to MeshPhysicalMaterial if desired. The purpose of this PR is to get the plumbing in place.

This should not affect existing code; deletions are minimal.

I will provide an example of its use shortly.

/ping @bhouston

@mrdoob

This comment has been minimized.

Copy link
Owner

commented Oct 20, 2015

Looks great! We'll definitely have to find model/textures for this.
Also, yes, MeshPhysicalMaterial sounds more intuitive. I'll rename.

mrdoob added a commit that referenced this pull request Oct 20, 2015

Merge pull request #7381 from WestLangley/dev-standard
Inital PR for MeshStandardMaterial

@mrdoob mrdoob merged commit bc6ed16 into mrdoob:dev Oct 20, 2015

@mrdoob

This comment has been minimized.

Copy link
Owner

commented Oct 20, 2015

Hmm, I think you forgot to include materials/MeshStandardMaterial.js.

@WestLangley

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 20, 2015

Looks like I forgot a lot of stuff... sorry.

@mrdoob

This comment has been minimized.

Copy link
Owner

commented Oct 20, 2015

Also lights_standard_fragment.glsl.

@WestLangley

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 20, 2015

I failed to push the new files. Sorry. #7382

@WestLangley

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 20, 2015

Also, yes, MeshPhysicalMaterial sounds more intuitive. I'll rename.

One thing to think about. This model is desigend to be easy-to-use. It only has color, roughness, reflectivity, and metalness as its main parameters. Even so, it is physically-based.

@bhouston has proposed a more-sophisticated Disney-like material with clear-coat and the like. That material may be more appropriate for our MeshPhysicalMaterial.

It is up to you.

@mrdoob

This comment has been minimized.

Copy link
Owner

commented Oct 20, 2015

What do you think @bhouston?

@bhouston

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

Very very nice.

Usually people call it specularMap rather than reflectivityMap. That would reduce some of the code because we already have a specularMap.

I think we should aim for full compatibility with the UE4 Physical material, which is basically the Disney PBR material with slightly different parameterizations. :)

@bhouston

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

I would suggest only having a single MeshPhysicaMaterial, rather than a Standard and a Physical - just for simplicity sake.

@spite

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

Looks really nice, I like it. I read it as: the old "map" texture is albedo, roughness (glosiness), reflectivity (specular) and metalness, plus the old usual maps (normal, envMap). Will the Fresnel contribution be possible to modify, or is it enough with the Schlick's approximation?

@bhouston

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

@spite, normally specularColor (e.g. F0) should blend to white via Dielectric Fresnel using the Schlick approximation. What further control do you require? Here is how you can map between IOR and specularColor/F0 so you can use the Schlick's approximation:

function dielectricRefractionIndicesToF0( n1, n2 ) {
    var omn = ( n1 - n2 ) / ( n1 + n2 );
    return omn * omn;
}

function dielectricRefractionIndexToF0( n ) {
    return dielectricRefractionIndicesToF0( 1.0, n );
}

// derived via wolfram alpha: solve( a = (( 1-n ) / (1+n))^2, n )
function f0ToDielectricRefractionIndex( f0 ) {
    return ( Math.sqrt( f0 ) + 1 ) / ( 1 - Math.sqrt( f0 ) );
}
@WestLangley

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 20, 2015

I am in favor of a Disney-like model, too, but it involves 10, not 4, parameters. ( For example, some additional parameters would be sheen, tint, clearCoat, specularTint, clearCoatGloss, subsurface.) In my view, that is too much for the average user, so I proposed MeshStandardMaterial to replace Phong and perhaps Lambert, too. MeshStandardMaterial is still physically-based.

It was my vision to add the more-sophisticated Disney-like MeshPhysicalMaterial as an additional model for power users, and to reserve MeshStandardMaterial for use by most users.

@spite

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

@bhouston nice! i was just wondering about that. it looks cool. i agree that a basic, 4-params physical material for threejs will be more than enough for almost everyone

@WestLangley

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 20, 2015

@spite Many thanks for the positive feedback!

@bhouston specularMap can also be RGB, so to avoid confusion, I named it reflectivityMap. I am open to changing the name, however.

@bhouston @mrdoob I must say, from a marketing stanpoint, naming it MeshPhysicalMaterial was pure genius. : - )

@bhouston

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

If we are against implementing the rest of the standard UE4/Disney PBR model as part of this material to keep it simple, you should not call this Physical, rather call it Standard. I would only call this Physical if it is going to be compatible, or at least eventually compatible with the standard UE4/Disney Physical models -- otherwise we have to introduce a new MorePhysical material in the future, which would just be awkward. Unity actually has a similar simplified PBR material and they use the name Standard.

I think reflectivityMap is fine now that I understand how it differs. :)

@bhouston

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

Here is Unity's Standard material, which closely followed @WestLangley's implementation:

standardshadernewemptymaterial

(Although it looks Unity3D have even done away with the ability to control F0, unless I am mistaken, so one less parameter than this material.)

@mrdoob

This comment has been minimized.

Copy link
Owner

commented Oct 20, 2015

I think this is quite a change for what people is used. Evidence of this is how hard it is to find models/textures out there, so I think calling it MeshPhysicalMaterial makes it intuitive as a transition to learning PBR.

A more advanced material could be just called MeshPhysicalAdvancedMaterial (I know, it's long, we'll figure it out)

@mrdoob

This comment has been minimized.

Copy link
Owner

commented Nov 2, 2015

So yesterday I was checking out a bit more the *_variations examples and, in comparison with the PB material, I'm now a bit disgusted with MeshPhongMaterial to the point that I really want to encourage the use of the new material.

So yes, I think I'll rename the new material back to MeshStandardMaterial 😅

@WestLangley

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 2, 2015

So yes, I think I'll rename the new material back to MeshStandardMaterial

OK. So now can MeshPhysicalMaterial be the full-featured material that @bhouston has promoted?

@mrdoob

This comment has been minimized.

Copy link
Owner

commented Nov 2, 2015

I guess 😉

@mrdoob

This comment has been minimized.

Copy link
Owner

commented Nov 2, 2015

Yeah, that makes sense.

@simonihmig

This comment has been minimized.

Copy link

commented Dec 2, 2015

Great work! Any idea when this will land in master/be released?

@mrdoob

This comment has been minimized.

Copy link
Owner

commented Dec 2, 2015

December 15th, hopefully!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.