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

Material ambient color #6501

Closed
ghost opened this issue May 2, 2015 · 39 comments
Closed

Material ambient color #6501

ghost opened this issue May 2, 2015 · 39 comments
Labels

Comments

@ghost
Copy link

ghost commented May 2, 2015

I use AssimpJSONLoader and can't find model's ambient color of materials in r71. Everything looks dark. In r68 it was ok.
Sorry 4 my English.

1

@WestLangley
Copy link
Collaborator

MeshPhongMaterial.ambient has been removed. It was the "ambient reflectance of the material" -- that is, how the material reflects ambient light.

We now assume the material reflects ambient light the same way it reflects direct light, and that is specified by MeshPhongMaterial.diffuse.

@ghost
Copy link
Author

ghost commented May 3, 2015

I have set in 3dsmax ambient for my models everywhere... If I change it to diffuse it will appear in js object? And have I to set diffuse color in 3dsmax to black now in order to see models how they will look in browser?
Now I can't see .diffuse (or you mean .color?) property too. Maybe I'ts of online converter?... Ok I'll try.

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

I have set in 3dsmax ambient for my models everywhere.

No need to do that.
By default, in 3DS Max "ambient" and "diffuse" are linked (locked).
"ambient" is needed only for self-illumination objects.
Otherwise, the ambient light will have the same effect for all the objects in scene.
If you need self-illumination in THREE, use something like:

object.material.emissive = new THREE.Color( 0.2, 0.2, 0.2 );

cheers

@DzzD
Copy link

DzzD commented May 3, 2015

It seems to me a strange assumption that ambient == diffuse for two reasons :

  • ambient is part of the phong shading illumination model
  • it may be hard without ambient to correcly lighting some 3d scene

For exampe : if you were looking Inside a building with spots light Inside it from the exterior, it may be necessary to tune ambient material color for interior and exterior.

Edit : also some materials may have a different color when lightened with diffuse vs ambient lighting

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

In 3DS Max always set diffuse to (255,255,255) for all the materials.
That will be exported as (1,1,1) in THREE.
The "ambient" color is ignored, so don't waste your time with that value ("locked" anyway).
In THREE you need to manually set the emissive value if you need self-illuminating model:
object.material.emissive = new THREE.Color( 0.2, 0.2, 0.2 );

Now for all those who don't understand the "ambient" value in 3DS Max.
These are from the 3DS Max docs:

The ambient color map is not visible in viewports or renderings unless the level of ambient light is greater than default value of black.
By default, in a Standard material the Diffuse Color map is applied to the Ambient Color as well.

I hope it's cristal clear now.
cheers

@ghost
Copy link
Author

ghost commented May 3, 2015

Seems I have understood about 3DS Max. I have to set one value for all "ambient" colors in Max and not to change it for any model. :) And in THREE to find according value for global AmbientLight.
I just wanted models to look the same color and brightness in Max and in THREE scene.

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

To understand better the "ambient" value in THREE:

http://necromanthus.com/Test/html5/girl_JS.html
var ambient = new THREE.AmbientLight( 0x606060 );

http://necromanthus.com/Test/html5/girl_JS_emissive.html
var ambient = new THREE.AmbientLight( 0x000000 );
"colorEmissive" : [0.2, 0.15, 0.10]

Clear enough isn't it?
cheers

@DzzD
Copy link

DzzD commented May 3, 2015

The ambient color map is not visible in viewports or renderings unless the level of ambient light is greater than default value of black.

Yes inded, which is totally logical but you dont always want ambient light to be black, usually it will often be greater than 0

I only wanted to point out that : IMHO, a material named "phong" without ambient sounds really strange for me.

Also emissive and ambient color are not really related, emissive is more used to display modelised light (light emitter object), ambient to simulate special material that react differently on direct and indirect lighting

Below a simple sample showing how using differents ambient and diffuse color may help to produce specials effects/material :

ambienttest

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

IMHO, a material named "phong" without ambient sounds really strange for me.

You don't need "ambient" for a "Phong" material.
You need "normal" and "specular":
http://necromanthus.com/Test/html5/claire.html

cheers

@DzzD
Copy link

DzzD commented May 3, 2015

pretty women :) (as a side note the background is blinking in IE11)

You need "ambient" for a "Phong" material.
You need "normal" and "specular"

Sorry, but I can't see the point, (indeed normal and specular are requiered too as for gouraud shading, only difference is perpixel normals or not). But finally does this mean you agree ?

Or did you think ambient is useless in phong material ?

NB.: I am really sorry to disturb, but as I use ThreeJS more and more (and I like it), it make me a little worry, because as far I can remember (3D studios or 3D engines Ambient have always been availables in materials)

( This is part of the phong lighting model : http://en.wikipedia.org/wiki/Phong_reflection_model )

@benaadams
Copy link
Contributor

Or did you think ambient is useless in phong material ?

That ambient is the effect of .color or .map with THREE.AmbientLight

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

Or did you think ambient is useless in phong material ?

For now "ambient" and "diffuse" is the same thing in THREE.
Why do you argue with me if WestLangley said "MeshPhongMaterial.ambient has been removed."?
As I told the dev team several times before, "there is always room for better".
;)

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

(as a side note the background is blinking in IE11)

It doesn't in Chrome, Firefox and Opera.
I don't use IE11 anyway ...
;)

@DzzD
Copy link

DzzD commented May 3, 2015

Why do you argue with me if WestLangley said "MeshPhongMaterial.ambient has been removed."?

Sorry, but as I use ThreeJS I just want to help using my experience, and this requiere I give my opinion good or not, but yes It may not be the right thread ... :/,

I subscribed just few days ago to GitHuB... at some time we are all newbies ...

(For the blinking it is related to render clear color I think, I got this problem, cant remember exacly but setting 0 to alpha clearcolor may help)

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

(For the blinking it is related to render clear color I think,
I got this problem, cant remember exacly but setting 0 to alpha clearcolor may help)

You should contact the Microsoft IE dev team to report the issue.
They are well known for not following the "global rules" in their products.
;)

@DzzD
Copy link

DzzD commented May 3, 2015

trolling start

10 years ago IE was 95% of users... at this time they was the rules.... in the 2000s it was even possible to embed directX (3D) in web browser(IE) ... so who have not follow the "global rules", this is a too loooong question that have been debated too much, but if someone sell 10 cars a year, do they are legitimate to explain to a company that sell 1000000 cars how they should do ?

/trolling end

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

10 years ago IE was 95% of users..

At this moment IE11 represents 1-2% of the market ...
On the other hand, Windows XP (18% of the users) is still more popular than Windows 8 + 8.1 (16% of the users).
Just to have an idea about what M$ did in the past 15 years ...

@benaadams
Copy link
Contributor

At this moment IE11 represents 1-2% of the market ...

Depends on your market, IE11 on desktop its 25% (http://www.netmarketshare.com/) [58% for IE generally]

capture

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

Depends on your market, IE11 on desktop its 25%

Ben,

It has nothing to do with MY market.
The internet is full of "sponsored and fake" statistics.
Let's forget about them.
Try to get the medium value of 100 more or less trusted statistics.
You may start with this one:
http://www.w3schools.com/browsers/browsers_stats.asp

Less than 8% for ALL the Internet Explorer versions.
In any case (to close this subject), from the WebGL point of view, IE11 represents about 1-2%.

cheers

@DzzD
Copy link

DzzD commented May 3, 2015

Depends on your market
Thanks as I did not dare to post this :)

But to be back to the topic there is no confusion for me between ambient, diffuse, specular and emissive color, they have different usage in 3D. If you only want to display a simple model this may work fine, you can by some workaround get fair results by tuning emissive, lights or whatever but, IMO in lot of cases the lack of ambient color and or level will limit the possibilities of the 3d engine..

Something with en emissive color should always be visible even with no light on (ambient + spot + etc... == 0)

If you have a scene when you can turn off the light every object with emissive color will stay visible wich is wrong if they are not light source.

@WestLangley
Copy link
Collaborator

@DzzD

material.ambient was the ambient reflectance of the material. For real-world objects, it should normally match material.color, the diffuse reflectance of the material. (Objects, after all, do not know where the photons came from.)

We chose to simplify the API, and hardwire material.ambient to match material.color. Consequently, material.ambient has been removed.

I understand you may want to implement special effects. Your work-around is to create a ShaderMaterial that replicates the MeshPhongMaterial (Blinn-Phong) illumination model, and then modify it to your liking.

Extending materials in this way is a bit tedious, but you can find examples on stackoverflow.

@DzzD
Copy link

DzzD commented May 3, 2015

@WestLangley
Thanks for this interresting replie, I did not want to achieve special effect for now, this was just a general meaning for ThreeJS (I mean to match what is currently existing in 3d sofware and engine)

@DzzD
Copy link

DzzD commented May 3, 2015

Let me just conclude with the following and I will leave you quiet (for some time) :) sorry

IMHO :
Diffuse color/level : is when the light come from a straight line (known sources) and go back diffused
Ambient color/level : is when the light come from infinities sources (unknown locations) and go back diffused
Specular color/level : ligth come from a straight line and go back in straight line

Some real world materials may react differently when lightened with a direct or indirect light (ambient), but the main probleme I can see in this simplification is that people will have to take care or tune their materials outside of their 3d editor

@benaadams
Copy link
Contributor

Some real world materials may react differently when lightened with a direct or indirect light (ambient), but the main probleme I can see in this simplification is that people will have to take care or tune their materials outside of their 3d editor

If you are doing texturing however you probably want the colors of the texture * ambient light to be returned rather than a flat color? Also if you just want a flat color use .emissive and this will achieve that effect.

@RemusMar
Copy link
Contributor

RemusMar commented May 3, 2015

the main probleme I can see in this simplification is that people will have to take care or tune their materials outside of their 3d editor

At this moment you need to edit every JS, DAE or OBJ file if you want the best results.
Not to mention that you need to create certain materials or to modify parameters at runtime.
Again: "there is always room for better".

cheers

p.s.
The above "cute" girl is using normal maps (loaded with the OBJ container).
Can you do that with the standard OBJ container?
LOL

@DzzD
Copy link

DzzD commented May 3, 2015

At this moment you need to edit every JS, DAE or OBJ file if you want the best results.
Not to mention that you need to create certain materials or to modify parameters at runtime.
Again: "there is always room for better".

Yes that's what I do for now, manualy modifying the material, but it is possible to get the same render than you get in 3d studio (I managed to get exact same render result in 3DzzD than the 3DS scene model I exported from 3D Max nb.: only using blin material not special one), removing ambient component will just make it harder to do this in the futur
.
Once again, this is just a general thought

@DzzD
Copy link

DzzD commented May 3, 2015

One good example could be skin :
You have nearly a flat pink ambient and when you put a direct light some other things may appears like blood vessel.

That may be the same for many translucent objects like banknotes.

@benaadams
Copy link
Contributor

You have nearly a flat pink ambient and when you put a direct light some other things may appears like blood vessel.

That may be the same for many translucent objects like banknotes.

I think you have moved out of scope of the MeshPhongMaterial :)

@DzzD
Copy link

DzzD commented May 4, 2015

The above "cute" girl is using normal maps (loaded with the OBJ container).
Can you do that with the standard OBJ container?
LOL

Hehe this a modification I needed and I've done too ^^ by adding "map_bump" pattern but using it as a normal map (not a bump), but OBJ lack a lot of things (and obj exporter are rarely complet), 3DS handle a lot of more things and exporters work pretty well.

NB.: note that it would be possible to make it automatic by detecting normal map (most blue) VS bump (grayscale)

@mrdoob
Copy link
Owner

mrdoob commented May 4, 2015

Below a simple sample showing how using differents ambient and diffuse color may help to produce specials effects/material :

ambienttest

I'm aware of those special effects you can achieve (I used to use 3DSMAX in the past).

But that's not how materials behave in the real world, so we opted for simplifying the API so people have less things to "learn" and, at the same time, there are less things for us to maintain or worry about.

@mrdoob mrdoob closed this as completed May 4, 2015
@mrdoob mrdoob added the Question label May 4, 2015
@DzzD
Copy link

DzzD commented May 5, 2015

I understand the desire to make the API as simple as possible (I really had the same goal in the past), but this may cause unwanted sides effects that will requiere more works for ThreeJS users, like need to rework materials after export from a 3D modeler,

Maybe a middle solution is possible as keeping ambient but using diffuse if it is not defined.?

@tistatos
Copy link

I must say I also find this to be a very weird decision to remove ambient coefficients seeing they are part of many illuminations models. Especially since it was implemented previously?

And I understand what you mean with how materials behave in the real world, but isn't that part of the beauty of computer graphics? It doesn't have to be real life! 😄

@Wilt
Copy link
Contributor

Wilt commented Jan 14, 2016

As @WestLangley said they tied material.ambient by default to match material.color. So if a middle way is chosen I would say that it could be easy right?

THREE.MeshBasicMaterial = function ( parameters ) {
    //...
    this.color = new THREE.Color( 0xffffff );
    this.ambient = this.color;
    //...
}

Or would that not have the same optimizing effect?


I get two values from my original model information:

A surfaceColor and a diffuseColor. The diffuseColor is either a different color or a scalar used to scale the surfaceColor value into a diffuseColor...
The previous API allowed me to set the correct color without any issues:

material.ambient = surfaceColor

if( typeof diffuseColor === 'number' ){
    material.color = surfaceColor.multiplyScalar( diffuseColor );
}else{
    // We have a color not a scalar, set the color
    material.color = diffuseColor;
}

Similar solution for my specular color...

I would really like to be able to set ambient again in my materials so I can set the materials exactly as defined in my model.

@Wilt
Copy link
Contributor

Wilt commented Jan 14, 2016

In openGL materials also have different ambient, diffuse, and specular colors (link). As I understood from others also 3DMax allows different ambient and diffuse colors. And like I said also my model definition holds different ambient and diffuse color definitions.

It seems sad that something which was implemented for a long time (at least since r25) and which was working well for lots of people is removed from the library because of the sake of simplifying the API. Can the API not be simplified without losing the possibility to set ambient for those who use it?

I also like @tistatos his view: but isn't that part of the beauty of computer graphics :)

@mrdoob
Copy link
Owner

mrdoob commented Jan 14, 2016

Can the API not be simplified without losing the possibility to set ambient for those who use it?

We tried. It confused people more people than actual people used it. Doesn't follow the real physical world. Ultimately people want to have realistic renders. Eventually, I think MeshLambertMaterial and MeshPhongMaterial will move out of core so we can focus on MeshStandardMaterial. Maybe then we can add ambient back for people that want to continue using old lighting models.

I understand it's sad that things get removed. A way to make sure things don't get removed is by helping with user support. If I see there is something problematic that new users are struggling for and no one helping them then I have two options, put the library development on hold so I can help these users, or remove what they're struggling with. Putting the library on hold is dangerous (I could get burned out), so I give priority to not doing that.

@mrdoob
Copy link
Owner

mrdoob commented Jan 14, 2016

I would really like to be able to set ambient again in my materials so I can set the materials exactly as defined in my model.

Maybe you can just build the ShaderMaterial that goes with your model.

@Wilt
Copy link
Contributor

Wilt commented Jan 14, 2016

@mrdoob I will look into that...

But is doing this.ambient = this.color no option at all?

Hope you won't remove MeshLambertMaterial and MeshPhongMaterial though!

@mrdoob
Copy link
Owner

mrdoob commented Jan 14, 2016

Hope you won't remove MeshLambertMaterial and MeshPhongMaterial though!

In the future they most likely be moved to the examples folder. MeshStandardMaterial follows more closely how materials look in the real world and it'll be more easy for people to learn and achieve convincing results.

@Wilt
Copy link
Contributor

Wilt commented Jan 15, 2016

@mrdoob I try where I can to help with user support. But to be honest I am no expert either and I actually have no clue how to fix my broken ambient effect.

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

No branches or pull requests

7 participants